refactor: Conformance Router - FILES page to Confomance page router refresh the page done.

This commit is contained in:
chiayin
2024-03-15 18:10:25 +08:00
parent 49b0e462a1
commit bc3e20abd0
3 changed files with 23 additions and 12 deletions

View File

@@ -149,6 +149,7 @@ export default {
}, },
async mounted() { async mounted() {
let params = this.$route.params; let params = this.$route.params;
let parent = this.$route.meta.parent;
switch (params.type) { switch (params.type) {
case 'log': case 'log':
@@ -158,12 +159,12 @@ export default {
this.createFilterId = params.fileId; this.createFilterId = params.fileId;
break; break;
case 'rule': case 'rule':
switch (params.checkType) { switch (parent.type) {
case 'log': case 'log':
this.logId = params.checkFileId; this.logId = parent.id;
break; break;
case 'filter': case 'filter':
this.createFilterId = params.checkFileId; this.createFilterId = parent.id;
} }
break; break;
} }

View File

@@ -68,6 +68,9 @@ const routes = [
path: "/discover/conformance/:type/:fileId", path: "/discover/conformance/:type/:fileId",
name: "Conformance", name: "Conformance",
component: Conformance, component: Conformance,
mate: {
parent: {}
}
}, },
// { // {
// // type: rule(名稱待討論) // // type: rule(名稱待討論)

View File

@@ -15,6 +15,7 @@ import ConformanceStore from '@/stores/conformance.js';
import StatusBar from '@/components/Discover/StatusBar.vue'; import StatusBar from '@/components/Discover/StatusBar.vue';
import ConformanceResults from '@/components/Discover/Conformance/ConformanceResults.vue'; import ConformanceResults from '@/components/Discover/Conformance/ConformanceResults.vue';
import ConformanceSidebar from '@/components/Discover/Conformance/ConformanceSidebar.vue'; import ConformanceSidebar from '@/components/Discover/Conformance/ConformanceSidebar.vue';
import axios from 'axios';
export default { export default {
setup() { setup() {
@@ -34,16 +35,8 @@ export default {
}, },
async created() { async created() {
let params = this.$route.params; let params = this.$route.params;
let parent; let parent = this.$route.meta.parent;
this.isLoading = true;
await this.filesStore.fetchAllFiles();
await this.allFiles.forEach(file => {
if(file.id == params.fileId) {
parent = file.parent;
this.conformanceParent = file.parent;
}
});
// type: log | filter | rule(名稱待討論) | log-check(MAP page 來的已存檔 rule) | filter-check(MAP page 來的已存檔 rule) // type: log | filter | rule(名稱待討論) | log-check(MAP page 來的已存檔 rule) | filter-check(MAP page 來的已存檔 rule)
switch (params.type) { switch (params.type) {
case 'log': // FILES page 來的 log case 'log': // FILES page 來的 log
@@ -119,5 +112,19 @@ export default {
this.conformanceRuleData = null; this.conformanceRuleData = null;
this.conformanceFileName = null; this.conformanceFileName = null;
}, },
async beforeRouteEnter(to, from, next) {
const filesStore = FilesStore();
// Save token in Headers.
const token = document.cookie.replace(/(?:(?:^|.*;\s*)luciaToken\s*\=\s*([^;]*).*$)|^.*$/, "$1");
axios.defaults.headers.common['Authorization'] = `Bearer ${token}`;
await filesStore.fetchAllFiles();
await filesStore.allFiles.forEach(file => {
if(file.id == to.params.fileId) {
to.meta.parent = file.parent;
}
});
next();
}
} }
</script> </script>