feat: Upload no uploadId need to next to files page.

This commit is contained in:
chiayin
2024-01-08 12:56:34 +08:00
parent 080eb6ae95
commit 01d712e487
3 changed files with 13 additions and 7 deletions

View File

@@ -27,5 +27,5 @@ export default async function apiError(error, toastMessage) {
await delay(1000); await delay(1000);
loading.isLoading = false; loading.isLoading = false;
await delay(500); await delay(500);
$toast.default(toastMessage, {position: 'bottom'}); $toast.default('Please upload your file.', {position: 'bottom'});
} }

View File

@@ -177,8 +177,6 @@
this.store.fetchAllFiles(); this.store.fetchAllFiles();
this.isLoading = false; this.isLoading = false;
}, },
beforeUnmount() {
}
} }
</script> </script>

View File

@@ -293,7 +293,6 @@ export default {
}, },
}, },
mounted() { mounted() {
// 要有 uploadID 才能進來
// 只監聽第一次 // 只監聽第一次
let unwatch = this.$watch('fileName', (newValue) => { let unwatch = this.$watch('fileName', (newValue) => {
if (newValue) { if (newValue) {
@@ -307,7 +306,7 @@ export default {
); );
this.isInform = true; // 初始為藍字提示 this.isInform = true; // 初始為藍字提示
this.showEdit = true; this.showEdit = true;
this.filesStore.getUploadDetail(); if(this.uploadId) this.filesStore.getUploadDetail();
unwatch(); unwatch();
this.isLoading = false; this.isLoading = false;
}, },
@@ -315,7 +314,16 @@ export default {
// 離開頁面要刪 uploadID // 離開頁面要刪 uploadID
this.uploadId = null; this.uploadId = null;
this.uploadFileName = null; this.uploadFileName = null;
} },
beforeRouteEnter(to, from, next){
// 要有 uploadID 才能進來
next(vm => {
if(vm.uploadId == null) {
vm.$router.push({name: 'Files', replace: true});
vm.$toast.default('Please upload your file.', {position: 'bottom'});
return
}
})
},
} }
// beforeRouteUpdate(){}
</script> </script>