From ec48c8859b0c2bd2eef2f1f32a2dae730b410c9a Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 25 Oct 2025 10:56:33 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E3=80=90ele=E3=80=91=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/upload/image-upload.vue | 37 +++++++++---------- .../src/views/system/oauth2/client/data.ts | 2 - 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/apps/web-ele/src/components/upload/image-upload.vue b/apps/web-ele/src/components/upload/image-upload.vue index e8cc6a889..322c2cde1 100644 --- a/apps/web-ele/src/components/upload/image-upload.vue +++ b/apps/web-ele/src/components/upload/image-upload.vue @@ -11,7 +11,7 @@ import type { UploadListType } from './typing'; import type { AxiosProgressEvent } from '#/api/infra/file'; -import { nextTick, ref, toRefs, watch } from 'vue'; +import { ref, toRefs, watch } from 'vue'; import { IconifyIcon } from '@vben/icons'; import { $t } from '@vben/locales'; @@ -25,6 +25,7 @@ import { useUpload, useUploadType } from './use-upload'; defineOptions({ name: 'ImageUpload', inheritAttrs: false }); +// TODO @xingyu:这个要不要抽时间看看,upload 组件,和 antd 要不要进一步对齐下;(主要是代码风格。微信沟通~~~) const props = withDefaults( defineProps<{ // 根据后缀,或者其他 @@ -208,6 +209,20 @@ async function customRequest(options: UploadRequestOptions) { } as unknown as UploadProgressEvent); }; const res = await api?.(options.file, progressEvent); + + // TODO @xingyu:看看有没更好的实现代码。 + // 更新 fileList 中对应文件的 URL 为服务器返回的真实 URL + const uploadedFile = fileList.value.find( + (file) => file.uid === (options.file as any).uid, + ); + if (uploadedFile) { + const responseData = res?.data || res; + uploadedFile.url = + props.resultField && responseData[props.resultField] + ? responseData[props.resultField] + : responseData.url || responseData; + } + options.onSuccess!(res); ElMessage.success($t('ui.upload.uploadSuccess')); @@ -237,21 +252,6 @@ function getValue() { } return list; } - -// 编辑按钮:触发文件选择 -const triggerEdit = () => { - if (props.disabled) return; - // 只查找当前 upload-box 下的 input - nextTick(() => { - const uploadBox = document.querySelector('.upload-box'); - if (uploadBox) { - const input = uploadBox.querySelector( - 'input[type="file"]', - ) as HTMLInputElement | null; - if (input) input.click(); - } - }); -}; +
{{ getStringAccept }}
diff --git a/apps/web-ele/src/views/system/oauth2/client/data.ts b/apps/web-ele/src/views/system/oauth2/client/data.ts index 0df5f9b92..5705cb06c 100644 --- a/apps/web-ele/src/views/system/oauth2/client/data.ts +++ b/apps/web-ele/src/views/system/oauth2/client/data.ts @@ -147,7 +147,6 @@ export function useFormSchema(): VbenFormSchema[] { componentProps: { placeholder: '请输入权限', }, - rules: 'required', }, { fieldName: 'resourceIds', @@ -156,7 +155,6 @@ export function useFormSchema(): VbenFormSchema[] { componentProps: { placeholder: '请输入资源', }, - rules: 'required', }, { fieldName: 'additionalInformation',