修改:下单页面优化
continuous-integration/drone/push Build was killed
continuous-integration/drone/promote/prod Build is passing

This commit is contained in:
Linzm committed 2026-11-03 15:30:19 +08:00
1 parent add2409f1f
commit 6dd4b4a724
7 files changed
+325 -49

No files matched your search

+22 -24
View File
@@ -132,6 +132,7 @@ import {
type ImageInspect,
} from '@/services/jingdong/image-inspect'
import { flyImageToRect, rectFromElement, type FlyRect } from '@/utils/fly-image'
import { downloadFallbackTip, downloadImageCompat } from '@/utils/jingdong-download'
import { friendlyError } from '@/utils/jingdong-error'
import {
productTitleSpecFromOrder,
@@ -497,33 +498,30 @@ function previewImages(images: string[], startPosition = 0) {
}
async function downloadImage(url: string) {
const href = String(url || '').trim()
if (!href) {
showToast(config.messages.downloadFail)
return
}
try {
const res = await fetch(url)
const blob = await res.blob()
const objectUrl = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = objectUrl
a.download = `suwa-figure-${Date.now()}.png`
document.body.appendChild(a)
a.click()
a.remove()
URL.revokeObjectURL(objectUrl)
showToast(config.messages.downloadOk)
} catch {
// 跨域或本地资源失败时直接打开新窗口兜底
try {
const a = document.createElement('a')
a.href = url
a.target = '_blank'
a.rel = 'noopener'
a.download = `suwa-figure-${Date.now()}.png`
document.body.appendChild(a)
a.click()
a.remove()
const outcome = await downloadImageCompat(href, `suwa-figure-${Date.now()}.png`)
if (outcome === 'saved') {
showToast(config.messages.downloadOk)
} catch (error) {
showToast(friendlyError(error, 'download', config.messages.downloadFail))
return
}
if (outcome === 'opened') {
showToast({
message: downloadFallbackTip() || config.messages.downloadOpened,
duration: 3600,
})
return
}
showToast({ message: config.messages.downloadFail, duration: 3200 })
} catch (error) {
showToast({
message: friendlyError(error, 'download', config.messages.downloadFail),
duration: 3200,
})
}
}