From b14bd96cb26b250d234144b055ecdc4150401ae7 Mon Sep 17 00:00:00 2001 From: lzh Date: Fri, 19 Dec 2025 13:54:09 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 应用 linter 和 prettier 格式化规则 --- apps/web-antd/PROJECT_STRUCTURE_GUIDE.md | 222 ++++++++++-------- apps/web-antd/src/layouts/auth-original.vue | 1 - apps/web-antd/src/layouts/auth.vue | 14 +- .../src/views/_core/authentication/login.vue | 8 +- .../inject-app-loading/default-loading.html | 6 +- .../icons/login-illustration.vue | 27 ++- 6 files changed, 155 insertions(+), 123 deletions(-) diff --git a/apps/web-antd/PROJECT_STRUCTURE_GUIDE.md b/apps/web-antd/PROJECT_STRUCTURE_GUIDE.md index f019dadf4..eabfdb7da 100644 --- a/apps/web-antd/PROJECT_STRUCTURE_GUIDE.md +++ b/apps/web-antd/PROJECT_STRUCTURE_GUIDE.md @@ -43,16 +43,16 @@ yudao-ui-admin-vben/ ### 技术栈 -| 技术 | 版本 | 说明 | -|------|------|------| -| Vue | 3.x | 渐进式 JavaScript 框架 | -| Vite | 5.x | 下一代前端构建工具 | -| TypeScript | 5.x | 类型安全 | -| Ant Design Vue | 4.x | UI 组件库 | -| Pinia | 2.x | 状态管理 | -| Vue Router | 4.x | 路由管理 | -| Tailwind CSS | 3.x | 原子化 CSS | -| VueUse | 10.x | Vue Composition API 工具集 | +| 技术 | 版本 | 说明 | +| -------------- | ---- | -------------------------- | +| Vue | 3.x | 渐进式 JavaScript 框架 | +| Vite | 5.x | 下一代前端构建工具 | +| TypeScript | 5.x | 类型安全 | +| Ant Design Vue | 4.x | UI 组件库 | +| Pinia | 2.x | 状态管理 | +| Vue Router | 4.x | 路由管理 | +| Tailwind CSS | 3.x | 原子化 CSS | +| VueUse | 10.x | Vue Composition API 工具集 | --- @@ -193,7 +193,7 @@ import { VbenToast, VbenDropdown, VbenSelect, - VbenPinInput, // 验证码输入框 + VbenPinInput, // 验证码输入框 VbenLoading, VbenSpinner, // ... 更多组件 @@ -201,6 +201,7 @@ import { ``` **常用组件**: + - **按钮类**: `VbenButton`, `VbenIconButton` - **输入类**: `VbenInput`, `VbenInputPassword`, `VbenPinInput` - **选择类**: `VbenSelect`, `VbenDropdown`, `VbenCheckbox`, `VbenRadio` @@ -268,23 +269,24 @@ import { VbenModal, VbenDrawer } from '@vben-core/popup-ui'; ```typescript import { // 布局组件 - AuthPageLayout, // 认证页布局 - LoginIllustration, // 登录插图 (自定义新增) - + AuthPageLayout, // 认证页布局 + LoginIllustration, // 登录插图 (自定义新增) + // 小部件 - ThemeToggle, // 主题切换 - LanguageToggle, // 语言切换 - ColorToggle, // 颜色选择器 - LayoutToggle, // 布局切换 - UserDropdown, // 用户下拉菜单 - Breadcrumb, // 面包屑 - GlobalSearch, // 全局搜索 - LockScreen, // 锁屏 - Notification, // 通知 + ThemeToggle, // 主题切换 + LanguageToggle, // 语言切换 + ColorToggle, // 颜色选择器 + LayoutToggle, // 布局切换 + UserDropdown, // 用户下拉菜单 + Breadcrumb, // 面包屑 + GlobalSearch, // 全局搜索 + LockScreen, // 锁屏 + Notification, // 通知 } from '@vben/layouts'; ``` **目录结构**: + ``` packages/effects/layouts/src/ ├── authentication/ # 认证相关 @@ -309,17 +311,17 @@ packages/effects/layouts/src/ ```typescript import { // 认证组件 - AuthenticationLogin, // 登录表单 - AuthenticationCodeLogin, // 验证码登录 + AuthenticationLogin, // 登录表单 + AuthenticationCodeLogin, // 验证码登录 AuthenticationForgetPassword, // 忘记密码 - AuthenticationRegister, // 注册 - + AuthenticationRegister, // 注册 + // 其他通用组件 - Page, // 页面容器 - DocAlert, // 文档提醒 - Description, // 描述列表 - Ellipsis, // 文本省略 - Iframe, // 内嵌页面 + Page, // 页面容器 + DocAlert, // 文档提醒 + Description, // 描述列表 + Ellipsis, // 文本省略 + Iframe, // 内嵌页面 // ... } from '@vben/common-ui'; ``` @@ -330,10 +332,10 @@ import { ```typescript import { - useWatermark, // 水印 - useTabs, // 标签页管理 - useContentHeight, // 内容高度自适应 - isTenantEnable, // 租户功能是否启用 + useWatermark, // 水印 + useTabs, // 标签页管理 + useContentHeight, // 内容高度自适应 + isTenantEnable, // 租户功能是否启用 } from '@vben/hooks'; ``` @@ -366,6 +368,7 @@ $t('authentication.username'); ``` **语言包位置**: + - 中文: `packages/locales/src/langs/zh-CN/*.json` - 英文: `packages/locales/src/langs/en-US/*.json` @@ -373,10 +376,10 @@ $t('authentication.username'); ```typescript import { - useUserStore, // 用户信息 - useAccessStore, // 权限信息 - useTabsStore, // 标签页 - useAppStore, // 应用配置 + useUserStore, // 用户信息 + useAccessStore, // 权限信息 + useTabsStore, // 标签页 + useAppStore, // 应用配置 } from '@vben/stores'; const userStore = useUserStore(); @@ -387,9 +390,9 @@ await userStore.fetchUserInfo(); ```typescript import { - preferences, // 偏好设置对象 - updatePreferences, // 更新偏好设置 - usePreferences, // 响应式偏好设置 + preferences, // 偏好设置对象 + updatePreferences, // 更新偏好设置 + usePreferences, // 响应式偏好设置 } from '@vben/preferences'; // 读取 @@ -411,12 +414,12 @@ import { // 路由工具 mapTree, resetRoutes, - + // 通用工具 formatDate, formatDateTime, openWindow, - + // 验证器 isEmail, isPhone, @@ -431,7 +434,7 @@ import { // 核心常量 LOGIN_PATH, VBEN_DOC_URL, - + // 业务枚举 DictEnum, SystemEnum, @@ -485,6 +488,7 @@ export default defineConfig(async () => { ``` **路径别名**: + - `#/*` → `./src/*` (应用内部) - `@vben/*` → `packages/*` (公共包) @@ -519,7 +523,7 @@ VITE_APP_NAMESPACE=vben-web-antd ```typescript const BUILT_IN_THEME_PRESETS: BuiltinThemePreset[] = [ { - color: 'hsl(37 100% 52%)', // #FFA00A + color: 'hsl(37 100% 52%)', // #FFA00A type: 'amber', }, // ... 其他颜色 @@ -532,7 +536,7 @@ export const COLOR_PRESETS = [...BUILT_IN_THEME_PRESETS].slice(0, 8); ```typescript type BuiltinThemeType = - | 'amber' // 新增 + | 'amber' // 新增 | 'default' | 'orange' | 'red' @@ -545,10 +549,10 @@ type BuiltinThemeType = ```typescript const defaultPreferences: Preferences = { theme: { - builtinType: 'amber', // 默认主题类型 + builtinType: 'amber', // 默认主题类型 colorPrimary: 'hsl(37 100% 52%)', // 主色调 - mode: 'dark', // 暗色模式 - radius: '0.5', // 圆角 + mode: 'dark', // 暗色模式 + radius: '0.5', // 圆角 }, // ... }; @@ -564,11 +568,12 @@ const defaultPreferences: Preferences = { .loader::after { background: hsl(var(--primary, 37 100% 52%)); /* 橙色 #FFA00A */ } - + /* 标题样式 */ .title { font-weight: 600 !important; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important; + font-family: + -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important; } ``` @@ -584,6 +589,7 @@ const defaultPreferences: Preferences = { **文件**: `apps/web-antd/src/layouts/auth.vue` **主要特性**: + - ✅ 橙色渐变背景 (`rgb(218,125,68)` → `#FFA00A`) - ✅ 浮动插图动画(左侧) - ✅ 表单卡片居右 @@ -592,12 +598,9 @@ const defaultPreferences: Preferences = { - ✅ 快速过渡动画 **组件引用**: + ```typescript -import { - LanguageToggle, - LoginIllustration, - ThemeToggle, -} from '@vben/layouts'; +import { LanguageToggle, LoginIllustration, ThemeToggle } from '@vben/layouts'; ``` **详细文档**: 参见 `apps/web-antd/LOGIN_LAYOUT_README.md` @@ -607,12 +610,14 @@ import { **文件**: `apps/web-antd/src/views/_core/authentication/login.vue` **功能**: + - 用户名/密码登录 - 图形验证码 - 记住密码 - 第三方登录(手机、二维码) **表单配置示例**: + ```typescript const formSchema = computed((): VbenFormSchema[] => [ { @@ -634,16 +639,19 @@ const formSchema = computed((): VbenFormSchema[] => [ ### 验证码登录/忘记密码 **文件**: + - `apps/web-antd/src/views/_core/authentication/code-login.vue` - `apps/web-antd/src/views/_core/authentication/forget-password.vue` **验证码组件** (`VbenPinInput`): + - ✅ 验证码长度: 6 位 - ✅ 发送前验证手机号 - ✅ 倒计时 60 秒 - ✅ 失败自动清除倒计时 **修复**: `packages/@core/ui-kit/shadcn-ui/src/components/pin-input/input.vue` + ```typescript async function handleSend(e: Event) { try { @@ -722,6 +730,7 @@ pnpm update #### 1. Vue DevTools 安装 Vue DevTools 浏览器扩展,可以查看: + - 组件树 - Pinia 状态 - 路由信息 @@ -730,6 +739,7 @@ pnpm update #### 2. 网络请求调试 打开浏览器开发者工具 Network 面板: + - 查看 API 请求/响应 - 检查请求头/响应头 - 查看接口耗时 @@ -746,6 +756,7 @@ console.log('权限列表:', accessStore.accessCodes); #### 4. 断点调试 在 VS Code 中配置 `.vscode/launch.json`: + ```json { "version": "0.2.0", @@ -764,6 +775,7 @@ console.log('权限列表:', accessStore.accessCodes); #### 5. 性能分析 使用 Vue DevTools Performance 功能: + - 记录组件渲染时间 - 查找性能瓶颈 - 优化重渲染 @@ -775,11 +787,12 @@ console.log('权限列表:', accessStore.accessCodes); ### 1. 主题色定制 (#FFA00A - 橙色) #### 文件: `packages/@core/preferences/src/constants.ts` + ```typescript // 新增 amber 主题色 const BUILT_IN_THEME_PRESETS: BuiltinThemePreset[] = [ { - color: 'hsl(37 100% 52%)', // #FFA00A + color: 'hsl(37 100% 52%)', // #FFA00A type: 'amber', }, // ... @@ -788,18 +801,20 @@ export const COLOR_PRESETS = [...BUILT_IN_THEME_PRESETS].slice(0, 8); // 7→8 ``` #### 文件: `packages/@core/base/typings/src/app.d.ts` + ```typescript type BuiltinThemeType = - | 'amber' // ← 新增 - | 'default' - // ... + | 'amber' // ← 新增 + | 'default'; +// ... ``` #### 文件: `packages/@core/preferences/src/config.ts` + ```typescript const defaultPreferences: Preferences = { theme: { - builtinType: 'amber', // ← 设为默认 + builtinType: 'amber', // ← 设为默认 colorPrimary: 'hsl(37 100% 52%)', // ← 设为默认 // ... }, @@ -813,6 +828,7 @@ const defaultPreferences: Preferences = { #### 文件: `apps/web-antd/src/layouts/auth.vue` **完全重构,新增功能**: + - ✅ 橙色渐变背景 (从 `rgb(218,125,68)` 到 `#FFA00A`) - ✅ 浮动插图组件 (左侧,带动画) - ✅ 白色 Logo 文字,带阴影 @@ -822,30 +838,32 @@ const defaultPreferences: Preferences = { - ✅ 保留原有 Toolbar (主题、语言切换) **关键代码**: + ```vue