Skip to content

项目结构规范

前端项目结构规范

sh
src/
├── assets/                 # 静态资源
   ├── images/            # 图片资源
   ├── fonts/             # 字体文件
   └── styles/            # 全局样式
       ├── variables.scss # 变量定义
       ├── mixins.scss    # Mixins
       └── index.scss     # 样式入口
├── components/            # 组件目录
   ├── common/            # 通用组件(跨项目)
   ├── Button/
   ├── Button.vue
   ├── Button.ts
   └── index.ts
   └── Modal/
   ├── business/          # 业务组件
   └── User/
   └── layout/            # 布局组件
       ├── Header.vue
       ├── Sidebar.vue
       └── Footer.vue
├── composables/           # 组合式函数
   ├── usePagination.ts
   ├── useForm.ts
   └── index.ts
├── router/                # 路由配置
   ├── index.ts
   ├── routes.ts
   └── guards.ts
├── stores/                # 状态管理
   ├── modules/
   ├── user.ts
   └── app.ts
   └── index.ts
├── types/                 # TypeScript类型定义
   ├── api/
   ├── entity/
   └── index.ts
├── utils/                 # 工具函数
   ├── request.ts         # HTTP请求
   ├── validator.ts       # 验证器
   ├── date.ts            # 日期处理
   └── index.ts
├── views/                 # 页面组件
   ├── login/
   ├── dashboard/
   └── user/
├── api/                   # API接口层
   ├── modules/
   ├── user.ts
   └── auth.ts
   └── index.ts
├── locales/               # 国际化
   ├── zh-CN.ts
   └── en-US.ts
├── plugins/               # Vue插件
├── App.vue                # 根组件
└── main.ts                # 应用入口

后端项目结构(多模块)

sh
backend/
├── project-parent/                 # 父工程
   ├── pom.xml
   ├── README.md
   └── .gitignore
├── project-common/                 # 公共模块
   ├── common-core/               # 核心工具
   ├── common-redis/              # Redis封装
   ├── common-web/                # Web相关
   └── common-mybatis/            # MyBatis扩展
├── project-framework/              # 框架模块
   ├── framework-security/         # 安全框架
   ├── framework-log/              # 日志框架
   ├── framework-swagger/          # API文档
   └── framework-exception/        # 异常处理
├── project-modules/                # 业务模块
   ├── module-system/              # 系统模块
   ├── src/
   ├── main/
   ├── java/com/company/project/module/
   ├── controller/
   ├── service/
   ├── impl/
   └── UserService.java
   ├── mapper/
   ├── domain/
   ├── entity/
   ├── dto/
   ├── vo/
   └── query/
   └── config/
   └── resources/
       ├── mapper/
       ├── application.yml
       └── logback-spring.xml
   └── test/
   └── pom.xml
   ├── module-user/                # 用户模块
   └── module-order/               # 订单模块
├── project-gateway/                # API网关
├── project-auth/                   # 认证中心
└── project-monitor/                # 监控中心