mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2025-12-13 22:32:49 +00:00
优化
This commit is contained in:
parent
1397e033b4
commit
d24441d628
@ -48,7 +48,8 @@ function open() {
|
|||||||
collapseTags: true,
|
collapseTags: true,
|
||||||
collapseTagsTooltip: true,
|
collapseTagsTooltip: true,
|
||||||
props: {
|
props: {
|
||||||
label: 'name'
|
label: 'name',
|
||||||
|
children: '_children'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,9 +54,7 @@ export function useUpload() {
|
|||||||
// 上传进度
|
// 上传进度
|
||||||
let progress = 0;
|
let progress = 0;
|
||||||
|
|
||||||
// 上传
|
const reqData = {
|
||||||
await service
|
|
||||||
.request({
|
|
||||||
url: host,
|
url: host,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -64,14 +62,23 @@ export function useUpload() {
|
|||||||
Authorization: isLocal ? user.token : null
|
Authorization: isLocal ? user.token : null
|
||||||
},
|
},
|
||||||
timeout: 600000,
|
timeout: 600000,
|
||||||
data: fd,
|
data: file,
|
||||||
onUploadProgress(e: AxiosProgressEvent) {
|
onUploadProgress(e: AxiosProgressEvent) {
|
||||||
progress = e.total ? Math.floor((e.loaded / e.total) * 100) : 0;
|
progress = e.total ? Math.floor((e.loaded / e.total) * 100) : 0;
|
||||||
onProgress?.(progress);
|
onProgress?.(progress);
|
||||||
},
|
},
|
||||||
proxy: isLocal,
|
proxy: isLocal,
|
||||||
NProgress: false
|
NProgress: false
|
||||||
})
|
};
|
||||||
|
|
||||||
|
if (type == 'minio') {
|
||||||
|
reqData.headers['Content-Type'] = file.type;
|
||||||
|
reqData.method = 'PUT';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 上传
|
||||||
|
await service
|
||||||
|
.request(reqData as any)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (progress != 100) {
|
if (progress != 100) {
|
||||||
onProgress?.(100);
|
onProgress?.(100);
|
||||||
@ -106,7 +113,7 @@ export function useUpload() {
|
|||||||
} else {
|
} else {
|
||||||
service.base.comm
|
service.base.comm
|
||||||
.upload(
|
.upload(
|
||||||
type == 'aws'
|
['aws', 'minio'].includes(type)
|
||||||
? {
|
? {
|
||||||
key
|
key
|
||||||
}
|
}
|
||||||
@ -150,6 +157,12 @@ export function useUpload() {
|
|||||||
data: res.fields
|
data: res.fields
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
next({
|
||||||
|
host: res.url
|
||||||
|
});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(reject);
|
.catch(reject);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user