fix: Files Upload API & Rename API done.
This commit is contained in:
@@ -151,21 +151,19 @@ export default defineStore('filesStore', {
|
||||
uploadloader(); // 進度條
|
||||
try {
|
||||
const response = await axios.post(api, data);
|
||||
this.uploadLogId = response.data.id;
|
||||
Swal.close(); // 關閉進度條
|
||||
this.rename(); // 改檔名
|
||||
|
||||
this.uploadLogId = await response.data.id;
|
||||
await Swal.close(); // 關閉進度條
|
||||
await this.rename(); // 改檔名
|
||||
await uploadSuccess();
|
||||
this.$router.push({name: 'Files'});
|
||||
} catch(error) {
|
||||
console.log('error:', error);
|
||||
if(error.response.status === 422) {
|
||||
uploadFailedSecond(error.response.data.detail[0].type, error.response.data.detail[0].msg);
|
||||
} else {
|
||||
Swal.close(); // 關閉進度條
|
||||
apiError(error, 'Failed to upload the log files.');
|
||||
}
|
||||
} finally {
|
||||
// await this.rename();
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -176,14 +174,15 @@ export default defineStore('filesStore', {
|
||||
*/
|
||||
async rename(type, id, fileName) {
|
||||
// 先判斷有沒有 uploadLogId,有就設定 id 和 type;再判斷檔案型別。
|
||||
let api;
|
||||
let data = {"name": fileName};
|
||||
|
||||
if(this.uploadId && this.uploadFileName) {
|
||||
type = 'log';
|
||||
id = this.uploadLogId;
|
||||
fileName = this.uploadFileName;
|
||||
}
|
||||
|
||||
let api;
|
||||
let data = {"name": fileName};
|
||||
|
||||
switch (type) {
|
||||
case 'log':
|
||||
api = `/api/logs/${id}/name`;
|
||||
|
||||
Reference in New Issue
Block a user