-
Notifications
You must be signed in to change notification settings - Fork 0
refactor(frontend): 前端架构重构与工程化升级(TypeScript + Pinia + Router + i18n) #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
40b7c53
fa92cdc
613b1a0
8b06ac7
e735888
0a00c15
6b1ed99
0495f47
fd93b42
2285460
e85ace9
d1f9175
c7f44e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,12 @@ jobs: | |
| - name: Install frontend dependencies | ||
| run: task frontend:install | ||
|
|
||
| - name: Run frontend format checks | ||
| run: task frontend:fmt | ||
|
|
||
| - name: Run frontend lint checks | ||
| run: task frontend:lint | ||
|
|
||
| - name: Build frontend once | ||
| run: task frontend:build | ||
|
Comment on lines
+36
to
43
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| .github/agents/ | ||
| .github/prompts/ | ||
| .agent/ |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,45 +1,67 @@ | ||||||
| # MineDock Root Context | ||||||
|
|
||||||
| ## 1. 项目核心定义与最终目标 | ||||||
| MineDock 是一个用于管理本地 Docker 容器实例的最小可行系统。 | ||||||
| 当前阶段目标是:跑通一个测试容器的“创建”与“销毁”完整流程,并提供最基本的列表查询能力。 | ||||||
| ## 1. 说明 | ||||||
| MineDock 是一个用于管理 Docker 容器实例的系统 | ||||||
|
|
||||||
| ## 2. 全局系统边界 | ||||||
| - 后端仅实现对本地 Docker 引擎的调用。 | ||||||
| - 当前阶段使用 SQLite 持久化实例基础状态(container_id、name、status)。 | ||||||
| - 前端提供实例生命周期四段交互动作: | ||||||
| - 获取列表 | ||||||
| - 创建(仅创建容器,不自动启动) | ||||||
| - 开启(启动已创建容器) | ||||||
| - 关闭(停止运行中容器) | ||||||
| - 删除(彻底删除已停止容器) | ||||||
| - 暂不处理 Cgroups 内存限制与跨环境一致性问题。 | ||||||
| - 直接使用现成公开镜像进行流程验证。 | ||||||
| ## 2. 目标 | ||||||
| 实现一个支持易配置,功能强的游戏服务器容器化管理平台 | ||||||
|
|
||||||
| ## 3. 全局命名与契约约定 | ||||||
| - HTTP 接口统一挂载在 `/api` 前缀下。 | ||||||
| - 资源命名采用复数形式:`/api/instances`。 | ||||||
| - JSON 字段命名采用 snake_case(如 `container_id`)。 | ||||||
| - 实例状态字段 `status` 的业务值遵循: | ||||||
| - `Running` | ||||||
| - `Stopped` | ||||||
| ## 3. 当前系统边界 | ||||||
| ### 所有权边界 | ||||||
| #### 边界内 | ||||||
| - 本系统创建的容器 | ||||||
| - 本系统的数据库及其数据 | ||||||
| - 本系统的工作目录及容器挂载配置的数据卷目录 | ||||||
| #### 边界外 | ||||||
| - 非本系统创建的容器 | ||||||
| - 宿主机的其他进程 | ||||||
| - 除上述工作与挂载目录外的其他宿主机文件系统 | ||||||
| ### 功能边界 | ||||||
| #### 边界内 | ||||||
| - 容器的生命周期管理与资源配额调度 | ||||||
| - 容器内游戏服务器的快速安装与运行 | ||||||
| - 在线终端交互与控制指令下发 | ||||||
| - 游戏数据的持久化与灾灾备 (快照、备份与回档) | ||||||
|
||||||
| - 游戏数据的持久化与灾灾备 (快照、备份与回档) | |
| - 游戏数据的持久化与灾备 (快照、备份与回档) |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,21 @@ | ||||||
| # 后端规范 | ||||||
|
|
||||||
| 后端基于以下核心选型构建: | ||||||
| - **开发语言**:Go | ||||||
| - **持久化存储**:SQLite | ||||||
| - **核心依赖**:Docker SDK | ||||||
|
|
||||||
| ## 架构依赖规则 | ||||||
| 为保证代码的可测试性与可维护性,`internal` 目录下的四层架构必须遵循单向依赖规则,严禁循环引用: | ||||||
| - **`api` 层**:作为程序的入口与防腐层,负责依赖注入 `service`,并处理 HTTP 相关的解析与返回。 | ||||||
| - **`service` 层**:作为纯粹的业务中枢,内部调用 `store` 进行持久化获取或通过外部组件交互。 | ||||||
| - **`store` 层**:负责底层数据落地设计(如 SQLite 语句),对外暴露 Interface 或直接的数据操作方法。 | ||||||
| - **`model` 层**:最为底层,被上述三层共同引用,不应依赖 `api`/`service`/`store` 的任何代码。 | ||||||
|
|
||||||
| ## 编码质量与规范 | ||||||
| - **代码格式化与校验**:`go fmt` 与 `go vet` | ||||||
| - **错误处理**: | ||||||
| - 核心逻辑层要求显式返回 `error`,并在合适的网络层封装为统一规范的 JSON HTTP 响应体(如 `{"status": "error", "message": "..."}`)。 | ||||||
|
||||||
| - 核心逻辑层要求显式返回 `error`,并在合适的网络层封装为统一规范的 JSON HTTP 响应体(如 `{"status": "error", "message": "..."}`)。 | |
| - 核心逻辑层要求显式返回 `error`,并在合适的网络层封装为统一规范的 JSON HTTP 响应体(如 `{"status": "error", "error": "..."}`)。 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # 前端规范 | ||
|
|
||
| 前端基于以下核心选型构建: | ||
| - **构建工具**:Vite | ||
| - **核心框架**:Vue 3 (Composition API) | ||
| - **开发语言**: TypeScript | ||
| - **状态管理**:Pinia | ||
| - **路由控制**:Vue Router | ||
|
|
||
| ## 代码质量 | ||
| - **代码格式化与校验**: 使用 ESLint + Prettier | ||
|
|
||
| ## 模块化与主题化 | ||
| 前端 UI 必须具备高度的模块化,以支持动态主题(如浅色/暗色模式切换)和未来可能的皮肤更换 | ||
| - **禁止硬编码样式**:所有颜色、间距、字体大小必须使用 CSS 变量引入 | ||
| - **变量分层**: | ||
| - 基础变量:如 `--blue-500`, `--gray-900` | ||
| - 语义变量:如 `--bg-primary`, `--text-danger`, `--border-color` | ||
| - **主题切换实现**:通过动态修改 `<html>` 或 `<body>` 的 `data-theme` 属性(如 `data-theme="dark"`),结合 CSS 变量覆盖实现低成本主题切换 | ||
|
|
||
| ## 国际化规范 | ||
| 提供多语言支持 | ||
| - **文案分离**:所有的界面静态文本禁止在 `.vue` 或 `.js` 文件中硬编码,必须通过 Vue I18n 等插件引入 | ||
| - **文件组织**:语言包统一存放于 `src/locales/`,按语言划分(如 `zh-CN.json`, `en-US.json`) | ||
| - **动态变量插值**:涉及动态数据的文案使用插值符,例如:"成功启动容器 {containerName}" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # MineDock API Contracts | ||
|
|
||
| 前后端接口定义,后端与Docker Daemon的交互流等 | ||
|
|
||
| ## 1. 容器实例生命周期接口 (Instance Lifecycle) | ||
|
|
||
| | 方法 | 路径 | 说明 | 请求参数 | 返回结果 | | ||
| | --- | --- | --- | --- | --- | | ||
| | GET | `/api/instances` | 获取当前所有容器的列表 | 无 | `[{"container_id":"xxx", "name":"xxx", "status":"xxx"}]` | | ||
| | POST | `/api/instances` | 创建一个新容器(初始为 Stopped) | `{"name": "测试服1号"}` | `{"status": "success", "container_id": "xxx"}` | | ||
| | POST | `/api/instances/:id/start` | 启动指定容器实例 | 无(ID 在路径中) | `{"status": "success"}` | | ||
| | POST | `/api/instances/:id/stop` | 停止指定容器实例 | 无(ID 在路径中) | `{"status": "success"}` | | ||
| | DELETE | `/api/instances/:id` | 彻底删除指定容器实例 | 无(ID 在路径中) | `{"status": "success"}` | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| dist | ||
| node_modules | ||
| coverage | ||
| *.log |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "printWidth": 100, | ||
| "semi": true, | ||
| "singleQuote": false, | ||
| "trailingComma": "all", | ||
| "tabWidth": 2, | ||
| "useTabs": false, | ||
| "vueIndentScriptAndStyle": false | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new lint/format steps can fail under the configured Node "20" because the newly added ESLint toolchain in frontend/package-lock.json declares engines like
^20.19.0 || .... Consider pinning the workflow Node version to >=20.19.x (or downgrading ESLint deps to versions compatible with Node 20.0.x).