Files
verify/docs/DEVELOPMENT_LOG.md
T

42 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 开发日志
## 2026-05-08
### 修复:版本管理更新保存不生效
**问题描述:**
- 编辑版本时,将"可选更新"切换为"强制更新"后保存,提示成功但实际未生效
- 编辑版本页面进入后没有数据,全是默认状态
**根因分析:**
1. **编辑页数据获取错误**
- `[id].vue``fetchVersion()` 使用了 `data?.version || data`,由于 API 返回的 data 对象包含 `version` 字段(版本号字符串),导致 `data?.version` 返回的是版本号字符串而非版本对象,后续取 `ver.application_id` 等字段均为 `undefined`
2. **Switch 组件事件绑定错误**
- 项目使用了 Reka UI 的 Switch 组件,该组件明确要求使用 `v-model` 绑定,不支持 `:checked` + `@update:checked` 方式
- 原代码 `@update:checked` 事件实际上不会触发,导致 `formData.update_strategy` 始终为初始值 `optional`
- 这是版本更新不生效的真正根因
**修复方案:**
| 文件 | 修改内容 |
|------|----------|
| `frontend/src/pages/admin/versions/[id].vue` | 1. `fetchVersion()` 直接使用 `api.get()` 返回值而非 `data?.version`<br>2. Switch 改用 `v-model="isForcedUpdate"` 绑定 computed getter/setter |
| `frontend/src/pages/admin/versions/create.vue` | Switch 改用 `v-model="isForcedUpdate"` 绑定 computed getter/setter |
| `frontend/src/pages/admin/versions/components/columns.ts` | 状态列改为根据 `update_strategy` 判断(`optional`/`forced`),移除旧的 `active`/`superseded` 判断 |
| `backend/internal/router/admin/versions.go` | 改用 `DB.Model().Where().Updates()` 替代 `DB.Save()`,添加 `RowsAffected` 检查和调试日志 |
**技术要点:**
- Reka UI 的 `SwitchRoot` 组件必须使用 `v-model` 双向绑定,不能使用 `v-model:checked``:checked` + `@update:checked`
- 组件源码注释:[Switch.vue](../../frontend/src/components/ui/switch/Switch.vue) 第 5-9 行
```vue
<!-- 正确 -->
<UiSwitch v-model="isForcedUpdate" />
<!-- 错误值不会正确更新 -->
<UiSwitch v-model:checked="form.enabled" />
<UiSwitch :checked="val" @update:checked="val = $event" />
```