refactor: upload component (wip)

This commit is contained in:
dap
2024-10-10 14:21:16 +08:00
parent d10f950b6b
commit 26ee8e28ea
3 changed files with 14 additions and 11 deletions

View File

@@ -16,7 +16,7 @@ import { checkFileType } from './helper';
import { UploadResultStatus } from './typing';
import { useUploadType } from './use-upload';
defineOptions({ name: 'FileUpload' });
defineOptions({ name: 'FileUpload', inheritAttrs: false });
const props = withDefaults(
defineProps<{
@@ -95,7 +95,6 @@ watch(
return null;
}) as UploadProps['fileList'];
}
emit('update:value', value);
if (!isFirstRender.value) {
emit('change', value);
isFirstRender.value = false;
@@ -169,6 +168,10 @@ function getValue() {
if (item?.response && props?.resultField) {
return item?.response?.[props.resultField];
}
// 适用于已经有图片 回显的情况 会默认在init处理为{url: 'xx'}
if (item?.url) {
return item.url;
}
// 注意这里取的key为 url
return item?.response?.url;
});

View File

@@ -16,7 +16,7 @@ import { checkFileType } from './helper';
import { UploadResultStatus } from './typing';
import { useUploadType } from './use-upload';
defineOptions({ name: 'ImageUpload' });
defineOptions({ name: 'ImageUpload', inheritAttrs: false });
const props = withDefaults(
defineProps<{
@@ -106,7 +106,6 @@ watch(
return null;
}) as UploadProps['fileList'];
}
emit('update:value', value);
if (!isFirstRender.value) {
emit('change', value);
isFirstRender.value = false;