From 915d46d25e5a882be2e2aeeb52cc53c88848bb9d Mon Sep 17 00:00:00 2001 From: "yuan.ji" <961999367@qq.com> Date: Mon, 19 Jan 2026 17:18:49 +0800 Subject: [PATCH] =?UTF-8?q?perf(antd=20upload=20params):=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E7=BB=84=E4=BB=B6=E5=8F=82=E6=95=B0=E5=8F=96=E5=80=BC?= =?UTF-8?q?=20=E7=A1=AE=E4=BF=9D=E4=B8=8D=E5=90=8C=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E9=85=8D=E7=BD=AE=E5=8F=82=E6=95=B0=E5=8F=AF?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- playground/src/adapter/component/index.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/playground/src/adapter/component/index.ts b/playground/src/adapter/component/index.ts index 7fdb1434a..883dc8985 100644 --- a/playground/src/adapter/component/index.ts +++ b/playground/src/adapter/component/index.ts @@ -376,6 +376,9 @@ const withPreviewUpload = () => { const previewVisible = ref(false); const placeholder = attrs?.placeholder || $t(`ui.placeholder.upload`); + const maxSize = attrs?.maxSize || attrs?.['max-size'] || undefined; + const aspectRatio = + attrs?.aspectRatio || attrs?.['aspect-ratio'] || undefined; const listType = attrs?.listType || attrs?.['list-type'] || 'text'; @@ -387,8 +390,8 @@ const withPreviewUpload = () => { file: UploadFile, originFileList: Array, ) => { - if (attrs.maxSize && (file.size || 0) / 1024 / 1024 > attrs.maxSize) { - message.error($t('ui.formRules.sizeLimit', [attrs.maxSize])); + if (maxSize && (file.size || 0) / 1024 / 1024 > maxSize) { + message.error($t('ui.formRules.sizeLimit', [maxSize])); file.status = 'removed'; return false; } @@ -401,7 +404,7 @@ const withPreviewUpload = () => { ) { file.status = 'removed'; // antd Upload组件问题 file参数获取的是UploadFile类型对象无法取到File类型 所以通过originFileList[0]获取 - const blob = await cropImage(originFileList[0], attrs.aspectRatio); + const blob = await cropImage(originFileList[0], aspectRatio); return new Promise((resolve, reject) => { if (!blob) { return reject(new Error($t('ui.crop.errorTip')));