fix save fail for product photo and sku photo

This commit is contained in:
Timi
2026-09-19 16:29:38 +08:00
parent 77642bcd94
commit 6c488a4731
+15 -6
View File
@@ -662,24 +662,33 @@ async function handleAttachmentSelected(event: Event): Promise<void> {
function buildAttachmentList(): Attachment[] { function buildAttachmentList(): Attachment[] {
return attachmentItemList.value.flatMap(item => { return attachmentItemList.value.flatMap(item => {
if (item.tempFileId) {
return [{
...item.attachment,
attachType: item.attachType || item.attachment?.attachType || "PHOTO",
tempFileId: item.tempFileId,
metadata: item.isSolidColorCover && item.solidColor ? { purpose: SOLID_COLOR_COVER_PURPOSE, color: item.solidColor } : undefined
} as Attachment];
}
if (item.attachment) { if (item.attachment) {
return [{ ...item.attachment, attachType: item.attachType || item.attachment.attachType || "PHOTO" }]; return [{ ...item.attachment, attachType: item.attachType || item.attachment.attachType || "PHOTO" }];
} }
if (item.tempFileId) {
return [{ attachType: item.attachType, tempFileId: item.tempFileId, metadata: item.isSolidColorCover && item.solidColor ? { purpose: SOLID_COLOR_COVER_PURPOSE, color: item.solidColor } : undefined }];
}
return []; return [];
}); });
} }
function buildSkuAttachmentList(photoItemList: PhotoItem[]): Attachment[] { function buildSkuAttachmentList(photoItemList: PhotoItem[]): Attachment[] {
return photoItemList.flatMap(item => { return photoItemList.flatMap(item => {
if (item.tempFileId) {
return [{
...item.attachment,
attachType: item.attachType || item.attachment?.attachType || "PHOTO",
tempFileId: item.tempFileId
} as Attachment];
}
if (item.attachment) { if (item.attachment) {
return [{ ...item.attachment, attachType: item.attachType || item.attachment.attachType || "PHOTO" } as Attachment]; return [{ ...item.attachment, attachType: item.attachType || item.attachment.attachType || "PHOTO" } as Attachment];
} }
if (item.tempFileId) {
return [{ attachType: item.attachType || "PHOTO", tempFileId: item.tempFileId } as Attachment];
}
return []; return [];
}); });
} }