reactor:【INFRA】文件上传 api,增加 directory 参数,去除 path 参数,并支持按照日期分目录、文件名不再使用 sha256 而是时间戳

This commit is contained in:
YunaiV
2025-05-02 19:59:05 +08:00
parent 368f7c753f
commit 91d70b41cb
8 changed files with 41 additions and 34 deletions

View File

@@ -28,6 +28,8 @@ const props = withDefaults(
file: File,
onUploadProgress?: AxiosProgressEvent,
) => Promise<AxiosResponse<any>>;
// 上传的目录
directory?: string;
disabled?: boolean;
helpText?: string;
// 最大数量的文件Infinity不限制
@@ -44,13 +46,14 @@ const props = withDefaults(
}>(),
{
value: () => [],
directory: undefined,
disabled: false,
helpText: '',
maxSize: 2,
maxNumber: 1,
accept: () => [],
multiple: false,
api: useUpload().httpRequest,
api: undefined,
resultField: '',
showDescription: false,
},
@@ -141,10 +144,9 @@ const beforeUpload = async (file: File) => {
};
async function customRequest(info: UploadRequestOption<any>) {
const { api } = props;
let { api } = props;
if (!api || !isFunction(api)) {
console.warn('upload api must exist and be a function');
return;
api = useUpload(props.directory).httpRequest;
}
try {
// 上传文件