mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2024-11-01 14:10:27 +08:00
优化 upload 模块
This commit is contained in:
parent
bd0e804867
commit
d2a55fe8f4
@ -249,6 +249,15 @@ const isAdd = computed(() => {
|
|||||||
return props.multiple ? limit - list.value.length > 0 : list.value.length == 0;
|
return props.multiple ? limit - list.value.length > 0 : list.value.length == 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 获取类型
|
||||||
|
function getType(path: string) {
|
||||||
|
if (props.type == "image") {
|
||||||
|
return "image";
|
||||||
|
} else {
|
||||||
|
return fileType(path).value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 上传前
|
// 上传前
|
||||||
function beforeUpload(file: any, item?: Item) {
|
function beforeUpload(file: any, item?: Item) {
|
||||||
if (file.size / 1024 / 1024 >= limitSize) {
|
if (file.size / 1024 / 1024 >= limitSize) {
|
||||||
@ -257,7 +266,7 @@ function beforeUpload(file: any, item?: Item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const d = {
|
const d = {
|
||||||
type: fileType(file.name).value,
|
type: getType(file.name),
|
||||||
preload: "",
|
preload: "",
|
||||||
progress: 0,
|
progress: 0,
|
||||||
url: "",
|
url: "",
|
||||||
@ -446,7 +455,7 @@ watch(
|
|||||||
return item;
|
return item;
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
type: fileType(url).value,
|
type: getType(url),
|
||||||
progress: 0,
|
progress: 0,
|
||||||
uid: uuid(),
|
uid: uuid(),
|
||||||
url,
|
url,
|
||||||
|
Loading…
Reference in New Issue
Block a user