From f2cb69cb06c31fe09f1cad7c3cd966695bbf9210 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Wed, 16 Sep 2026 17:14:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(ai-chat):=20rename=20=5FpendingIdSeq=20?= =?UTF-8?q?=E2=86=92=20pendingIdSeq=20(Vue=202=20strips=20underscore-prefi?= =?UTF-8?q?x=20data)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-FRONTEND-MEDIA-UPLOAD-FIX-HOTFIX (2026-09-16) Bug: Vue 2 在组件实例化时过滤掉 _ 和 $ 开头的数据属性. `_pendingIdSeq: 0` 在 data() 里定义但 this._pendingIdSeq === undefined. onImagePicked 中 `++this._pendingIdSeq` → NaN, 所有 pendingImage 的 localId 都是 NaN, Vue 'Duplicate keys detected: NaN' 警告. E2E 实测发现 (test_ai_chat_upload.py 20/20 通过): - pendingImages 应有 3 项 ✓ - 每张图 localId 独立递增 (1, 2, 3) ✓ - 3 张图独立上传成功 ✓ - DOM 渲染 3 个 .pending-item + 3 个 uni-image 缩略图 ✓ - canSendPendingImage computed = true → .top-send-btn 出现 ✓ - removePendingImage(localId) → 剩 2 张 ✓ - 失败场景: uploadError 有值 + pending-retry-delete 出现 ✓ 修复: data 里改 pendingIdSeq: 0, 代码里改 ++this.pendingIdSeq 教训: Vue 2 data() 里禁止用 _ 或 $ 前缀的属性名. --- pages_tool/ai-chat/ai-chat-message.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pages_tool/ai-chat/ai-chat-message.vue b/pages_tool/ai-chat/ai-chat-message.vue index 2c6e2fc..3ecade6 100644 --- a/pages_tool/ai-chat/ai-chat-message.vue +++ b/pages_tool/ai-chat/ai-chat-message.vue @@ -541,7 +541,10 @@ export default { // PR-FRONTEND-MEDIA-UPLOAD-FIX (2026-09-16): pendingImages 数组支持 1-9 张图 // 原 pendingImage 单数对象, 只存第一张, 选 5 张只发 1 张 // 每项: { localId, tempPath, uploading, uploaded, uploadError, sentWithBatch } - _pendingIdSeq: 0, + // ⚠️ Vue 2 会过滤掉 _/$ 开头的数据属性, _pendingIdSeq → undefined → ++undefined = NaN + // 所有图 localId 都变 NaN, Vue "Duplicate keys" 警告, 数组错乱. + // 必须用非下划线前缀. PR-FRONTEND-MEDIA-UPLOAD-FIX-HOTFIX (2026-09-16) + pendingIdSeq: 0, pendingImages: [], scrollTop: 0, scrollIntoViewId: null, @@ -770,7 +773,7 @@ export default { const list = Array.isArray(paths) ? paths : (paths ? [paths] : []) if (!list.length) return list.forEach((path) => { - const localId = ++this._pendingIdSeq + const localId = ++this.pendingIdSeq const pending = { localId, tempPath: path,