perf: 上传逻辑优化
This commit is contained in:
@ -11,7 +11,11 @@ import {
|
|||||||
Message as AMessage,
|
Message as AMessage,
|
||||||
Textarea,
|
Textarea,
|
||||||
} from '@arco-design/web-vue';
|
} from '@arco-design/web-vue';
|
||||||
import { getTemplateUrlWriter, postWorksByLinkWriter, postWorksByFileWriter } from '@/api/all/generationWorkshop-writer.ts';
|
import {
|
||||||
|
getTemplateUrlWriter,
|
||||||
|
postWorksByLinkWriter,
|
||||||
|
postWorksByFileWriter,
|
||||||
|
} from '@/api/all/generationWorkshop-writer.ts';
|
||||||
import { slsWithCatch } from '@/utils/stroage.ts';
|
import { slsWithCatch } from '@/utils/stroage.ts';
|
||||||
|
|
||||||
import TextOverTips from '@/components/text-over-tips';
|
import TextOverTips from '@/components/text-over-tips';
|
||||||
@ -113,26 +117,22 @@ export default {
|
|||||||
|
|
||||||
// 文件上传处理
|
// 文件上传处理
|
||||||
const handleUpload = async (option) => {
|
const handleUpload = async (option) => {
|
||||||
try {
|
taskStatus.value = TASK_STATUS.LOADING;
|
||||||
taskStatus.value = TASK_STATUS.LOADING;
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
fileItem: { file },
|
fileItem: { file },
|
||||||
} = option;
|
} = option;
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
const { code, data } = await postWorksByFileWriter(formData, {
|
const { code, data } = await postWorksByFileWriter(formData, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
taskStatus.value = TASK_STATUS.SUCCESS;
|
taskStatus.value = TASK_STATUS.SUCCESS;
|
||||||
works.value = data;
|
works.value = data;
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
taskStatus.value = TASK_STATUS.DEFAULT;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user