fix: 支持HEIC格式上传 + 压缩目标调小
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 4s
Test / build-check (push) Successful in 3s
PR Preview / test (pull_request) Successful in 5s
Test / e2e-test (push) Failing after 56s
PR Preview / deploy-preview (pull_request) Successful in 1m0s
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 4s
Test / build-check (push) Successful in 3s
PR Preview / test (pull_request) Successful in 5s
Test / e2e-test (push) Failing after 56s
PR Preview / deploy-preview (pull_request) Successful in 1m0s
- HEIC/HEIF格式自动转换为JPEG后压缩 - 压缩目标调小确保不超后端限制(QR/logo 300KB,背景 600KB) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
7
frontend/package-lock.json
generated
7
frontend/package-lock.json
generated
@@ -9,6 +9,7 @@
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"exceljs": "^4.4.0",
|
||||
"heic2any": "^0.0.4",
|
||||
"html2canvas": "^1.4.1",
|
||||
"pinia": "^2.3.1",
|
||||
"vue": "^3.5.32",
|
||||
@@ -2871,6 +2872,12 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/heic2any": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/heic2any/-/heic2any-0.0.4.tgz",
|
||||
"integrity": "sha512-3lLnZiDELfabVH87htnRolZ2iehX9zwpRyGNz22GKXIu0fznlblf0/ftppXKNqS26dqFSeqfIBhAmAj/uSp0cA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/html-encoding-sniffer": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-6.0.0.tgz",
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"exceljs": "^4.4.0",
|
||||
"heic2any": "^0.0.4",
|
||||
"html2canvas": "^1.4.1",
|
||||
"pinia": "^2.3.1",
|
||||
"vue": "^3.5.32",
|
||||
|
||||
@@ -573,9 +573,16 @@ function checkSquare(base64) {
|
||||
}
|
||||
|
||||
async function handleUpload(type, event) {
|
||||
const file = event.target.files[0]
|
||||
let file = event.target.files[0]
|
||||
if (!file) return
|
||||
try {
|
||||
// Convert HEIC/HEIF to JPEG
|
||||
if (file.name.toLowerCase().match(/\.hei[cf]$/)) {
|
||||
ui.showToast('正在转换HEIC格式...')
|
||||
const heic2any = (await import('heic2any')).default
|
||||
const blob = await heic2any({ blob: file, toType: 'image/jpeg', quality: 0.8 })
|
||||
file = new File([blob], file.name.replace(/\.hei[cf]$/i, '.jpg'), { type: 'image/jpeg' })
|
||||
}
|
||||
let base64 = await readFileAsBase64(file)
|
||||
|
||||
// QR: check if square, offer to crop
|
||||
@@ -590,8 +597,8 @@ async function handleUpload(type, event) {
|
||||
}
|
||||
}
|
||||
|
||||
const maxSize = type === 'bg' ? 1000000 : 500000
|
||||
const maxDim = type === 'bg' ? 1200 : 800
|
||||
const maxSize = type === 'bg' ? 600000 : 300000
|
||||
const maxDim = type === 'bg' ? 1000 : 600
|
||||
base64 = await compressImage(base64, maxSize, maxDim)
|
||||
const fieldMap = { logo: 'brand_logo', bg: 'brand_bg', qr: 'qr_code' }
|
||||
const field = fieldMap[type]
|
||||
|
||||
Reference in New Issue
Block a user