Skip to content

目录结构 ​

仓库采用 pnpm monorepo,workspace 范围由根 pnpm-workspace.yaml 界定:apps/*、packages/*、apps/web/packages/*。

autojs6_Management/
├── apps/
│   ├── server/                 # NestJS 10 后端(唯一允许演进的后端)
│   │   ├── prisma/
│   │   │   ├── schema.prisma   # 数据模型(Prisma)
│   │   │   ├── migrations/     # 数据库迁移文件
│   │   │   ├── seed.ts         # 空库基线快照
│   │   │   └── seed-if-empty.cjs
│   │   ├── src/
│   │   │   ├── main.ts         # 应用入口(全局前缀 /api)
│   │   │   ├── app.module.ts   # 根模块(全局 Guard 链注册)
│   │   │   ├── config/         # 环境变量校验与 AppConfigService
│   │   │   ├── module/         # 业务模块(如 device/)
│   │   │   ├── core/           # 守卫、拦截器、过滤器、装饰器
│   │   │   ├── infrastructure/ # Prisma、Repository 基类、缓存、日志
│   │   │   ├── shared/         # 统一响应、异常、工具、枚举
│   │   │   ├── tenant/         # 多租户上下文、Extension、服务
│   │   │   ├── security/       # 登录、MFA、加密
│   │   │   ├── observability/  # 审计、指标、健康检查
│   │   │   └── resilience/     # 熔断、重试、限流
│   │   ├── Dockerfile          # 生产镜像(两阶段)
│   │   └── docker-entrypoint.sh
│   └── web/                    # Vue3 + Naive UI 前端(唯一允许演进的前端)
│       ├── src/
│       │   ├── main.ts
│       │   ├── router/         # 路由与守卫(@elegant-router 文件路由)
│       │   ├── views/          # 页面(src/views/<域>/<功能>/)
│       │   ├── components/
│       │   ├── layouts/
│       │   ├── store/          # Pinia
│       │   ├── hooks/          # 通用/业务 hooks(useTable 等)
│       │   ├── service/        # API 定义与请求层
│       │   ├── typings/        # 接口类型
│       │   └── plugins/
│       ├── packages/           # 前端子包(axios/hooks/materials 等)
│       ├── build/              # vite 插件与构建配置
│       └── vite.config.ts
├── packages/
│   └── types/                  # @nest-admin/types 跨端共享类型
├── RefConf/
│   ├── dev/                    # 本地编排(compose、nginx、Dockerfile.dev)
│   └── hk/                     # 香港生产配置(compose、nginx、部署脚本)
├── docs/                       # VitePress 文档站(本站)
├── doc/                        # 架构方案与设计文档
├── scripts/                    # 基础设施脚本
├── pnpm-workspace.yaml
├── turbo.json
└── build-server.ps1            # 本地容器化统一入口

后端模块结构 ​

业务模块统一放在 apps/server/src/module/<域>/<功能>/:

module/device/
├── device.module.ts
├── device.controller.ts        # 参数/DTO/权限/Swagger
├── device.service.ts           # 业务编排(复杂逻辑拆 services/)
├── device.repository.ts        # 查询封装(extends SoftDeleteRepository)
├── dto/                        # 入参 *.request.dto.ts + 出参 responses/
└── services/(可选)

依赖方向严格单向:

Controller → Service → Repository → Prisma

前端页面结构 ​

页面位于 apps/web/src/views/<域>/<功能>/,配套文件放在 modules/:

views/system/notice/
├── index.vue                   # 列表页(useTable + NDataTable)
└── modules/
    ├── notice-search.vue       # 搜索表单
    └── notice-operate-drawer.vue # 新增/编辑抽屉

新建页面后通过后端动态菜单下发权限,不写静态路由。

最近更新

Released under the MIT License.