refactor(device): 收敛设备模块结构,业务 API 与页面组件迁出上游目录
- src/api/system/device -> src/api/device,原 app-icon 类型拆为 appIcon.types.ts - src/api/system/developer -> src/api/developer - src/components/DeviceSn -> src/views/devices/sn/components,页内改为显式导入 - 同步更新 AGENTS.md 的模块目录与 API 分域约定
This commit is contained in:
1 parent
d50265da77
commit
d36248ead6
22 files changed
+581
-574
No files matched your search
@@ -56,20 +56,23 @@
|
||||
## 6. 新模块目录约定
|
||||
|
||||
```text
|
||||
src/api/<module>/index.ts # API 对象;类型少可同文件,多则拆 types.ts
|
||||
src/api/<module>.ts # 类型少时单文件(API 对象 + interface)
|
||||
src/api/<module>/index.ts # API 对象;类型多时拆 types.ts
|
||||
src/api/<module>/types.ts
|
||||
src/views/<module>/<page>/index.vue
|
||||
src/views/<module>/<page>/config/ # 可选:search/content/add/edit/options
|
||||
src/components/<ModuleName>/ # 模块私有可复用组件
|
||||
src/views/<module>/<page>/config/ # 可选:search/content/add/edit/options
|
||||
src/views/<module>/<page>/components/ # 可选:页面私有组件与类型
|
||||
src/components/<ModuleName>/ # 跨页面复用才提升到这里
|
||||
src/composables/use<Name>.ts # 新 composable 直接引用,不并入上游 index.ts
|
||||
src/enums/<module>.ts # 新枚举独立文件,不并入上游 enums/index.ts
|
||||
src/constants/<module>.ts
|
||||
```
|
||||
|
||||
- 目录 kebab-case(`app-manager`、`save-flow`),组件 PascalCase(`DeviceSnDetail`)。
|
||||
- 页面私有组件/类型留在页面目录;跨页面复用才提升到 `src/components/<ModuleName>/`。
|
||||
- 业务 API 一律放 `src/api/<module>`,**不要放进上游的 `src/api/system/`**(会被上游同步覆盖或覆盖上游 `user`/`role` 等模块)。
|
||||
- 页面私有组件/类型留在页面目录的 `components/`;跨页面复用才提升到 `src/components/<ModuleName>/`。
|
||||
- 业务类型不放 `src/types/`;通用工具可在 `src/utils/` 新建独立文件,禁止修改上游已有工具文件;业务状态不放上游 `src/stores/*`。
|
||||
- 现有范例:`src/views/update/`、`src/views/devices/`、`src/views/app-manager/`、`src/components/DeviceSn/`。
|
||||
- 现有范例:`src/views/update/`、`src/views/devices/`、`src/views/app-manager/`、`src/views/devices/sn/components/`。
|
||||
|
||||
## 7. API 层规范
|
||||
|
||||
@@ -88,6 +91,7 @@ export const XxxAPI = {
|
||||
```
|
||||
|
||||
- 分页统一用 `@/api/common` 的 `PageQuery` / `PageResult`。
|
||||
- 一个模块下有多组业务类型时按域拆文件(如 `src/api/device/types.ts` 与 `src/api/device/appIcon.types.ts`),不要混放在一个 `types.ts`。
|
||||
- 错误提示由拦截器统一弹出;页面 `catch` 只做善后(关 loading、关弹窗、回滚状态),不要重复 `ElMessage.error`。
|
||||
- 轮询/探测请求用 `silentErrorStatuses` 静默指定状态码。
|
||||
- 免鉴权请求用 `anonymous: true` 或 `headers: { Authorization: "no-auth" }`(类型见 `types/axios.d.ts`)。
|
||||
|
||||
Reference in new issue
Block a user