From 800017b78c2dce2676fdf07c6614f15b3e2f726c Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 8 Feb 2026 11:38:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=BE=E5=AE=BD=E4=B8=8A=E4=BC=A0=E5=88=B050?= =?UTF-8?q?MB=E5=B9=B6=E5=8F=96=E6=B6=88=E5=88=86=E8=BE=A8=E7=8E=87?= =?UTF-8?q?=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../settings/admin-settings-client.tsx | 2 +- app/(chat)/api/files/upload/route.ts | 4 +-- components/canvas/CanvasChatPanel.tsx | 4 +-- components/canvas/CanvasWorkspace.tsx | 4 +-- components/canvas/nodes/ImageNode.tsx | 6 ++--- components/image-annotator.tsx | 14 +++++----- components/multimodal-input.tsx | 26 +++++-------------- components/scene-fusion-dialog.tsx | 8 +++--- components/scene-fusion-view.tsx | 8 +++--- 9 files changed, 32 insertions(+), 44 deletions(-) diff --git a/app/(admin)/settings/admin-settings-client.tsx b/app/(admin)/settings/admin-settings-client.tsx index e9acb22..8fddac0 100644 --- a/app/(admin)/settings/admin-settings-client.tsx +++ b/app/(admin)/settings/admin-settings-client.tsx @@ -4445,7 +4445,7 @@ export function AdminSettingsClient() {

• API地址应指向服务根地址,例如: https://techsz.aoscdn.com

• 系统会自动调用 /api/tasks/visual/scale 接口进行变清晰处理

• 支持的图片格式:JPG, JPEG, PNG, BMP, WEBP, TIFF等

-

• 图片大小:不超过20MB,分辨率最大4096x4096

+

• 图片大小:不超过50MB,不限制分辨率(建议按业务需求控制尺寸)

• 返回的链接有效期为1小时,系统会自动下载并存储到S3

diff --git a/app/(chat)/api/files/upload/route.ts b/app/(chat)/api/files/upload/route.ts index f1020d4..77198dd 100644 --- a/app/(chat)/api/files/upload/route.ts +++ b/app/(chat)/api/files/upload/route.ts @@ -85,8 +85,8 @@ async function optimizeImage(buffer: Buffer, mimeType: string): Promise const FileSchema = z.object({ file: z .instanceof(Blob) - .refine((file) => file.size <= 20 * 1024 * 1024, { - message: "File size should be less than 20MB", + .refine((file) => file.size <= 50 * 1024 * 1024, { + message: "File size should be less than 50MB", }) // Update the file type based on the kind of files you want to accept .refine((file) => ["image/jpeg", "image/png", "image/webp"].includes(file.type), { diff --git a/components/canvas/CanvasChatPanel.tsx b/components/canvas/CanvasChatPanel.tsx index 257dbc5..dea85e0 100644 --- a/components/canvas/CanvasChatPanel.tsx +++ b/components/canvas/CanvasChatPanel.tsx @@ -932,8 +932,8 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF continue; } - if (file.size > 20 * 1024 * 1024) { - toast.error('图片大小不能超过 20MB'); + if (file.size > 50 * 1024 * 1024) { + toast.error('图片大小不能超过 50MB'); continue; } diff --git a/components/canvas/CanvasWorkspace.tsx b/components/canvas/CanvasWorkspace.tsx index c5be68c..f92134b 100644 --- a/components/canvas/CanvasWorkspace.tsx +++ b/components/canvas/CanvasWorkspace.tsx @@ -283,8 +283,8 @@ export function CanvasWorkspace() { for (let index = 0; index < files.length; index++) { const file = files[index]; - if (file.size > 20 * 1024 * 1024) { - toast.error("图片大小不能超过 20MB"); + if (file.size > 50 * 1024 * 1024) { + toast.error("图片大小不能超过 50MB"); continue; } diff --git a/components/canvas/nodes/ImageNode.tsx b/components/canvas/nodes/ImageNode.tsx index b06e91c..15ca08c 100644 --- a/components/canvas/nodes/ImageNode.tsx +++ b/components/canvas/nodes/ImageNode.tsx @@ -560,9 +560,9 @@ export function ImageNode({ node, isSelected }: ImageNodeProps) { return; } - // 验证文件大小 (20MB) - if (file.size > 20 * 1024 * 1024) { - toast.error('图片大小不能超过 20MB'); + // 验证文件大小 (50MB) + if (file.size > 50 * 1024 * 1024) { + toast.error('图片大小不能超过 50MB'); return; } diff --git a/components/image-annotator.tsx b/components/image-annotator.tsx index d6d861a..9e7427f 100644 --- a/components/image-annotator.tsx +++ b/components/image-annotator.tsx @@ -105,8 +105,8 @@ export function ImageAnnotator({ imageUrl, onConfirm, onCancel, initialResizeMod toast.error("请上传图片文件"); return; } - if (file.size > 10 * 1024 * 1024) { - toast.error("图片大小不能超过 10MB"); + if (file.size > 50 * 1024 * 1024) { + toast.error("图片大小不能超过 50MB"); return; } @@ -160,8 +160,8 @@ export function ImageAnnotator({ imageUrl, onConfirm, onCancel, initialResizeMod const file = item.getAsFile(); if (!file) continue; - if (file.size > 10 * 1024 * 1024) { - toast.error("图片大小不能超过 10MB"); + if (file.size > 50 * 1024 * 1024) { + toast.error("图片大小不能超过 50MB"); return; } @@ -303,8 +303,8 @@ export function ImageAnnotator({ imageUrl, onConfirm, onCancel, initialResizeMod const handleImageUpload = async (e: React.ChangeEvent) => { const file = e.target.files?.[0]; if (file) { - if (file.size > 10 * 1024 * 1024) { - toast.error("图片大小不能超过 10MB"); + if (file.size > 50 * 1024 * 1024) { + toast.error("图片大小不能超过 50MB"); e.target.value = ""; return; } @@ -1763,7 +1763,7 @@ export function ImageAnnotator({ imageUrl, onConfirm, onCancel, initialResizeMod

上传图片以开始编辑

拖拽图片到此处、点击选择或 Ctrl+V 粘贴

-

支持 JPG, PNG, WebP 格式,最大 10MB

+

支持 JPG, PNG, WebP 格式,最大 50MB

=> { + // 不限制分辨率,优先保留原图质量 + const compressImage = useCallback(async (file: File, maxSizeMB = 50): Promise => { // 如果不是图片,直接返回 if (!file.type.startsWith('image/')) { return file; @@ -265,14 +266,12 @@ function PureMultimodalInput({ img.onload = () => { URL.revokeObjectURL(objectUrl); - const width = img.width; - const height = img.height; - const maxDimension = 4096; // 4K + const width = img.width; + const height = img.height; - // ✅ 免检通道:如果图片小于 5MB 且分辨率在 4K 以内,直接返回原图 - // 这样可以避免不必要的压缩导致的画质损失 - if (file.size <= 5 * 1024 * 1024 && width <= maxDimension && height <= maxDimension) { - console.log(`[压缩] 免检通过: ${(file.size / 1024 / 1024).toFixed(2)}MB, ${width}x${height} (小于5MB且小于4K),使用原图`); + // ✅ 免检通道:50MB以内直接使用原图,避免分辨率与画质损失 + if (file.size <= maxSizeMB * 1024 * 1024) { + console.log(`[压缩] 免检通过: ${(file.size / 1024 / 1024).toFixed(2)}MB, ${width}x${height},使用原图`); resolve(file); return; } @@ -281,17 +280,6 @@ function PureMultimodalInput({ let newWidth = width; let newHeight = height; - // 计算缩放比例以达到目标大小 - if (newWidth > maxDimension || newHeight > maxDimension) { - if (newWidth > newHeight) { - newHeight = (newHeight / newWidth) * maxDimension; - newWidth = maxDimension; - } else { - newWidth = (newWidth / newHeight) * maxDimension; - newHeight = maxDimension; - } - } - canvas.width = newWidth; canvas.height = newHeight; diff --git a/components/scene-fusion-dialog.tsx b/components/scene-fusion-dialog.tsx index 7f35d1d..a735a3f 100644 --- a/components/scene-fusion-dialog.tsx +++ b/components/scene-fusion-dialog.tsx @@ -82,8 +82,8 @@ export function SceneFusionDialog({ open, onOpenChange }: SceneFusionDialogProps const file = e.target.files?.[0]; if (!file) return; - if (file.size > 10 * 1024 * 1024) { - toast.error("图片大小不能超过 10MB"); + if (file.size > 50 * 1024 * 1024) { + toast.error("图片大小不能超过 50MB"); return; } @@ -107,8 +107,8 @@ export function SceneFusionDialog({ open, onOpenChange }: SceneFusionDialogProps } files.forEach(file => { - if (file.size > 10 * 1024 * 1024) { - toast.error(`图片 ${file.name} 大小不能超过 10MB`); + if (file.size > 50 * 1024 * 1024) { + toast.error(`图片 ${file.name} 大小不能超过 50MB`); return; } diff --git a/components/scene-fusion-view.tsx b/components/scene-fusion-view.tsx index 249a458..278a223 100644 --- a/components/scene-fusion-view.tsx +++ b/components/scene-fusion-view.tsx @@ -138,8 +138,8 @@ export function SceneFusionView({ onBack, initialProductImage, initialProductNam const file = e.target.files?.[0]; if (!file) return; - if (file.size > 10 * 1024 * 1024) { - toast.error("图片大小不能超过 10MB"); + if (file.size > 50 * 1024 * 1024) { + toast.error("图片大小不能超过 50MB"); return; } @@ -177,8 +177,8 @@ export function SceneFusionView({ onBack, initialProductImage, initialProductNam } files.forEach(file => { - if (file.size > 10 * 1024 * 1024) { - toast.error(`图片 ${file.name} 大小不能超过 10MB`); + if (file.size > 50 * 1024 * 1024) { + toast.error(`图片 ${file.name} 大小不能超过 50MB`); return; }