docs: 更新known-patterns.json - 增加API嵌套结构问题说明
- pat-002: 明确说明所有列表API都有相同的嵌套结构问题 - applications: 5次重复发生
This commit is contained in:
parent
e0a228188a
commit
2d0f9bf5e0
|
|
@ -18,17 +18,18 @@
|
||||||
},
|
},
|
||||||
"pat-002": {
|
"pat-002": {
|
||||||
"name": "Axios响应数据嵌套结构",
|
"name": "Axios响应数据嵌套结构",
|
||||||
"source": "implementation_review",
|
"source": "user_feedback",
|
||||||
"confidence": 0.95,
|
"confidence": 0.95,
|
||||||
"applications": 1,
|
"applications": 5,
|
||||||
"created": "2026-03-22",
|
"created": "2026-03-22",
|
||||||
"category": "frontend",
|
"category": "frontend",
|
||||||
"pattern": "API响应是{code, message, data{...}}嵌套结构,直接访问res.data.token是undefined",
|
"pattern": "后端API响应统一格式为{code,message,data{}},前端直接访问res.data导致数据为undefined",
|
||||||
"problem": "登录成功后token存储为undefined,导致isLoggedIn返回false",
|
"problem": "登录、用户、角色、权限等页面fetch数据时,res.data是ApiResponse而非实际数据",
|
||||||
"solution": "使用res.data.data获取实际的登录数据",
|
"solution": "使用res.data.data获取实际的列表/用户数据",
|
||||||
"quality_rules": [
|
"quality_rules": [
|
||||||
"登录数据在res.data.data中,不是在res.data中",
|
"所有API调用后赋值给ref时使用 res.data.data",
|
||||||
"访问嵌套数据前先console.log打印确认结构"
|
"示例: users.value = res.data.data || []",
|
||||||
|
"不仅是登录API,所有列表查询API都有相同的嵌套结构"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"pat-003": {
|
"pat-003": {
|
||||||
|
|
@ -50,7 +51,7 @@
|
||||||
"name": "Git提交纪律",
|
"name": "Git提交纪律",
|
||||||
"source": "user_feedback",
|
"source": "user_feedback",
|
||||||
"confidence": 0.95,
|
"confidence": 0.95,
|
||||||
"applications": 3,
|
"applications": 5,
|
||||||
"created": "2026-03-22",
|
"created": "2026-03-22",
|
||||||
"category": "workflow",
|
"category": "workflow",
|
||||||
"pattern": "代码修改后未提交到Git,npm install或操作导致工作目录恢复到旧状态",
|
"pattern": "代码修改后未提交到Git,npm install或操作导致工作目录恢复到旧状态",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue