halo/console/docs/project-structure
Ryan Wang 52d064381f
refactor: improve project structure for user center feature (#4839)
#### What type of PR is this?

/area console
/kind improvement
/milestone 2.11.x

#### What this PR does / why we need it:

重构前端的目录结构,以便在后续让个人中心的代码支持复用部分代码。

https://github.com/ruibaby/halo/tree/refactor/file-structure/console/docs/project-structure

#### Special notes for your reviewer:

测试方式:

1. 启动最新的 Halo 后端。
2. 在 Console 目录运行 `pnpm dev`,可以观察到同时监听了 3000 和 4000 端口,分别代理原本的 /console 和新加的 /uc
3. 访问 /console 和 /uc。
4. 测试 `pnpm build`,完成之后检查主项目的 `src/main/resources` 目录是否包含 console 和 uc 目录。
5. 使用生产环境运行 Halo,访问 /console 和 /uc

#### Does this PR introduce a user-facing change?

```release-note
None
```
2023-11-09 06:56:06 +00:00
..
README.md refactor: improve project structure for user center feature (#4839) 2023-11-09 06:56:06 +00:00

README.md

项目结构

此目录为 Halo 前端项目的根目录,包含 Console 和 User Center 两部分。

名词解释

  • Console管理控制台主要包含内容管理、系统管理、插件、主题等面向管理员的功能。
  • User Center用户中心主要面向单个用户。

目录结构

├── console-src                         # Console 部分的源码
│   ├── composables
│   ├── layouts
│   ├── modules
│   ├── router
│   ├── stores
│   ├── styles
│   ├── views
│   ├── App.vue
│   └── main.ts
├── packages                            # 公共库,会在 Halo 发布版本的时候发布到 npmjs.com
│   ├── api-client                      # 根据 OpenAPI 生成的 API 客户端
│   ├── components                      # 基础组件库
│   └── shared                          # 共享库,主要提供给插件使用
├── src                                 # Console 和 User Center 共享的源码
│   ├── assets
│   ├── components
│   ├── constants
│   ├── formkit
│   ├── locales
│   ├── setup
│   ├── stores
│   ├── types
│   ├── utils
│   └── vite
├── uc-src                              # User Center 部分的源码
│   ├── router
│   ├── App.vue
│   └── main.ts
├── env.d.ts
├── index.html
├── package.json
├── pnpm-lock.yaml
├── pnpm-workspace.yaml
├── postcss.config.js
├── prettier.config.js
├── tailwind.config.js
├── tsconfig.app.json
├── tsconfig.json
├── tsconfig.node.json
├── tsconfig.vitest.json
├── vite.config.ts                      # Console 的 Vite 配置,使用 `--config` 指定
├── vite.uc.config.ts                   # User Center 的 Vite 配置,使用 `--config` 指定
└── vitest.config.ts

可以注意到 Console 和 User Center 仅仅只是使用了目录和 Vite 配置进行区分,本质上还是同一个项目,启动 Dev Server 的时候会同时启动两个 Vite 服务,路径分别为 /console/uc

同时,在构建时,会将 Console 和 User Center 两部分分别构建为两个独立的项目,构建后的文件会分别放在后端的 application/src/main/resources/consoleapplication/src/main/resources/uc 目录下,最终通过 Halo 本身进行托管。