fix
parent
b49e43f1b7
commit
7b697b099b
|
|
@ -59,9 +59,17 @@ export default function AttachmentUpload({ name, label, disabled = false, maxCou
|
||||||
action={`${window.process.env.app.API_HOST}/safetyEval/file/upload`}
|
action={`${window.process.env.app.API_HOST}/safetyEval/file/upload`}
|
||||||
beforeUpload={(file) => {
|
beforeUpload={(file) => {
|
||||||
if (!accept) return true;
|
if (!accept) return true;
|
||||||
const exts = accept.split(",").map((e) => e.trim().toLowerCase());
|
const rules = accept.split(",").map((e) => e.trim().toLowerCase());
|
||||||
const ext = "." + file.name.split(".").pop().toLowerCase();
|
const ext = "." + file.name.split(".").pop().toLowerCase();
|
||||||
if (!exts.includes(ext)) {
|
const matchExt = rules.includes(ext);
|
||||||
|
const matchMime = rules.some((r) => {
|
||||||
|
if (r.endsWith("/*")) {
|
||||||
|
const prefix = r.slice(0, -1);
|
||||||
|
return file.type && file.type.toLowerCase().startsWith(prefix);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
if (!matchExt && !matchMime) {
|
||||||
message.error(`仅支持 ${accept} 格式文件`);
|
message.error(`仅支持 ${accept} 格式文件`);
|
||||||
return Upload.LIST_IGNORE;
|
return Upload.LIST_IGNORE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue