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