Router: change /Discover to /Discover/map/type/filterId

This commit is contained in:
chiayin
2023-06-16 17:13:59 +08:00
parent 07b35fcce0
commit af1f8f3016
20 changed files with 121 additions and 57 deletions

View File

@@ -27,17 +27,17 @@ export default {
const loadingStore = LoadingStore();
const allMapDataStore = AllMapDataStore();
const { checkLogin } = loginStore;
const { tempFilterId, createFilterId, temporaryData, postRuleData } = storeToRefs(allMapDataStore);
const { tempFilterId, createFilterId, temporaryData, postRuleData, ruleData } = storeToRefs(allMapDataStore);
return { checkLogin, loadingStore, temporaryData, tempFilterId, createFilterId, postRuleData, allMapDataStore };
return { checkLogin, loadingStore, temporaryData, tempFilterId, createFilterId, postRuleData, ruleData, allMapDataStore };
},
watch: {
$route: function(to, from) {
// 離開 DiscoverLog 頁要將 Funnel 的規則刪除, DiscoverFilter 會帶上次儲存的 Funnel, 所以不用
if(to.name !== 'DiscoverLog') {
// 離開 Map Log 頁要將 Funnel 的規則刪除, Map Filter 會帶上次儲存的 Funnel, 所以不用做
if(from.name === 'Map' && from.params.type === 'log') {
this.tempFilterId = null;
this.temporaryData = []
this.postRuleData = []
this.temporaryData = [];
this.postRuleData = [];
}
}
},
@@ -61,8 +61,8 @@ export default {
},
beforeRouteUpdate(to, from, next) {
// 離開 Discover 頁時判斷是否有無資料和需要存檔
if ((from.name === 'DiscoverLog' || from.name === 'DiscoverFilter') && this.tempFilterId) {
leaveFilter(next, this.allMapDataStore.addFilterId)
if ((from.name === 'Map') && this.tempFilterId) {
leaveFilter(next, this.allMapDataStore.addFilterId, to.path)
} else {
next();
}