# 前端系统性重构 - 白色体系设计规范实施 > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. **Goal:** 基于前端优化方案与设计规范文档,对前端项目进行系统性重构,统一白色色彩体系,创建通用组件库,优化信息密度,提升用户体验。 **Architecture:** 采用分层重构策略:先建立设计令牌系统(CSS变量)→ 创建通用组件库 → 重构全局样式 → 重构导航系统 → 逐个模块替换为通用组件。确保每一步都可独立验证,保持功能完整性。 **Tech Stack:** Vue 3 (Composition API / ` ``` #### Task 2.2: 创建 TabsBar 组件 **Files:** - Create: `src/components/common/TabsBar.vue` - [ ] **Step 1: 创建 TabsBar.vue** ```vue ``` #### Task 2.3: 创建 ContentCard 组件 **Files:** - Create: `src/components/common/ContentCard.vue` - [ ] **Step 1: 创建 ContentCard.vue** ```vue ``` #### Task 2.4: 创建 StatsRow 组件 **Files:** - Create: `src/components/common/StatsRow.vue` - [ ] **Step 1: 创建 StatsRow.vue** ```vue ``` #### Task 2.5: 创建 DataTable 组件 **Files:** - Create: `src/components/common/DataTable.vue` - [ ] **Step 1: 创建 DataTable.vue** ```vue ``` --- ### Task 3: 重构全局样式 (style.css) **Files:** - Modify: `src/style.css` - [ ] **Step 1: 完全重写 style.css 为白色体系** 将现有的 `src/style.css` 替换为以下内容: ```css /* ======================================== 全局样式 - 白色体系 基于设计令牌系统 ======================================== */ * { margin: 0; padding: 0; box-sizing: border-box; } html, body { width: 100%; height: 100%; overflow-x: hidden; overflow-y: hidden; } body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif; line-height: 1.5; color: var(--text-primary); background: var(--bg-page); } #app { width: 100%; height: 100%; } /* ===== 布局基础 ===== */ .ant-layout { background: var(--bg-page); } .ant-layout-header { background: var(--bg-header); box-shadow: var(--shadow-sm); } /* ===== 卡片统一样式 ===== */ .ant-card { border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--border-light); transition: all var(--transition-fast); } .ant-card:hover { box-shadow: var(--shadow-md); } .ant-card-head { border-bottom: 1px solid var(--border-light); padding: var(--space-md) var(--card-padding); background: var(--bg-page); border-radius: var(--radius-lg) var(--radius-lg) 0 0; } .ant-card-head-title { font-weight: var(--weight-semibold); color: var(--text-primary); } .ant-card-body { padding: var(--card-padding); } /* ===== 标签页统一样式 ===== */ .ant-tabs-nav { margin-bottom: var(--space-md); padding: 0 var(--space-xs); } .ant-tabs-tab { padding: var(--tab-btn-padding-v) var(--tab-btn-padding-h); font-weight: var(--weight-medium); color: var(--text-secondary); transition: all var(--transition-fast); } .ant-tabs-tab:hover { color: var(--text-primary); } .ant-tabs-tab-active { color: var(--text-primary) !important; font-weight: var(--weight-semibold); } .ant-tabs-ink-bar { background: var(--color-primary); height: 2px; border-radius: 1px; } /* ===== 按钮统一样式 ===== */ .ant-btn { border-radius: var(--radius-md); font-weight: var(--weight-medium); transition: all var(--transition-fast); } .ant-btn-primary { background: var(--color-primary); border-color: var(--color-primary); } .ant-btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); } .ant-btn-default { border-color: var(--border-default); color: var(--text-primary); } .ant-btn-default:hover { border-color: var(--color-primary); color: var(--color-primary); } /* ===== 输入框统一样式 ===== */ .ant-input { border-radius: var(--radius-md); transition: all var(--transition-fast); border-color: var(--border-default); font-size: var(--font-md); height: var(--input-height); } .ant-input:focus, .ant-input:hover, .ant-input-focused { border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(33, 37, 41, 0.08); } /* ===== 选择器统一样式 ===== */ .ant-select-selector { border-radius: var(--radius-md) !important; border-color: var(--border-default) !important; transition: all var(--transition-fast) !important; } .ant-select:hover .ant-select-selector { border-color: var(--border-medium) !important; } .ant-select-focused .ant-select-selector { border-color: var(--color-primary) !important; box-shadow: 0 0 0 2px rgba(33, 37, 41, 0.08) !important; } .ant-select-selection-item { color: var(--text-primary) !important; font-weight: var(--weight-medium); } .ant-select-selection-placeholder { color: var(--text-disabled) !important; } .ant-select-dropdown { border-radius: var(--radius-lg) !important; box-shadow: var(--shadow-lg) !important; border: 1px solid var(--border-light) !important; } .ant-select-item { border-radius: var(--radius-md) !important; margin: var(--space-xs) var(--space-sm) !important; padding: var(--space-sm) var(--space-md) !important; font-weight: var(--weight-medium); color: var(--text-secondary); } .ant-select-item-option-selected { background: var(--bg-active) !important; color: var(--text-primary) !important; font-weight: var(--weight-semibold); } .ant-select-item-option-active:not(.ant-select-item-option-disabled) { background: var(--bg-hover) !important; } /* ===== 表格紧凑模式 ===== */ .ant-table { border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); } .ant-table-thead > tr > th { background: var(--bg-container); color: var(--text-primary); font-weight: var(--weight-semibold); font-size: var(--font-md); padding: var(--space-sm) var(--space-md); border-bottom: 1px solid var(--border-default); } .ant-table-tbody > tr > td { font-size: var(--font-md); padding: var(--space-sm) var(--space-md); border-bottom: 1px solid var(--border-light); } .ant-table-tbody > tr:hover > td { background: var(--bg-hover); } /* ===== 模态框统一样式 ===== */ .ant-modal-content { border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); } .ant-modal-header { border-radius: var(--radius-xl) var(--radius-xl) 0 0; border-bottom: 1px solid var(--border-light); padding: var(--space-lg) var(--space-2xl); background: var(--bg-page); } .ant-modal-title { font-weight: var(--weight-semibold); font-size: var(--font-xl); color: var(--text-primary); } .ant-modal-body { padding: var(--space-2xl); } .ant-modal-footer { border-top: 1px solid var(--border-light); padding: var(--space-lg) var(--space-2xl); border-radius: 0 0 var(--radius-xl) var(--radius-xl); } /* ===== 列表项统一样式 ===== */ .ant-list-item { border-radius: var(--radius-md); margin-bottom: var(--space-md); padding: var(--space-md) var(--space-lg); transition: all var(--transition-fast); cursor: pointer; border: 1px solid transparent; } .ant-list-item:hover { background: var(--bg-hover); border-color: var(--border-light); } /* ===== 标签统一样式 ===== */ .ant-tag { border-radius: var(--radius-sm); padding: 2px var(--space-sm); font-weight: var(--weight-medium); font-size: var(--font-sm); } /* ===== 表单统一样式 ===== */ .ant-form-item-label > label { font-weight: var(--weight-medium); color: var(--text-primary); } .ant-form-item { margin-bottom: var(--form-gap); } /* ===== 进度条统一样式 ===== */ .ant-progress-bg { border-radius: var(--radius-sm); } /* ===== 徽标统一样式 ===== */ .ant-badge-status-dot { width: 8px; height: 8px; } /* ===== 滚动条统一样式 ===== */ ::-webkit-scrollbar { width: 6px; height: 6px; } ::-webkit-scrollbar-track { background: transparent; border-radius: 3px; } ::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; transition: all var(--transition-fast); } ::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); } /* ===== 标题样式 ===== */ h1, h2, h3, h4, h5, h6 { color: var(--text-primary); font-weight: var(--weight-semibold); line-height: 1.4; } h3 { font-size: var(--font-xl); margin-bottom: var(--space-md); } h4 { font-size: var(--font-lg); margin-bottom: var(--space-sm); } h5 { font-size: var(--font-md); margin-bottom: var(--space-sm); } /* ===== 全局布局约束 ===== */ html { overflow: hidden; width: 100%; height: 100%; } body { overflow-x: hidden; overflow-y: hidden; width: 100vw; max-width: 100vw; height: 100vh; } #app { width: 100vw; max-width: 100vw; height: 100vh; overflow-x: hidden; overflow-y: hidden; } .ant-layout { max-width: 100vw; width: 100vw; height: 100vh; overflow: hidden; } .ant-card, .ant-table-wrapper, .ant-list, .ant-tabs, .ant-form { max-width: 100% !important; } /* ===== 性能友好降级 ===== */ @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; } } ``` --- ### Task 4: 简化 index.css 基础样式 **Files:** - Modify: `src/index.css` - [ ] **Step 1: 简化 index.css 为纯基础重置** ```css * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } code { font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; } ``` --- ### Task 5: 重构 Home.vue 导航系统 **Files:** - Modify: `src/views/Home.vue` - [ ] **Step 1: 将下拉选择器改为顶部标签栏导航** 关键修改点: 1. Header 高度从默认改为 48px (`var(--header-height)`) 2. 移除 `` 下拉框 3. 新增顶部标签栏导航按钮组 4. 应用白色体系样式 5. 保持所有权限逻辑不变 ```vue

制度文件管理学习AI智能体

...
``` ```js // 新增计算属性 - 可见模块列表 const visibleModules = computed(() => { const moduleConfig = [ { key: 'read', label: '文件查看', icon: '📄' }, { key: 'manage', label: '文件管理', icon: '📁' }, { key: 'qa', label: '知识问答', icon: '💬' }, { key: 'exam', label: '考察训练', icon: '🔍' }, { key: 'mind', label: '纲要学习', icon: '📋' }, { key: 'dashboard', label: '综合看板', icon: '📊' }, { key: 'permission', label: '权限管理', icon: '👥' } ] return moduleConfig.filter(mod => hasPermission(mod.key)) }) ``` ```css /* 新增顶部导航样式 */ .top-nav-bar { display: flex; gap: var(--space-xs); } .nav-tab { display: inline-flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm) var(--space-md); border: none; border-radius: var(--radius-md); background: transparent; color: var(--text-secondary); font-size: var(--font-md); font-weight: var(--weight-medium); cursor: pointer; transition: all var(--transition-fast); white-space: nowrap; } .nav-tab:hover { background: var(--bg-hover); color: var(--text-primary); } .nav-tab.active { background: var(--bg-active); color: var(--text-primary); font-weight: var(--weight-semibold); } .nav-icon { font-size: 14px; } .nav-label { line-height: 1; } ``` --- ### Task 6: 重构 ReadModule.vue **Files:** - Modify: `src/components/ReadModule.vue` - [ ] **Step 1: 引入并使用 TabsBar 组件替代自定义 main-tabs-bar** - [ ] **Step 2: 移除模块内重复的渐变样式类** - [ ] **Step 3: 统一使用 CSS 变量定义的颜色值** --- ### Task 7: 重构 ExamModule.vue **Files:** - Modify: `src/components/ExamModule.vue` - [ ] **Step 1: 引入并使用 TabsBar、PageHeader、StatsRow、ContentCard 组件** - [ ] **Step 2: 替换 main-tabs-bar 为 TabsBar 组件** - [ ] **Step 3: 替换 exam-header 为 PageHeader 组件** - [ ] **Step 4: 替换 stats-row + stat-card 为 StatsRow 组件** - [ ] **Step 5: 替换 exam-card 为 ContentCard 组件** - [ ] **Step 6: 移除所有 btn-gradient-* 和 card-gradient-* 类的使用** - [ ] **Step 7: 统一表单间距为 var(--form-gap)** --- ### Task 8: 重构 ManageModule.vue **Files:** - Modify: `src/components/ManageModule.vue` - [ ] **Step 1: 引入并使用 TabsBar、PageHeader、ContentCard、DataTable 组件** - [ ] **Step 2: 替换重复的布局结构为通用组件** - [ ] **Step 3: 移除彩色渐变样式** --- ### Task 9: 重构 QAModule.vue **Files:** - Modify: `src/components/QAModule.vue` - [ ] **Step 1: 引入并使用 PageHeader、ContentCard 组件** - [ ] **Step 2: 简化页面头部和卡片容器** --- ### Task 10: 重构 MindModule.vue / DashboardModule.vue / PermissionModule.vue **Files:** - Modify: `src/components/MindModule.vue` - Modify: `src/components/DashboardModule.vue` - Modify: `src/components/PermissionModule.vue` - [ ] **Step 1: 各模块分别引入对应通用组件** - [ ] **Step 2: 替换重复布局结构** - [ ] **Step 3: DashboardModule 特别处理 StatsRow 的使用** --- ### Task 11: 最终验证 - [ ] **Step 1: 启动开发服务器检查编译是否通过** Run: `npm run dev` Expected: 无编译错误 - [ ] **Step 2: 逐个模块检查视觉一致性** 检查项: - 所有页面使用统一的白色背景 - Header 为纯白+底部边线 - 标签栏为灰色激活态 - 卡片为纯白+浅边框 - 按钮为深灰色主操作色 - 表格行高紧凑一致 - 无残留的彩色渐变元素 - [ ] **Step 3: 检查各模块功能完整性** 检查项: - 登录流程正常 - 权限控制正常 - 模块切换正常 - 数据加载正常 - 交互操作正常 --- ## 实施顺序总结 ``` Task 1: design-tokens.css + main.js引入 ← 基础设施 Task 2: 6个通用组件 ← 组件库 Task 3: style.css 重写 ← 全局样式 Task 4: index.css 简化 ← 基础样式 Task 5: Home.vue 导航重构 ← 导航系统 Task 6: ReadModule.vue ← 模块重构 Task 7: ExamModule.vue ← 模块重构 Task 8: ManageModule.vue ← 模块重构 Task 9: QAModule.vue ← 模块重构 Task 10: MindModule/Dashboard/Permission ← 模块重构 Task 11: 最终验证 ← 质量保证 ```