mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2024-11-01 14:10:27 +08:00
解决 cl-upload 上传进度丢失问题
This commit is contained in:
parent
2a2578a85a
commit
b472769132
@ -490,6 +490,10 @@ defineExpose({
|
|||||||
|
|
||||||
&__file {
|
&__file {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
|
&-btn {
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__list {
|
&__list {
|
||||||
|
@ -66,6 +66,9 @@ export function useUpload() {
|
|||||||
// 文件
|
// 文件
|
||||||
fd.append("file", file);
|
fd.append("file", file);
|
||||||
|
|
||||||
|
// 上传进度
|
||||||
|
let progress = 0;
|
||||||
|
|
||||||
// 上传
|
// 上传
|
||||||
await service
|
await service
|
||||||
.request({
|
.request({
|
||||||
@ -78,16 +81,17 @@ export function useUpload() {
|
|||||||
timeout: 600000,
|
timeout: 600000,
|
||||||
data: fd,
|
data: fd,
|
||||||
onUploadProgress(e: AxiosProgressEvent) {
|
onUploadProgress(e: AxiosProgressEvent) {
|
||||||
const progress = e.total
|
progress = e.total ? Math.floor((e.loaded / e.total) * 100) : 0;
|
||||||
? Math.floor((e.loaded / e.total) * 100)
|
|
||||||
: 0;
|
|
||||||
|
|
||||||
onProgress?.(progress);
|
onProgress?.(progress);
|
||||||
},
|
},
|
||||||
proxy: isLocal,
|
proxy: isLocal,
|
||||||
NProgress: false
|
NProgress: false
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
if (progress != 100) {
|
||||||
|
onProgress?.(100);
|
||||||
|
}
|
||||||
|
|
||||||
key = encodeURIComponent(key);
|
key = encodeURIComponent(key);
|
||||||
|
|
||||||
let url = "";
|
let url = "";
|
||||||
|
Loading…
Reference in New Issue
Block a user