|
|
@@ -3,97 +3,137 @@
|
|
|
## 版本信息
|
|
|
| 版本 | 日期 | 描述 | 作者 |
|
|
|
|------|------|------|------|
|
|
|
-| 2.4 | 2025-09-20 | 与主架构文档版本一致 | Winston |
|
|
|
+| 2.5 | 2025-10-21 | 更新为实际项目结构 | Winston |
|
|
|
|
|
|
## 实际项目结构
|
|
|
```text
|
|
|
-d8d-starter/
|
|
|
-├── src/
|
|
|
-│ ├── client/ # React前端应用
|
|
|
-│ │ ├── admin/ # 管理后台应用
|
|
|
-│ │ │ ├── components/ # 管理后台专用组件
|
|
|
-│ │ │ │ ├── ProtectedRoute.tsx # 路由保护组件
|
|
|
-│ │ │ │ ├── ErrorPage.tsx # 错误页面
|
|
|
-│ │ │ │ └── NotFoundPage.tsx # 404页面
|
|
|
-│ │ │ ├── hooks/ # 管理后台Hooks
|
|
|
-│ │ │ │ └── AuthProvider.tsx # 认证状态管理
|
|
|
-│ │ │ ├── layouts/ # 布局组件
|
|
|
-│ │ │ │ └── MainLayout.tsx # 主布局
|
|
|
-│ │ │ ├── pages/ # 页面组件
|
|
|
-│ │ │ │ ├── Dashboard.tsx # 仪表板
|
|
|
-│ │ │ │ ├── Login.tsx # 登录页面
|
|
|
-│ │ │ │ └── Users.tsx # 用户管理
|
|
|
-│ │ │ ├── routes.tsx # 路由配置
|
|
|
-│ │ │ └── index.tsx # 管理后台入口
|
|
|
-│ │ ├── home/ # 用户前台应用
|
|
|
-│ │ ├── components/ # 共享UI组件
|
|
|
-│ │ │ └── ui/ # shadcn/ui组件库(50+组件)
|
|
|
-│ │ │ ├── button.tsx # 按钮组件
|
|
|
-│ │ │ ├── input.tsx # 输入框组件
|
|
|
-│ │ │ ├── table.tsx # 表格组件
|
|
|
-│ │ │ └── ... # 其他组件
|
|
|
-│ │ ├── hooks/ # 共享Hooks
|
|
|
-│ │ ├── lib/ # 工具库
|
|
|
-│ │ ├── utils/ # 工具函数
|
|
|
-│ │ ├── api.ts # API客户端配置
|
|
|
-│ │ └── index.tsx # 前端入口
|
|
|
-│ ├── server/ # Hono后端应用
|
|
|
-│ │ ├── api/ # API路由
|
|
|
-│ │ │ ├── auth/ # 认证相关路由
|
|
|
-│ │ │ │ ├── login.ts # 登录路由
|
|
|
-│ │ │ │ ├── logout.ts # 登出路由
|
|
|
-│ │ │ │ └── register.ts # 注册路由
|
|
|
-│ │ │ ├── users/ # 用户管理路由
|
|
|
-│ │ │ │ ├── index.ts # 用户列表路由
|
|
|
-│ │ │ │ ├── [id].ts # 用户详情路由
|
|
|
-│ │ │ │ └── __tests__/ # 路由测试
|
|
|
-│ │ │ ├── roles/ # 角色管理路由
|
|
|
-│ │ │ ├── files/ # 文件管理路由
|
|
|
-│ │ │ │ ├── multipart-policy/ # 多部分上传策略
|
|
|
-│ │ │ │ ├── multipart-complete/ # 完成多部分上传
|
|
|
-│ │ │ │ ├── [id]/ # 文件操作路由
|
|
|
-│ │ │ │ └── upload-policy/ # 上传策略路由
|
|
|
-│ │ │ └── __integration_tests__/ # 集成测试
|
|
|
-│ │ ├── modules/ # 业务模块
|
|
|
-│ │ │ ├── auth/ # 认证业务模块
|
|
|
-│ │ │ │ ├── auth.service.ts # 认证服务
|
|
|
-│ │ │ │ └── __tests__/ # 认证测试
|
|
|
-│ │ │ ├── users/ # 用户业务模块
|
|
|
-│ │ │ │ ├── user.entity.ts # 用户实体
|
|
|
-│ │ │ │ ├── user.service.ts # 用户服务
|
|
|
-│ │ │ │ └── __tests__/ # 用户测试
|
|
|
-│ │ │ ├── files/ # 文件业务模块
|
|
|
-│ │ │ │ ├── file.entity.ts # 文件实体
|
|
|
-│ │ │ │ ├── file.service.ts # 文件服务
|
|
|
-│ │ │ │ ├── minio.service.ts # MinIO服务
|
|
|
-│ │ │ │ ├── file.schema.ts # 文件验证Schema
|
|
|
-│ │ │ │ └── __tests__/ # 文件测试
|
|
|
-│ │ ├── utils/ # 工具层
|
|
|
-│ │ │ ├── generic-crud.service.ts # 通用CRUD服务
|
|
|
-│ │ │ ├── generic-crud.routes.ts # 通用CRUD路由
|
|
|
-│ │ │ ├── errorHandler.ts # 错误处理
|
|
|
-│ │ │ ├── backup.ts # 数据库备份工具
|
|
|
-│ │ │ ├── restore.ts # 数据库恢复工具
|
|
|
-│ │ │ ├── logger.ts # 日志工具
|
|
|
-│ │ │ └── __tests__/ # 工具测试
|
|
|
-│ │ ├── middleware/ # 中间件层
|
|
|
-│ │ │ ├── auth.middleware.ts # 认证中间件
|
|
|
-│ │ │ └── permission.middleware.ts # 权限中间件
|
|
|
-│ │ ├── types/ # 类型定义
|
|
|
-│ │ ├── data-source.ts # 数据库连接配置
|
|
|
-│ │ └── index.ts # 服务器入口
|
|
|
-│ └── share/ # 前后端共享代码
|
|
|
-│ └── types.ts # TypeScript类型定义
|
|
|
-├── tests/
|
|
|
-│ └── e2e/ # E2E测试 (Playwright)
|
|
|
-└── package.json
|
|
|
+d8d-mini-starter/
|
|
|
+├── mini/ # 小程序项目 (Taro + React)
|
|
|
+│ ├── src/
|
|
|
+│ │ ├── app.tsx # 小程序入口
|
|
|
+│ │ ├── app.config.ts # 小程序配置
|
|
|
+│ │ ├── api.ts # API客户端
|
|
|
+│ │ ├── components/
|
|
|
+│ │ │ └── ui/ # UI组件库
|
|
|
+│ │ │ ├── avatar-upload.tsx # 头像上传组件
|
|
|
+│ │ │ ├── button.tsx # 按钮组件
|
|
|
+│ │ │ ├── card.tsx # 卡片组件
|
|
|
+│ │ │ ├── form.tsx # 表单组件
|
|
|
+│ │ │ ├── image.tsx # 图片组件
|
|
|
+│ │ │ ├── input.tsx # 输入框组件
|
|
|
+│ │ │ ├── label.tsx # 标签组件
|
|
|
+│ │ │ ├── navbar.tsx # 导航栏组件
|
|
|
+│ │ │ └── tab-bar.tsx # 标签栏组件
|
|
|
+│ │ ├── layouts/
|
|
|
+│ │ │ └── tab-bar-layout.tsx # 标签栏布局
|
|
|
+│ │ ├── pages/
|
|
|
+│ │ │ ├── explore/ # 探索页面
|
|
|
+│ │ │ │ ├── index.tsx
|
|
|
+│ │ │ │ └── index.config.ts
|
|
|
+│ │ │ ├── index/ # 首页
|
|
|
+│ │ │ │ ├── index.tsx
|
|
|
+│ │ │ │ └── index.config.ts
|
|
|
+│ │ │ ├── login/ # 登录页面
|
|
|
+│ │ │ │ ├── index.tsx
|
|
|
+│ │ │ │ ├── index.config.ts
|
|
|
+│ │ │ │ └── wechat-login.tsx # 微信登录
|
|
|
+│ │ │ ├── profile/ # 个人资料
|
|
|
+│ │ │ │ ├── index.tsx
|
|
|
+│ │ │ │ └── index.config.ts
|
|
|
+│ │ │ └── register/ # 注册页面
|
|
|
+│ │ │ ├── index.tsx
|
|
|
+│ │ │ └── index.config.ts
|
|
|
+│ │ ├── schemas/ # 验证模式
|
|
|
+│ │ └── utils/ # 工具函数
|
|
|
+│ ├── config/
|
|
|
+│ │ ├── dev.ts # 开发环境配置
|
|
|
+│ │ ├── index.ts # 配置入口
|
|
|
+│ │ └── prod.ts # 生产环境配置
|
|
|
+│ └── package.json
|
|
|
+├── web/ # Web应用 (Hono + React SSR)
|
|
|
+│ ├── src/
|
|
|
+│ │ ├── client/ # 客户端代码
|
|
|
+│ │ │ ├── admin/ # 管理后台
|
|
|
+│ │ │ │ ├── components/ # 管理后台组件
|
|
|
+│ │ │ │ │ ├── AvatarSelector.tsx # 头像选择器
|
|
|
+│ │ │ │ │ ├── DataTablePagination.tsx # 表格分页
|
|
|
+│ │ │ │ │ ├── ErrorPage.tsx # 错误页面
|
|
|
+│ │ │ │ │ ├── FileSelector.tsx # 文件选择器
|
|
|
+│ │ │ │ │ ├── MinioUploader.tsx # MinIO上传器
|
|
|
+│ │ │ │ │ ├── NotFoundPage.tsx # 404页面
|
|
|
+│ │ │ │ │ └── ProtectedRoute.tsx # 路由保护
|
|
|
+│ │ │ │ ├── hooks/
|
|
|
+│ │ │ │ │ └── AuthProvider.tsx # 认证状态管理
|
|
|
+│ │ │ │ ├── layouts/
|
|
|
+│ │ │ │ │ └── MainLayout.tsx # 主布局
|
|
|
+│ │ │ │ ├── pages/
|
|
|
+│ │ │ │ │ ├── Dashboard.tsx # 仪表板
|
|
|
+│ │ │ │ │ ├── Files.tsx # 文件管理
|
|
|
+│ │ │ │ │ ├── Login.tsx # 登录页面
|
|
|
+│ │ │ │ │ └── Users.tsx # 用户管理
|
|
|
+│ │ │ │ ├── menu.tsx # 菜单配置
|
|
|
+│ │ │ │ ├── routes.tsx # 路由配置
|
|
|
+│ │ │ │ └── index.tsx # 管理后台入口
|
|
|
+│ │ │ ├── components/
|
|
|
+│ │ │ │ └── ui/ # shadcn/ui组件库
|
|
|
+│ │ │ │ ├── accordion.tsx # 手风琴组件
|
|
|
+│ │ │ │ ├── alert-dialog.tsx # 警告对话框
|
|
|
+│ │ │ │ ├── alert.tsx # 警告组件
|
|
|
+│ │ │ │ └── ... # 其他50+组件
|
|
|
+│ │ │ ├── api.ts # API客户端
|
|
|
+│ │ │ └── index.tsx # 前端入口
|
|
|
+│ │ ├── server/ # 服务器端代码
|
|
|
+│ │ │ ├── api/ # API路由
|
|
|
+│ │ │ │ ├── auth/ # 认证相关
|
|
|
+│ │ │ │ │ ├── index.ts # 认证路由入口
|
|
|
+│ │ │ │ │ ├── login/post.ts # 登录接口
|
|
|
+│ │ │ │ │ ├── logout.ts # 登出接口
|
|
|
+│ │ │ │ │ ├── me/get.ts # 获取用户信息
|
|
|
+│ │ │ │ │ ├── me/put.ts # 更新用户信息
|
|
|
+│ │ │ │ │ ├── mini-login/post.ts # 小程序登录
|
|
|
+│ │ │ │ │ ├── register/create.ts # 注册接口
|
|
|
+│ │ │ │ │ └── sso-verify.ts # SSO验证
|
|
|
+│ │ │ │ ├── files/ # 文件管理
|
|
|
+│ │ │ │ │ ├── [id]/delete.ts # 删除文件
|
|
|
+│ │ │ │ │ ├── [id]/download.ts # 下载文件
|
|
|
+│ │ │ │ │ ├── [id]/get-url.ts # 获取文件URL
|
|
|
+│ │ │ │ │ ├── index.ts # 文件列表
|
|
|
+│ │ │ │ │ ├── multipart-complete/post.ts # 完成分片上传
|
|
|
+│ │ │ │ │ ├── multipart-policy/post.ts # 分片上传策略
|
|
|
+│ │ │ │ │ └── upload-policy/post.ts # 上传策略
|
|
|
+│ │ │ │ ├── roles/index.ts # 角色管理
|
|
|
+│ │ │ │ ├── users/index.ts # 用户管理
|
|
|
+│ │ │ │ ├── users/custom.ts # 自定义用户接口
|
|
|
+│ │ │ │ └── api.ts # API路由入口
|
|
|
+│ │ │ ├── data-source.ts # 数据库连接
|
|
|
+│ │ │ └── index.tsx # 服务器入口
|
|
|
+│ │ └── share/ # 共享代码
|
|
|
+│ ├── tests/
|
|
|
+│ │ ├── e2e/ # E2E测试 (Playwright)
|
|
|
+│ │ ├── integration/ # 集成测试
|
|
|
+│ │ └── unit/ # 单元测试
|
|
|
+│ └── package.json
|
|
|
+├── docs/ # 项目文档
|
|
|
+│ └── architecture/ # 架构文档
|
|
|
+├── scripts/ # 脚本文件
|
|
|
+├── .bmad-core/ # BMAD核心配置
|
|
|
+├── .claude/ # Claude配置
|
|
|
+├── .git/ # Git仓库
|
|
|
+├── package.json # 根项目配置
|
|
|
+└── pnpm-lock.yaml # 依赖锁定文件
|
|
|
```
|
|
|
|
|
|
## 集成指南
|
|
|
- **文件命名**: 保持现有kebab-case命名约定
|
|
|
-- **文件夹组织**: 遵循功能模块划分,添加__tests__文件夹
|
|
|
-- **测试结构**: 单元测试位于`__tests__/`目录,集成测试位于`__integration_tests__/`目录
|
|
|
-- **导入/导出模式**: 使用ES模块,保持现有别名系统(@/)
|
|
|
-- **测试位置**: 前端集成测试位于`__integration_tests__/`,页面单元测试位于`__tests__/`
|
|
|
-- **后端测试**: API测试位于路由`__tests__/`目录,服务测试位于模块`__tests__/`目录
|
|
|
-- **工具测试**: 通用工具测试位于`utils/__tests__/`目录
|
|
|
+- **项目结构**: 采用monorepo模式,包含小程序(mini)和Web应用(web)两个独立项目
|
|
|
+- **小程序架构**: 基于Taro框架,支持多平台(微信小程序、H5等)
|
|
|
+- **Web应用架构**: 基于Hono + React SSR,使用shadcn/ui组件库
|
|
|
+- **API设计**: 使用Hono框架,RESTful API设计,支持文件分片上传
|
|
|
+- **数据库**: 使用PostgreSQL + TypeORM
|
|
|
+- **存储**: 使用MinIO进行文件存储
|
|
|
+- **测试结构**:
|
|
|
+ - 单元测试位于`tests/unit/`
|
|
|
+ - 集成测试位于`tests/integration/`
|
|
|
+ - E2E测试位于`tests/e2e/` (Playwright)
|
|
|
+- **开发环境**: 多八多云端开发容器,包含Node.js 20.19.2、PostgreSQL 17、Redis 7、MinIO
|
|
|
+- **构建工具**: 使用Vite + pnpm,支持SSR构建
|