docs: add web frontend engineering guide
This commit is contained in:
25
web/.ai-specs/coding-specs/page-view-component-split.md
Normal file
25
web/.ai-specs/coding-specs/page-view-component-split.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# page-view-component-split
|
||||
|
||||
## 适用范围
|
||||
|
||||
- 涉及新增页面、抽公共组件、抽 hooks 时必读。
|
||||
|
||||
## 边界规则
|
||||
|
||||
- `src/view` 负责页面级编排、页面级异步请求、页面生命周期和页面局部状态。
|
||||
- `src/components` 只放跨页面复用组件,不直接承载具体页面路由语义。
|
||||
- `src/hooks` 只放可复用行为逻辑,不承载模板和页面路由跳转。
|
||||
- 页面私有子组件优先放在页面目录内部,而不是直接放进 `src/components`。
|
||||
|
||||
## 新增代码默认落点
|
||||
|
||||
- 新页面:`src/view/<module>/index.vue` 或页面目录内对应 `.vue`
|
||||
- 页面局部子组件:`src/view/<module>/components/*`
|
||||
- 跨页面复用组件:`src/components/<component-name>/*`
|
||||
- 跨页面复用逻辑:`src/hooks/useXxx.js`
|
||||
|
||||
## 常见错误
|
||||
|
||||
- 只在一个页面使用的弹窗、表格、筛选器被塞进 `src/components`。
|
||||
- 页面内的大段逻辑直接复制到第二个页面,没有先评估是否抽 hooks。
|
||||
- hooks 内直接操作页面模板细节,导致复用边界失效。
|
||||
Reference in New Issue
Block a user