From e093cccb8da6ccb75b5cfb6841b377587e213d0e Mon Sep 17 00:00:00 2001 From: zhangyahui Date: Thu, 7 May 2026 17:06:06 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E6=B2=A1=E6=9C=89=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E4=B8=BB=E5=9B=BE=E6=97=B6=E8=87=AA=E5=8A=A8=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SellerDashboard/MyListings/EditDetail/agents.md | 2 ++ .../SellerDashboard/MyListings/EditDetail/index.vue | 10 +--------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/views/SellerDashboard/MyListings/EditDetail/agents.md b/src/views/SellerDashboard/MyListings/EditDetail/agents.md index 55112b27..bc44c503 100644 --- a/src/views/SellerDashboard/MyListings/EditDetail/agents.md +++ b/src/views/SellerDashboard/MyListings/EditDetail/agents.md @@ -50,6 +50,7 @@ When saving, preserve the backend's expected image categories. Confirm backend n - The `main` badge represents the first selected product image, not the most recently selected one. - `firstSelectedIndex` is stored on each `ListingItem` and passed to `ProductImageList.vue`. +- Hydrating detail data must only set `mainProductImage` from explicit `main_product` or `mainProductImage` rows. Never infer it from selected `product` rows. - Selecting a product image should only set `mainProductImage` when no main image is currently tracked by that listing's `firstSelectedIndex`. - Unselecting the current main product image clears `mainProductImage` and resets `firstSelectedIndex`. - Videos can be selected and saved, but they cannot become `mainProductImage`, must not set `firstSelectedIndex`, and must not display the `main` badge. @@ -57,6 +58,7 @@ When saving, preserve the backend's expected image categories. Confirm backend n 中文补充: - `main` 标识只给图片,不给视频。 +- 数据回显时,只有接口明确返回 `main_product` / `mainProductImage` 才能设置主图。不要因为某个 `product` 是已选中状态,就自动把它当成 `mainProductImage` 或显示 `main`。 - 第一次选择视频时可以弹 warning,但视频本身仍然要保持选中;只是不要把它写入 `mainProductImage`,也不要更新 `firstSelectedIndex`。 - 如果先选中视频,再选中图片,图片仍然可以成为第一个主图。 - 如果取消的是当前主图图片,需要清空 `mainProductImage` 和 `firstSelectedIndex`;取消普通图片或视频不应影响主图。 diff --git a/src/views/SellerDashboard/MyListings/EditDetail/index.vue b/src/views/SellerDashboard/MyListings/EditDetail/index.vue index a76419a8..82aa514d 100644 --- a/src/views/SellerDashboard/MyListings/EditDetail/index.vue +++ b/src/views/SellerDashboard/MyListings/EditDetail/index.vue @@ -313,10 +313,6 @@ if (videoItem) listing.prodImageList.push(videoItem) }) - if (!listing.mainProductImage) { - listing.mainProductImage = - listing.prodImageList.find((item) => item.selected && !item.isVideo)?.url || "" - } if (coverFromImageUrl) { listing.coverFrom = resolveCoverSourceFromImageUrl(coverFromImageUrl, listing) } @@ -324,11 +320,7 @@ const mainProductIndex = listing.prodImageList.findIndex( (item) => !item.isVideo && item.url === listing.mainProductImage ) - const selectedIndex = - mainProductIndex === -1 - ? listing.prodImageList.findIndex((item) => item.selected && !item.isVideo) - : mainProductIndex - listing.firstSelectedIndex = selectedIndex === -1 ? null : selectedIndex + listing.firstSelectedIndex = mainProductIndex === -1 ? null : mainProductIndex listing.productImage = listing.prodImageList.map((item) => item.url) listing.apparelSketch = listing.sketchList