This commit is contained in:
sakuya 2021-04-25 01:00:05 +08:00
parent e56e0a4dbb
commit 49fc8520b5
5 changed files with 47 additions and 15 deletions

View File

@ -76,7 +76,7 @@
}, },
watch: { watch: {
$route(e) { $route(e) {
this.addViewTags(e) this.addViewTags(e);
}, },
contextMenuVisible(value) { contextMenuVisible(value) {
var _this = this; var _this = this;
@ -137,10 +137,22 @@
//TAB //TAB
refreshTab(){ refreshTab(){
var nowTag = this.contextMenuItem; var nowTag = this.contextMenuItem;
this.$router.push({
path: nowTag.path
})
this.contextMenuVisible = false this.contextMenuVisible = false
//
if(this.$route.path != nowTag.path){
this.$router.push({
path: nowTag.path
})
}
var _this = this;
setTimeout(function() {
_this.$store.commit("removeKeepLive", nowTag.name)
_this.$store.commit("setRouteShow", false)
_this.$nextTick(() => {
_this.$store.commit("pushKeepLive",nowTag.name)
_this.$store.commit("setRouteShow", true)
})
}, 0);
}, },
//TAB //TAB
closeTabs(){ closeTabs(){

View File

@ -1,6 +1,8 @@
export default { export default {
state: { state: {
keepLiveRoute: [] keepLiveRoute: [],
routeKey: null,
routeShow: true
}, },
mutations: { mutations: {
pushKeepLive(state, component){ pushKeepLive(state, component){
@ -16,6 +18,17 @@ export default {
}, },
clearKeepLive(state){ clearKeepLive(state){
state.keepLiveRoute = [] state.keepLiveRoute = []
},
setRouteKey(state, key){
state.routeKey = key
},
setRouteShow(state, key){
state.routeShow = key
}
},
actions: {
setRouteKey({ commit }, key) {
commit('setRouteKey', key);
} }
} }
} }

View File

@ -52,6 +52,9 @@
return { return {
} }
},
mounted(){
console.log("home.vue mounted #57");
} }
} }
</script> </script>

View File

@ -23,7 +23,7 @@
</el-header> </el-header>
<el-main id="tableMain"> <el-main id="tableMain">
<el-card shadow="never"> <el-card shadow="never" v-loading="loading">
<el-table :data="tableData" row-key="name" stripe default-expand-all :height="tableHeight"> <el-table :data="tableData" row-key="name" stripe default-expand-all :height="tableHeight">
<el-table-column type="selection" width="50"></el-table-column> <el-table-column type="selection" width="50"></el-table-column>
<el-table-column label="显示名称" prop="meta.title" width="200"></el-table-column> <el-table-column label="显示名称" prop="meta.title" width="200"></el-table-column>
@ -82,14 +82,21 @@
], ],
tableHeight: '0', tableHeight: '0',
tableData: [], tableData: [],
loading: true,
drawer: false drawer: false
} }
}, },
components: { components: {
Show Show
}, },
created() { async created() {
this.tableData = this.$TOOL.data.get("user").menuList; var userInfo = await this.$API.user.info();
var _this = this;
setTimeout(function() {
_this.tableData = userInfo.data.menuList;
_this.loading = false;
}, 500);
}, },
mounted(){ mounted(){
this.$nextTick(() => { this.$nextTick(() => {

View File

@ -1,7 +1,7 @@
<template> <template>
<router-view v-slot="{ Component }"> <router-view v-slot="{ Component }">
<keep-alive :include="keepAliveNameList"> <keep-alive :include="this.$store.state.keepAlive.keepLiveRoute">
<component :is="Component" :key="$route.fullPath"/> <component :is="Component" :key="$route.fullPath" v-if="$store.state.keepAlive.routeShow"/>
</keep-alive> </keep-alive>
</router-view> </router-view>
</template> </template>
@ -10,11 +10,8 @@
export default { export default {
data() { data() {
return { return {
keepAliveNameList: this.$store.state.keepAlive.keepLiveRoute
} }
}, }
created: function() {
},
} }
</script> </script>