修改:去掉重复上传图片
continuous-integration/drone/push Build was killed
continuous-integration/drone/promote/prod Build is passing

This commit is contained in:
Linzm committed 2026-11-04 18:42:25 +08:00
1 parent 4979739521
commit e1da41c2f8
1 file changed
+23 -24
+23 -24
View File
@@ -786,7 +786,8 @@ async function startGenerate(opts: {
userText: string
userImage?: string
mode: 'generate' | 'edit'
file?: File | null
/** 导入阶段已拿到的 upload_id;提交只 confirm,不再调 upload/url */
uploadId: string
sceneProp?: string
}) {
if (remainCount.value <= 0) {
@@ -806,6 +807,14 @@ async function startGenerate(opts: {
return
}
const uploadId = String(opts.uploadId || '').trim()
if (!uploadId) {
showToast(
opts.mode === 'edit' ? config.messages.effectPreparing : config.messages.needPhoto,
)
return
}
const now = new Date()
const time = formatTime(now)
const startedAt = Date.now()
@@ -832,25 +841,10 @@ async function startGenerate(opts: {
isBusy.value = true
pendingFinish.value = null
lastUploadId.value = uploadId
try {
if (!opts.file && !pendingUploadId.value) {
throw new Error(opts.mode === 'edit' ? '缺少可编辑的效果图' : '请先上传照片')
}
// 复用导入阶段的 upload_id;若无则兜底:url+PUT(仍不在这里 classify)
let uploadId = String(pendingUploadId.value || '').trim()
if (!uploadId) {
if (!opts.file) throw new Error(opts.mode === 'edit' ? '缺少可编辑的效果图' : '请先上传照片')
const prepared = await jingdongApi.prepareUpload(opts.file, {
session_id: sid,
purpose: 'origin',
})
uploadId = prepared.uploadId
pendingUploadId.value = uploadId
lastUploadId.value = uploadId
}
// 提交阶段:confirm → imagegen/submit
// 提交阶段:仅 confirm → imagegen/submit(upload/url 已在导入时完成)
await jingdongApi.confirmUpload({
session_id: sid,
upload_id: uploadId,
@@ -948,14 +942,20 @@ function onSend() {
const text = draft.value.trim()
const sceneProp = resolveScenePropFromOrder(orderStat.value, productTitle.value)
// 必须在 resetComposer 之前取出:reset 会清空 pendingUploadId
const uploadId = String(pendingUploadId.value || '').trim()
if (!uploadId) {
showToast(config.messages.uploadingTip)
return
}
if (isEditing.value) {
if (!text) {
showToast(config.messages.needEditText)
return
}
const file = pendingFile.value
const image = pendingPreview.value
if (!file || !image) {
if (!image) {
showToast(config.messages.effectPreparing)
return
}
@@ -964,15 +964,14 @@ function onSend() {
void startGenerate({
userText: text,
mode: 'edit',
file,
uploadId,
sceneProp,
})
return
}
const image = pendingPreview.value
const file = pendingFile.value
if (!file || !image) {
if (!image) {
showToast(config.messages.needPhoto)
return
}
@@ -992,7 +991,7 @@ function onSend() {
userText: sendText,
userImage: sendImage,
mode: 'generate',
file,
uploadId,
sceneProp,
})
}