726 lines
23 KiB
Markdown
726 lines
23 KiB
Markdown
|
|
# Niucloud 前端迁移到 Vben Admin 规划文档
|
|||
|
|
|
|||
|
|
## 1. 项目概述
|
|||
|
|
|
|||
|
|
### 1.1 迁移目标
|
|||
|
|
将 Niucloud PHP 项目的管理后台前端功能迁移到基于 Vben Admin 框架的现代化管理面板中。
|
|||
|
|
|
|||
|
|
### 1.2 架构层级映射
|
|||
|
|
|
|||
|
|
#### Niucloud 架构层级
|
|||
|
|
- **app**: 核心业务功能模块(用户、权限、菜单、系统设置等)
|
|||
|
|
- **addons**: 插件扩展模块(可选功能模块)
|
|||
|
|
- **app (业务)**: 具体业务应用模块
|
|||
|
|
|
|||
|
|
#### WWJCloud 架构层级
|
|||
|
|
- **common**: 框架通用服务层(对应 Niucloud 的 app)
|
|||
|
|
- **addon**: 插件扩展层(对应 Niucloud 的 addons)
|
|||
|
|
- **app**: 业务开发层(对应 Niucloud 的业务 app)
|
|||
|
|
|
|||
|
|
#### 层级映射关系
|
|||
|
|
```
|
|||
|
|
Niucloud → WWJCloud
|
|||
|
|
├── app/ ├── common/ (核心功能:用户、权限、设置等)
|
|||
|
|
├── addons/ ├── addon/ (插件扩展:可选功能模块)
|
|||
|
|
└── app(业务)/ └── app/ (具体业务:电商、CRM、ERP等)
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 1.3 技术栈对比
|
|||
|
|
|
|||
|
|
| 项目 | Niucloud Admin | Vben Admin (目标) |
|
|||
|
|
|------|----------------|-------------------|
|
|||
|
|
| 框架 | Vue 3 + TypeScript | Vue 3 + TypeScript |
|
|||
|
|
| UI库 | Element Plus | Element Plus |
|
|||
|
|
| 构建工具 | Vite | Vite |
|
|||
|
|
| 状态管理 | Pinia | Pinia |
|
|||
|
|
| 路由 | Vue Router | Vue Router |
|
|||
|
|
| 样式 | SCSS + Tailwind | SCSS + Tailwind |
|
|||
|
|
|
|||
|
|
## 2. 目录结构对比分析
|
|||
|
|
|
|||
|
|
### 2.1 Niucloud Admin 结构
|
|||
|
|
```
|
|||
|
|
src/
|
|||
|
|
├── app/ # 应用层
|
|||
|
|
│ ├── api/ # API 接口定义
|
|||
|
|
│ ├── assets/ # 静态资源
|
|||
|
|
│ ├── components/ # 业务组件
|
|||
|
|
│ ├── lang/ # 国际化
|
|||
|
|
│ └── views/ # 页面视图
|
|||
|
|
│ ├── app/ # 应用管理
|
|||
|
|
│ ├── auth/ # 权限管理
|
|||
|
|
│ ├── channel/ # 渠道管理
|
|||
|
|
│ ├── dict/ # 字典管理
|
|||
|
|
│ ├── diy/ # 自定义页面
|
|||
|
|
│ ├── finance/ # 财务管理
|
|||
|
|
│ ├── home/ # 首页
|
|||
|
|
│ ├── marketing/ # 营销管理
|
|||
|
|
│ ├── member/ # 会员管理
|
|||
|
|
│ ├── setting/ # 系统设置
|
|||
|
|
│ └── tools/ # 工具管理
|
|||
|
|
├── components/ # 通用组件
|
|||
|
|
├── layout/ # 布局组件
|
|||
|
|
├── router/ # 路由配置
|
|||
|
|
├── stores/ # 状态管理
|
|||
|
|
├── styles/ # 样式文件
|
|||
|
|
├── types/ # 类型定义
|
|||
|
|
└── utils/ # 工具函数
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 2.2 Vben Admin 结构
|
|||
|
|
```
|
|||
|
|
src/
|
|||
|
|
├── adapter/ # 适配器层
|
|||
|
|
├── api/ # API 接口
|
|||
|
|
├── layouts/ # 布局组件
|
|||
|
|
├── locales/ # 国际化
|
|||
|
|
├── router/ # 路由配置
|
|||
|
|
│ └── routes/ # 路由模块
|
|||
|
|
│ └── modules/ # 路由模块文件
|
|||
|
|
├── store/ # 状态管理
|
|||
|
|
└── views/ # 页面视图
|
|||
|
|
├── _core/ # 核心页面
|
|||
|
|
├── dashboard/ # 仪表板
|
|||
|
|
└── demos/ # 示例页面
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 3. 功能模块映射方案
|
|||
|
|
|
|||
|
|
### 3.1 功能模块映射(全部迁移到 Common 层)
|
|||
|
|
|
|||
|
|
根据项目实际情况,所有 Niucloud 功能模块都将迁移到 WWJCloud 的 Common 层,作为框架底层通用功能。
|
|||
|
|
|
|||
|
|
#### 3.1.1 核心管理功能(高优先级)
|
|||
|
|
|
|||
|
|
| Niucloud 模块 | WWJCloud Common 位置 | 迁移优先级 | 功能说明 |
|
|||
|
|
|---------------|---------------------|------------|----------|
|
|||
|
|
| 用户管理 (user) | `common/user` | 高 | 用户账户管理 |
|
|||
|
|
| 角色权限 (auth) | `common/rbac` | 高 | RBAC 权限控制 |
|
|||
|
|
| 菜单管理 (menu) | `common/rbac/menu` | 高 | 动态菜单管理 |
|
|||
|
|
| 系统设置 (setting) | `common/settings` | 高 | 系统配置管理 |
|
|||
|
|
| 字典管理 (dict) | `common/dict` | 高 | 数据字典管理 |
|
|||
|
|
| 文件管理 (file) | `common/file` | 高 | 文件上传管理 |
|
|||
|
|
| 站点管理 (site) | `common/settings/site` | 高 | 站点基础配置 |
|
|||
|
|
|
|||
|
|
#### 3.1.2 业务管理功能(中优先级)
|
|||
|
|
|
|||
|
|
| Niucloud 模块 | WWJCloud Common 位置 | 迁移优先级 | 功能说明 |
|
|||
|
|
|---------------|---------------------|------------|----------|
|
|||
|
|
| 会员管理 (member) | `common/member` | 中 | 会员系统管理 |
|
|||
|
|
| 营销工具 (marketing) | `common/marketing` | 中 | 营销活动管理 |
|
|||
|
|
| 财务管理 (finance) | `common/finance` | 中 | 财务数据管理 |
|
|||
|
|
| 渠道管理 (channel) | `common/channel` | 中 | 销售渠道管理 |
|
|||
|
|
| 应用管理 (app) | `common/app` | 中 | 应用配置管理 |
|
|||
|
|
| 首页管理 (home) | `common/dashboard` | 中 | 仪表板管理 |
|
|||
|
|
|
|||
|
|
#### 3.1.3 扩展功能模块(低优先级)
|
|||
|
|
|
|||
|
|
| Niucloud 模块 | WWJCloud Common 位置 | 迁移优先级 | 功能说明 |
|
|||
|
|
|---------------|---------------------|------------|----------|
|
|||
|
|
| 海报管理 (poster) | `common/poster` | 低 | 海报设计工具 |
|
|||
|
|
| 打印管理 (printer) | `common/printer` | 低 | 打印模板管理 |
|
|||
|
|
| 微信平台 (wxoplatform) | `common/wechat` | 低 | 微信生态集成 |
|
|||
|
|
| 工具集 (tools) | `common/tools` | 低 | 辅助工具集合 |
|
|||
|
|
| DIY 页面 (diy) | `common/diy` | 低 | 自定义页面构建 |
|
|||
|
|
| DIY 表单 (diy_form) | `common/diy-form` | 低 | 自定义表单构建 |
|
|||
|
|
|
|||
|
|
### 3.2 详细页面映射(全部映射到 Common 层)
|
|||
|
|
|
|||
|
|
#### 3.2.1 权限管理模块 (auth/)
|
|||
|
|
```
|
|||
|
|
Niucloud: app/views/auth/
|
|||
|
|
├── user.vue → views/common/auth/user/index.vue
|
|||
|
|
├── role.vue → views/common/auth/role/index.vue
|
|||
|
|
├── menu.vue → views/common/auth/menu/index.vue
|
|||
|
|
├── site_menu.vue → views/common/auth/site-menu/index.vue
|
|||
|
|
└── log.vue → views/common/auth/log/index.vue
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 3.2.2 系统设置模块 (setting/)
|
|||
|
|
```
|
|||
|
|
Niucloud: app/views/setting/
|
|||
|
|
├── system.vue → views/common/setting/basic/index.vue
|
|||
|
|
├── adminlogin.vue → views/common/setting/login/index.vue
|
|||
|
|
├── sms.vue → views/common/setting/sms/index.vue
|
|||
|
|
├── pay.vue → views/common/setting/payment/index.vue
|
|||
|
|
├── storage.vue → views/common/setting/storage/index.vue
|
|||
|
|
├── notice.vue → views/common/setting/notification/index.vue
|
|||
|
|
├── map.vue → views/common/setting/map/index.vue
|
|||
|
|
└── member.vue → views/common/setting/member/index.vue
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 3.2.3 会员管理模块 (member/)
|
|||
|
|
```
|
|||
|
|
Niucloud: app/views/member/
|
|||
|
|
├── member.vue → views/common/member/list/index.vue
|
|||
|
|
├── member_detail.vue → views/common/member/detail/index.vue
|
|||
|
|
├── level.vue → views/common/member/level/index.vue
|
|||
|
|
├── label.vue → views/common/member/label/index.vue
|
|||
|
|
├── balance.vue → views/common/member/balance/index.vue
|
|||
|
|
├── point.vue → views/common/member/point/index.vue
|
|||
|
|
└── commission.vue → views/common/member/commission/index.vue
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 3.2.4 应用管理模块 (app/)
|
|||
|
|
```
|
|||
|
|
Niucloud: app/views/app/
|
|||
|
|
├── app.vue → views/common/app/list/index.vue
|
|||
|
|
├── app_detail.vue → views/common/app/detail/index.vue
|
|||
|
|
└── config.vue → views/common/app/config/index.vue
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 3.2.5 营销管理模块 (marketing/)
|
|||
|
|
```
|
|||
|
|
Niucloud: app/views/marketing/
|
|||
|
|
├── activity.vue → views/common/marketing/activity/index.vue
|
|||
|
|
├── coupon.vue → views/common/marketing/coupon/index.vue
|
|||
|
|
└── promotion.vue → views/common/marketing/promotion/index.vue
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 3.2.6 财务管理模块 (finance/)
|
|||
|
|
```
|
|||
|
|
Niucloud: app/views/finance/
|
|||
|
|
├── account.vue → views/common/finance/account/index.vue
|
|||
|
|
├── transaction.vue → views/common/finance/transaction/index.vue
|
|||
|
|
└── report.vue → views/common/finance/report/index.vue
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 3.2.7 渠道管理模块 (channel/)
|
|||
|
|
```
|
|||
|
|
Niucloud: app/views/channel/
|
|||
|
|
├── channel.vue → views/common/channel/list/index.vue
|
|||
|
|
├── config.vue → views/common/channel/config/index.vue
|
|||
|
|
└── statistics.vue → views/common/channel/statistics/index.vue
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 3.2.8 字典管理模块 (dict/)
|
|||
|
|
```
|
|||
|
|
Niucloud: app/views/dict/
|
|||
|
|
├── dict.vue → views/common/dict/list/index.vue
|
|||
|
|
├── dict_data.vue → views/common/dict/data/index.vue
|
|||
|
|
└── dict_type.vue → views/common/dict/type/index.vue
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 3.2.9 文件管理模块 (file/)
|
|||
|
|
```
|
|||
|
|
Niucloud: app/views/file/
|
|||
|
|
├── file.vue → views/common/file/list/index.vue
|
|||
|
|
├── upload.vue → views/common/file/upload/index.vue
|
|||
|
|
└── config.vue → views/common/file/config/index.vue
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 3.2.10 扩展功能模块
|
|||
|
|
```
|
|||
|
|
Niucloud: app/views/poster/
|
|||
|
|
├── poster.vue → views/common/poster/list/index.vue
|
|||
|
|
└── template.vue → views/common/poster/template/index.vue
|
|||
|
|
|
|||
|
|
Niucloud: app/views/printer/
|
|||
|
|
├── printer.vue → views/common/printer/list/index.vue
|
|||
|
|
└── template.vue → views/common/printer/template/index.vue
|
|||
|
|
|
|||
|
|
Niucloud: app/views/wxoplatform/
|
|||
|
|
├── config.vue → views/common/wechat/config/index.vue
|
|||
|
|
└── menu.vue → views/common/wechat/menu/index.vue
|
|||
|
|
|
|||
|
|
Niucloud: app/views/tools/
|
|||
|
|
├── generator.vue → views/common/tools/generator/index.vue
|
|||
|
|
└── backup.vue → views/common/tools/backup/index.vue
|
|||
|
|
|
|||
|
|
Niucloud: app/views/diy/
|
|||
|
|
├── page.vue → views/common/diy/page/index.vue
|
|||
|
|
└── component.vue → views/common/diy/component/index.vue
|
|||
|
|
|
|||
|
|
Niucloud: app/views/diy_form/
|
|||
|
|
├── form.vue → views/common/diy-form/list/index.vue
|
|||
|
|
└── builder.vue → views/common/diy-form/builder/index.vue
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 4. 组件迁移策略
|
|||
|
|
|
|||
|
|
### 4.1 通用组件映射
|
|||
|
|
|
|||
|
|
| Niucloud 组件 | 功能 | Vben 替代方案 |
|
|||
|
|
|---------------|------|---------------|
|
|||
|
|
| upload-image | 图片上传 | VbenUpload + 自定义适配 |
|
|||
|
|
| upload-file | 文件上传 | VbenUpload + 自定义适配 |
|
|||
|
|
| upload-video | 视频上传 | VbenUpload + 自定义适配 |
|
|||
|
|
| editor | 富文本编辑器 | VbenEditor 或 第三方编辑器 |
|
|||
|
|
| select-icon | 图标选择器 | VbenIconPicker |
|
|||
|
|
| select-area | 地区选择器 | VbenAreaPicker 或 自定义 |
|
|||
|
|
| heat-map | 热力图 | 自定义组件 + ECharts |
|
|||
|
|
| video-player | 视频播放器 | 第三方播放器组件 |
|
|||
|
|
|
|||
|
|
### 4.2 布局组件迁移
|
|||
|
|
|
|||
|
|
Niucloud 有多套布局主题:
|
|||
|
|
- admin (默认)
|
|||
|
|
- admin_simplicity (简洁)
|
|||
|
|
- bussiness (商务)
|
|||
|
|
- darkside (暗色)
|
|||
|
|
- profession (专业)
|
|||
|
|
|
|||
|
|
**迁移策略**: 统一使用 Vben Admin 的主题系统,通过配置实现多主题切换。
|
|||
|
|
|
|||
|
|
## 5. 路由配置迁移
|
|||
|
|
|
|||
|
|
### 5.1 路由结构对比
|
|||
|
|
|
|||
|
|
**Niucloud 路由特点**:
|
|||
|
|
- 基于文件系统的路由
|
|||
|
|
- 支持动态路由加载
|
|||
|
|
- 权限路由集成
|
|||
|
|
|
|||
|
|
**Vben Admin 路由特点**:
|
|||
|
|
- 模块化路由配置
|
|||
|
|
- 支持路由懒加载
|
|||
|
|
- 内置权限控制
|
|||
|
|
|
|||
|
|
### 5.2 路由迁移示例
|
|||
|
|
|
|||
|
|
```typescript
|
|||
|
|
// src/router/routes/modules/common.ts
|
|||
|
|
import type { RouteRecordRaw } from 'vue-router';
|
|||
|
|
|
|||
|
|
const routes: RouteRecordRaw[] = [
|
|||
|
|
{
|
|||
|
|
path: '/common',
|
|||
|
|
name: 'Common',
|
|||
|
|
component: () => import('@/layouts/basic.vue'),
|
|||
|
|
meta: {
|
|||
|
|
title: '框架管理',
|
|||
|
|
icon: 'common',
|
|||
|
|
orderNo: 1000,
|
|||
|
|
},
|
|||
|
|
children: [
|
|||
|
|
{
|
|||
|
|
path: 'system',
|
|||
|
|
name: 'CommonSystem',
|
|||
|
|
meta: { title: '系统管理' },
|
|||
|
|
children: [
|
|||
|
|
{
|
|||
|
|
path: 'auth',
|
|||
|
|
name: 'CommonSystemAuth',
|
|||
|
|
meta: { title: '权限管理' },
|
|||
|
|
children: [
|
|||
|
|
{
|
|||
|
|
path: 'user',
|
|||
|
|
name: 'CommonSystemAuthUser',
|
|||
|
|
component: () => import('@/views/common/auth/user/index.vue'),
|
|||
|
|
meta: { title: '用户管理' },
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
path: 'role',
|
|||
|
|
name: 'CommonSystemAuthRole',
|
|||
|
|
component: () => import('@/views/common/auth/role/index.vue'),
|
|||
|
|
meta: { title: '角色管理' },
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
path: 'menu',
|
|||
|
|
name: 'CommonSystemAuthMenu',
|
|||
|
|
component: () => import('@/views/common/auth/menu/index.vue'),
|
|||
|
|
meta: { title: '菜单管理' },
|
|||
|
|
},
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
path: 'setting',
|
|||
|
|
name: 'CommonSystemSetting',
|
|||
|
|
meta: { title: '系统设置' },
|
|||
|
|
children: [
|
|||
|
|
{
|
|||
|
|
path: 'basic',
|
|||
|
|
name: 'CommonSystemSettingBasic',
|
|||
|
|
component: () => import('@/views/common/setting/basic/index.vue'),
|
|||
|
|
meta: { title: '基础设置' },
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
path: 'sms',
|
|||
|
|
name: 'CommonSystemSettingSms',
|
|||
|
|
component: () => import('@/views/common/setting/sms/index.vue'),
|
|||
|
|
meta: { title: '短信设置' },
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
path: 'payment',
|
|||
|
|
name: 'CommonSystemSettingPayment',
|
|||
|
|
component: () => import('@/views/common/setting/payment/index.vue'),
|
|||
|
|
meta: { title: '支付设置' },
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
path: 'storage',
|
|||
|
|
name: 'CommonSystemSettingStorage',
|
|||
|
|
component: () => import('@/views/common/setting/storage/index.vue'),
|
|||
|
|
meta: { title: '存储设置' },
|
|||
|
|
},
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
path: 'member',
|
|||
|
|
name: 'CommonSystemMember',
|
|||
|
|
meta: { title: '会员管理' },
|
|||
|
|
children: [
|
|||
|
|
{
|
|||
|
|
path: 'list',
|
|||
|
|
name: 'CommonSystemMemberList',
|
|||
|
|
component: () => import('@/views/common/member/list/index.vue'),
|
|||
|
|
meta: { title: '会员列表' },
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
path: 'level',
|
|||
|
|
name: 'CommonSystemMemberLevel',
|
|||
|
|
component: () => import('@/views/common/member/level/index.vue'),
|
|||
|
|
meta: { title: '会员等级' },
|
|||
|
|
},
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
path: 'file',
|
|||
|
|
name: 'CommonFile',
|
|||
|
|
meta: { title: '文件管理' },
|
|||
|
|
children: [
|
|||
|
|
{
|
|||
|
|
path: 'list',
|
|||
|
|
name: 'CommonFileList',
|
|||
|
|
component: () => import('@/views/common/file/list/index.vue'),
|
|||
|
|
meta: { title: '文件列表' },
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
path: 'upload',
|
|||
|
|
name: 'CommonFileUpload',
|
|||
|
|
component: () => import('@/views/common/file/upload/index.vue'),
|
|||
|
|
meta: { title: '文件上传' },
|
|||
|
|
},
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
],
|
|||
|
|
},
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
export default routes;
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 6. API 接口迁移
|
|||
|
|
|
|||
|
|
### 6.1 API 结构对比
|
|||
|
|
|
|||
|
|
**Niucloud API 特点**:
|
|||
|
|
- RESTful 风格
|
|||
|
|
- 统一响应格式
|
|||
|
|
- 内置权限验证
|
|||
|
|
|
|||
|
|
**目标 API 结构**:
|
|||
|
|
- 对接后端 NestJS API
|
|||
|
|
- 保持 RESTful 风格
|
|||
|
|
- JWT 认证
|
|||
|
|
|
|||
|
|
### 6.2 API 迁移示例
|
|||
|
|
|
|||
|
|
```typescript
|
|||
|
|
// src/api/auth.ts
|
|||
|
|
import { request } from '@/api/request';
|
|||
|
|
|
|||
|
|
export interface UserListParams {
|
|||
|
|
page?: number;
|
|||
|
|
limit?: number;
|
|||
|
|
keyword?: string;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export interface UserInfo {
|
|||
|
|
id: number;
|
|||
|
|
username: string;
|
|||
|
|
nickname: string;
|
|||
|
|
email: string;
|
|||
|
|
status: number;
|
|||
|
|
created_at: string;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 获取用户列表
|
|||
|
|
export function getUserList(params: UserListParams) {
|
|||
|
|
return request<{
|
|||
|
|
list: UserInfo[];
|
|||
|
|
total: number;
|
|||
|
|
}>('/api/users', {
|
|||
|
|
method: 'GET',
|
|||
|
|
params,
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 创建用户
|
|||
|
|
export function createUser(data: Partial<UserInfo>) {
|
|||
|
|
return request('/api/users', {
|
|||
|
|
method: 'POST',
|
|||
|
|
data,
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 更新用户
|
|||
|
|
export function updateUser(id: number, data: Partial<UserInfo>) {
|
|||
|
|
return request(`/api/users/${id}`, {
|
|||
|
|
method: 'PUT',
|
|||
|
|
data,
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 删除用户
|
|||
|
|
export function deleteUser(id: number) {
|
|||
|
|
return request(`/api/users/${id}`, {
|
|||
|
|
method: 'DELETE',
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 7. 状态管理迁移
|
|||
|
|
|
|||
|
|
### 7.1 Store 结构对比
|
|||
|
|
|
|||
|
|
**Niucloud Stores**:
|
|||
|
|
- app.ts (应用状态)
|
|||
|
|
- user.ts (用户状态)
|
|||
|
|
- system.ts (系统状态)
|
|||
|
|
- style.ts (样式状态)
|
|||
|
|
- tabbar.ts (标签栏状态)
|
|||
|
|
|
|||
|
|
**Vben Admin Stores**:
|
|||
|
|
- auth.ts (认证状态)
|
|||
|
|
- 其他业务状态按需添加
|
|||
|
|
|
|||
|
|
### 7.2 状态迁移示例
|
|||
|
|
|
|||
|
|
```typescript
|
|||
|
|
// src/store/modules/system.ts
|
|||
|
|
import { defineStore } from 'pinia';
|
|||
|
|
|
|||
|
|
export interface SystemState {
|
|||
|
|
settings: {
|
|||
|
|
siteName: string;
|
|||
|
|
logo: string;
|
|||
|
|
copyright: string;
|
|||
|
|
};
|
|||
|
|
dictData: Record<string, any[]>;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export const useSystemStore = defineStore('system', {
|
|||
|
|
state: (): SystemState => ({
|
|||
|
|
settings: {
|
|||
|
|
siteName: '',
|
|||
|
|
logo: '',
|
|||
|
|
copyright: '',
|
|||
|
|
},
|
|||
|
|
dictData: {},
|
|||
|
|
}),
|
|||
|
|
|
|||
|
|
getters: {
|
|||
|
|
getSiteName: (state) => state.settings.siteName,
|
|||
|
|
getDictByType: (state) => (type: string) => state.dictData[type] || [],
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
actions: {
|
|||
|
|
async fetchSettings() {
|
|||
|
|
// 获取系统设置
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
async fetchDictData() {
|
|||
|
|
// 获取字典数据
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 8. 样式迁移策略
|
|||
|
|
|
|||
|
|
### 8.1 样式文件迁移
|
|||
|
|
|
|||
|
|
**保留的样式**:
|
|||
|
|
- 业务相关的自定义样式
|
|||
|
|
- 品牌色彩定义
|
|||
|
|
- 特殊组件样式
|
|||
|
|
|
|||
|
|
**替换的样式**:
|
|||
|
|
- 基础布局样式 (使用 Vben 内置)
|
|||
|
|
- 通用组件样式 (使用 Element Plus)
|
|||
|
|
- 响应式断点 (使用 Vben 配置)
|
|||
|
|
|
|||
|
|
### 8.2 主题配置
|
|||
|
|
|
|||
|
|
```typescript
|
|||
|
|
// src/preferences.ts
|
|||
|
|
export const preferences = {
|
|||
|
|
theme: {
|
|||
|
|
colorPrimary: '#1890ff', // 主色调
|
|||
|
|
mode: 'light', // 主题模式
|
|||
|
|
},
|
|||
|
|
layout: {
|
|||
|
|
sidebar: {
|
|||
|
|
collapsed: false,
|
|||
|
|
width: 240,
|
|||
|
|
},
|
|||
|
|
header: {
|
|||
|
|
height: 64,
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
};
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 9. 迁移实施计划
|
|||
|
|
|
|||
|
|
### 9.1 阶段一:目录结构搭建(1周)
|
|||
|
|
|
|||
|
|
#### 所有功能模块统一在 Common 层目录创建
|
|||
|
|
```
|
|||
|
|
src/views/
|
|||
|
|
├── common/ # 框架通用功能层(所有 Niucloud 功能迁移到此层)
|
|||
|
|
│ └── # 系统管理模块
|
|||
|
|
│ ├── auth/ # 权限管理
|
|||
|
|
│ │ ├── user/ # 用户管理
|
|||
|
|
│ │ ├── role/ # 角色管理
|
|||
|
|
│ │ ├── menu/ # 菜单管理
|
|||
|
|
│ │ ├── site-menu/ # 站点菜单管理
|
|||
|
|
│ │ └── log/ # 操作日志
|
|||
|
|
│ ├── setting/ # 系统设置
|
|||
|
|
│ │ ├── basic/ # 基础设置
|
|||
|
|
│ │ ├── login/ # 登录设置
|
|||
|
|
│ │ ├── sms/ # 短信设置
|
|||
|
|
│ │ ├── payment/ # 支付设置
|
|||
|
|
│ │ ├── storage/ # 存储设置
|
|||
|
|
│ │ ├── notification/ # 通知设置
|
|||
|
|
│ │ ├── map/ # 地图设置
|
|||
|
|
│ │ └── member/ # 会员设置
|
|||
|
|
│ ├── member/ # 会员管理
|
|||
|
|
│ │ ├── list/ # 会员列表
|
|||
|
|
│ │ ├── detail/ # 会员详情
|
|||
|
|
│ │ ├── level/ # 会员等级
|
|||
|
|
│ │ ├── label/ # 会员标签
|
|||
|
|
│ │ ├── balance/ # 余额管理
|
|||
|
|
│ │ ├── point/ # 积分管理
|
|||
|
|
│ │ └── commission/ # 佣金管理
|
|||
|
|
│ ├── marketing/ # 营销管理
|
|||
|
|
│ │ ├── activity/ # 营销活动
|
|||
|
|
│ │ ├── coupon/ # 优惠券
|
|||
|
|
│ │ └── promotion/ # 促销活动
|
|||
|
|
│ ├── finance/ # 财务管理
|
|||
|
|
│ │ ├── account/ # 账户管理
|
|||
|
|
│ │ ├── transaction/ # 交易记录
|
|||
|
|
│ │ └── report/ # 财务报表
|
|||
|
|
│ ├── channel/ # 渠道管理
|
|||
|
|
│ │ ├── list/ # 渠道列表
|
|||
|
|
│ │ ├── config/ # 渠道配置
|
|||
|
|
│ │ └── statistics/ # 渠道统计
|
|||
|
|
│ ├── app/ # 应用管理
|
|||
|
|
│ │ ├── list/ # 应用列表
|
|||
|
|
│ │ ├── detail/ # 应用详情
|
|||
|
|
│ │ └── config/ # 应用配置
|
|||
|
|
│ ├── dict/ # 字典管理
|
|||
|
|
│ │ ├── list/ # 字典列表
|
|||
|
|
│ │ ├── data/ # 字典数据
|
|||
|
|
│ │ └── type/ # 字典类型
|
|||
|
|
│ ├── file/ # 文件管理
|
|||
|
|
│ │ ├── list/ # 文件列表
|
|||
|
|
│ │ ├── upload/ # 文件上传
|
|||
|
|
│ │ └── config/ # 文件配置
|
|||
|
|
│ ├── poster/ # 海报管理
|
|||
|
|
│ │ ├── list/ # 海报列表
|
|||
|
|
│ │ └── template/ # 海报模板
|
|||
|
|
│ ├── printer/ # 打印管理
|
|||
|
|
│ │ ├── list/ # 打印机列表
|
|||
|
|
│ │ └── template/ # 打印模板
|
|||
|
|
│ ├── wechat/ # 微信平台
|
|||
|
|
│ │ ├── config/ # 微信配置
|
|||
|
|
│ │ └── menu/ # 微信菜单
|
|||
|
|
│ ├── tools/ # 工具集
|
|||
|
|
│ │ ├── generator/ # 代码生成
|
|||
|
|
│ │ └── backup/ # 数据备份
|
|||
|
|
│ ├── diy/ # DIY 页面
|
|||
|
|
│ │ ├── page/ # 页面管理
|
|||
|
|
│ │ └── component/ # 组件管理
|
|||
|
|
│ └── diy-form/ # DIY 表单
|
|||
|
|
│ ├── list/ # 表单列表
|
|||
|
|
│ └── builder/ # 表单构建器
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 9.2 阶段二:Common 层核心功能迁移(2-3周)
|
|||
|
|
- [ ] 用户管理系统 (`user`)
|
|||
|
|
- [ ] 角色权限管理 (`rbac`)
|
|||
|
|
- [ ] 菜单管理系统 (`rbac/menu`)
|
|||
|
|
- [ ] 系统设置模块 (`settings`)
|
|||
|
|
- [ ] 数据字典管理 (`dict`)
|
|||
|
|
- [ ] 文件管理系统 (`file`)
|
|||
|
|
|
|||
|
|
### 9.3 阶段三:App 层业务功能迁移(3-4周)
|
|||
|
|
- [ ] 会员管理系统 (`crm/member`)
|
|||
|
|
- [ ] 营销工具模块 (`marketing`)
|
|||
|
|
- [ ] 财务管理模块 (`erp/finance`)
|
|||
|
|
- [ ] 渠道管理系统 (`channel`)
|
|||
|
|
|
|||
|
|
### 9.4 阶段四:Addon 层扩展功能迁移(2-3周)
|
|||
|
|
- [ ] 海报管理工具 (`addons/poster`)
|
|||
|
|
- [ ] 打印模板管理 (`addons/printer`)
|
|||
|
|
- [ ] 微信平台集成 (`addons/wechat`)
|
|||
|
|
- [ ] 辅助工具集合 (`addons/tools`)
|
|||
|
|
|
|||
|
|
### 9.5 阶段五:优化和测试(2周)
|
|||
|
|
- [ ] 性能优化和代码重构
|
|||
|
|
- [ ] 跨浏览器兼容性测试
|
|||
|
|
- [ ] 用户体验优化
|
|||
|
|
- [ ] 技术文档完善
|
|||
|
|
|
|||
|
|
### 9.2 开发规范
|
|||
|
|
|
|||
|
|
1. **组件开发**:
|
|||
|
|
- 优先使用 Vben 封装组件
|
|||
|
|
- 其次使用 Element Plus 原生组件
|
|||
|
|
- 必要时开发自定义组件
|
|||
|
|
|
|||
|
|
2. **代码规范**:
|
|||
|
|
- 遵循 Vben Admin 代码规范
|
|||
|
|
- 使用 TypeScript 严格模式
|
|||
|
|
- 统一的 ESLint 和 Prettier 配置
|
|||
|
|
|
|||
|
|
3. **测试策略**:
|
|||
|
|
- 单元测试覆盖核心业务逻辑
|
|||
|
|
- E2E 测试覆盖关键用户流程
|
|||
|
|
- 兼容性测试确保多浏览器支持
|
|||
|
|
|
|||
|
|
## 10. 风险评估与应对
|
|||
|
|
|
|||
|
|
### 10.1 技术风险
|
|||
|
|
|
|||
|
|
| 风险项 | 影响程度 | 应对策略 |
|
|||
|
|
|--------|----------|----------|
|
|||
|
|
| 组件兼容性 | 中 | 提前验证,准备降级方案 |
|
|||
|
|
| 性能问题 | 中 | 代码分割,懒加载优化 |
|
|||
|
|
| 数据迁移 | 高 | 制定详细的数据映射方案 |
|
|||
|
|
| 用户体验差异 | 中 | 保持核心交互逻辑一致 |
|
|||
|
|
|
|||
|
|
### 10.2 进度风险
|
|||
|
|
|
|||
|
|
- **人力资源**: 确保有经验的前端开发人员参与
|
|||
|
|
- **时间安排**: 预留充足的测试和调试时间
|
|||
|
|
- **需求变更**: 建立变更控制流程
|
|||
|
|
|
|||
|
|
## 11. 验收标准
|
|||
|
|
|
|||
|
|
### 11.1 功能验收
|
|||
|
|
- [ ] 所有原有功能正常运行
|
|||
|
|
- [ ] 用户权限控制正确
|
|||
|
|
- [ ] 数据操作无误
|
|||
|
|
- [ ] 响应式布局适配
|
|||
|
|
|
|||
|
|
### 11.2 性能验收
|
|||
|
|
- [ ] 首屏加载时间 < 3s
|
|||
|
|
- [ ] 页面切换流畅
|
|||
|
|
- [ ] 大数据量列表渲染正常
|
|||
|
|
|
|||
|
|
### 11.3 兼容性验收
|
|||
|
|
- [ ] Chrome/Firefox/Safari 最新版本
|
|||
|
|
- [ ] 移动端适配
|
|||
|
|
- [ ] 不同分辨率屏幕适配
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
**文档版本**: v1.0
|
|||
|
|
**创建时间**: 2025-01-22
|
|||
|
|
**更新时间**: 2025-01-22
|
|||
|
|
**负责人**: 开发团队
|
|||
|
|
**审核人**: 项目经理
|