refactor: Discover Router done.
This commit is contained in:
@@ -54,8 +54,10 @@
|
||||
|
||||
<script>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import axios from 'axios';
|
||||
import LoadingStore from '@/stores/loading.js';
|
||||
import AllMapDataStore from '@/stores/allMapData.js';
|
||||
import ConformanceStore from '@/stores/conformance.js';
|
||||
import cytoscapeMap from '@/module/cytoscapeMap.js';
|
||||
import SidebarView from '@/components/Discover/Map/SidebarView.vue';
|
||||
import SidebarState from '@/components/Discover/Map/SidebarState.vue';
|
||||
@@ -359,37 +361,33 @@ export default {
|
||||
},
|
||||
async created() {
|
||||
const routeParams = this.$route.params;
|
||||
const file = this.$route.meta.file;
|
||||
const isCheckPage = this.$route.name.includes('Check');
|
||||
|
||||
// 先 loading 再執行以下程式
|
||||
this.isLoading = true;
|
||||
// Log 檔前往 Map Log 頁, Filter 檔前往 Map Filter 頁
|
||||
switch (routeParams.type) {
|
||||
case 'log':
|
||||
this.logId = routeParams.fileId;
|
||||
this.baseLogId = routeParams.fileId;
|
||||
if(!isCheckPage) {
|
||||
this.logId = routeParams.fileId;
|
||||
this.baseLogId = routeParams.fileId;
|
||||
} else {
|
||||
this.logId = file.parent.id;
|
||||
this.baseLogId = file.parent.id;
|
||||
}
|
||||
break;
|
||||
case 'filter':
|
||||
this.createFilterId = routeParams.fileId;
|
||||
if(!isCheckPage) {
|
||||
this.createFilterId = routeParams.fileId;
|
||||
} else {
|
||||
this.createFilterId = file.parent.id;
|
||||
}
|
||||
// 取得 logID 和上次儲存的 Funnel
|
||||
await this.allMapDataStore.fetchFunnel(this.createFilterId);
|
||||
this.isRuleData = await Array.from(this.temporaryData);
|
||||
this.ruleData = await this.isRuleData.map(e => this.$refs.sidevarFilterRef.setRule(e));
|
||||
break;
|
||||
case 'rule':
|
||||
switch (this.checkType) {
|
||||
case 'log':
|
||||
this.logId = this.checkFileId;
|
||||
this.baseLogId = this.checkFileId;
|
||||
break;
|
||||
case 'filter':
|
||||
this.createFilterId = this.checkFileId;
|
||||
// 取得 logID 和上次儲存的 Funnel
|
||||
await this.allMapDataStore.fetchFunnel(this.createFilterId);
|
||||
this.isRuleData = await Array.from(this.temporaryData);
|
||||
this.ruleData = await this.isRuleData.map(e => this.$refs.sidevarFilterRef.setRule(e));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 取得 logId 後才 call api
|
||||
await this.allMapDataStore.getAllMapData();
|
||||
@@ -424,6 +422,28 @@ export default {
|
||||
this.temporaryData = [];
|
||||
this.postRuleData = [];
|
||||
this.ruleData = [];
|
||||
},
|
||||
async beforeRouteEnter(to, from, next) {
|
||||
const isCheckPage = to.name.includes('Check');
|
||||
|
||||
if (isCheckPage) {
|
||||
const conformanceStore = ConformanceStore();
|
||||
// Save token in Headers.
|
||||
const token = document.cookie.replace(/(?:(?:^|.*;\s*)luciaToken\s*\=\s*([^;]*).*$)|^.*$/, "$1");
|
||||
|
||||
axios.defaults.headers.common['Authorization'] = `Bearer ${token}`;
|
||||
switch (to.params.type) {
|
||||
case 'log':
|
||||
conformanceStore.conformanceLogCreateCheckId = to.params.fileId;
|
||||
break;
|
||||
case 'filter':
|
||||
conformanceStore.conformanceFilterCreateCheckId = to.params.fileId;
|
||||
break;
|
||||
}
|
||||
await conformanceStore.getConformanceReport(true);
|
||||
to.meta.file = conformanceStore.routeFile; // 將 file data 存到 route
|
||||
}
|
||||
next();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user