Files
msh-system/scripts/logs/agent-BUG-007-102627.log

38 lines
2.0 KiB
Plaintext
Raw Normal View History

BUG-007 已按你的要求改完,修改总结如下:
### 1. **`loadKnowledgeList` 与 API 调用**
- **根因**:在 `rawList.map` 里用了 `formatKnowledgeTime(...)` 未加 `this.`,在 API 有数据时会报错(如 "formatKnowledgeTime is not a function"),进入 catch列表不会被赋值所以一直为空。
- **修改**:改为 `this.formatKnowledgeTime(...)`,确保在 map 里正确调用组件方法。
### 2. **请求参数 type**
- type 已与后端一致:`guide` / `article`(注释里也写明了)。
### 3. **API 失败时的处理**
- catch 里已有 `uni.showToast` 提示。
- 在 catch 中保证不把列表置为 undefined
`this.guideList = this.guideList ?? []`、`this.articleList = this.articleList ?? []`,出错时仍保持为数组。
### 4. **响应数据结构兼容**
- 增加对两种返回形式的兼容:
- `result.data.list` 为数组时用 `result.data.list`
- 若 `result.data` 本身是数组则用 `result.data`。
这样无论后端用分页对象还是直接数组,都能正确取到列表。
### 5. **onLoad 无 id 时的逻辑**
- 有 `id`:调用 `switchTab('articles')`,会触发 `loadKnowledgeList` 拉取科普文章列表。
- 无 `id`:显式保持 `currentTab = 'nutrients'`;用户切到「饮食指南」或「科普文章」时由 `switchTab` 触发 `loadKnowledgeList`,与需求一致。
### 6. **详情页跳转 `goToDetail`**
- 已有「无 id 不跳转」的逻辑,本次只做了小加固:
- 若 `!item` 也先提示「暂无详情」再 return
- 仅当 `knowledgeId` 或 `id` 存在且有效时才 `navigateTo`,否则一律提示「暂无详情」。
当前无新的 lint 报错。若后端库里没有 type 为 `guide` / `article` 的数据,列表仍会为空,但会正常显示「暂无饮食指南数据」/「暂无科普文章数据」;若详情页打开仍空白,需要再确认详情页是否应调 `tool/knowledge/detail/:id` 而不是文章接口。