Browse Source

修复历史标签页

ming 3 years ago
parent
commit
849d3145a6

+ 20 - 1
src/layout/vab-avatar/index.vue

@@ -60,7 +60,8 @@
 import { recordRoute } from '@/config'
 import { DownOutlined } from '@ant-design/icons-vue'
 import { useStore } from 'vuex'
-import { mapGetters } from 'vuex'
+import { mapActions, mapGetters } from 'vuex'
+// import { mapGetters, } from 'vuex'
 export default {
   name: 'VabAvatar',
   components: { DownOutlined },
@@ -95,6 +96,13 @@ export default {
     }, 0)
   },
   methods: {
+
+     ...mapActions({
+ 
+      delAllVisitedRoutes: 'tagsBar/delAllVisitedRoutes',
+
+      // toggleCollapse: 'settings/toggleCollapse',
+    }),
     goPerCenter() {
       this.$router.push('/perCenter/index')
     },
@@ -111,12 +119,23 @@ export default {
       this.$router.push('/alarmManage/index')
     },
 
+     async closeAllTabs() {
+      await this.delAllVisitedRoutes()
+      if (this.affixTabs.some((tag) => tag.path === this.toThisTag().path))
+        return
+      this.toLastTag()
+    },
+
     async logout() {
       await this.$store.dispatch('user/logout')
       if (recordRoute) {
         // const fullPath = this.$route.fullPath
         // this.$router.push(`/login?redirect=${fullPath}`)
 
+        // this.$store.visitedRoutes=[]
+
+        this.closeAllTabs()
+
         this.$router.push('/login')
       } else {
         this.$router.push('/login')

+ 1 - 0
src/layout/vab-tabs/index.vue

@@ -39,6 +39,7 @@
           {{ item.title }}
         </el-breadcrumb-item>
       </el-breadcrumb> -->
+      
       <!-- {{visitedRoutes}} -->
 
       <a-tabs

+ 1 - 1
src/store/index.js

@@ -149,7 +149,7 @@ export default createStore({
         },
 
         /**
-         * @中间页主体页面配置
+         * @中间页主体页面配置  
          * @param {*} state 
          */
         async getMiddleConfig(state) {

+ 1 - 0
src/store/modules/routes.js

@@ -55,6 +55,7 @@ const actions = {
         data[0].meta.affix = false
         data[0].children[0].meta.affix = true
 
+
         // data.unshift({
         //     path: "/home",
         //     hidden: false,

+ 8 - 38
src/vab/plugins/permissions.js

@@ -15,18 +15,23 @@ import {
 
 router.beforeEach(async(to, from, next) => {
 
+
+
     let hasToken = store.getters['user/accessToken']
 
     if (!loginInterception) hasToken = true
     console.log(localStorage.getItem('accessToken'))
     console.log(localStorage.getItem('accessToken'))
     if (hasToken) {
-        if (to.path === '/login') {
 
 
+        if (to.path === '/login') {
+
             next({ path: '/' })
         } else {
 
+
+
             const hasRoles =
                 store.getters['acl/admin'] ||
                 store.getters['acl/role'].length > 0 ||
@@ -41,7 +46,7 @@ router.beforeEach(async(to, from, next) => {
                 next()
             } else {
 
-
+                store.commit('getMiddleConfig')
 
                 try {
                     if (loginInterception) {
@@ -59,55 +64,20 @@ router.beforeEach(async(to, from, next) => {
                     }
 
                     accessRoutes.forEach((item) => {
-
                         router.addRoute(item)
                     })
 
                     console.log('accessRoutes')
                     console.log(accessRoutes)
 
-                    // api.getMiddleConfig().then((requset) => {
-                    //     if (requset.status === 'SUCCESS') {
-                    //         store.state.middleStatus = requset.data[0].middleStatus;
-                    //         if (store.state.middleStatus == 1) {
-                    //             next('/middle')
-                    //         } else {
-                    //             next(accessRoutes[0].children[0].path)
-                    //         }
-                    //     } else {
-                    //         console.log(111)
-                    //     }
-                    // })
-
+                    // alert('判断是否显示中间页的middleStatus值' + store.state.middleStatus)
 
-
-                    store.commit('getMiddleConfig')
-                        // alert('判断是否显示中间页的middleStatus值' + store.state.middleStatus)
                     if (store.state.middleStatus == 1) {
                         next('/middle')
                     } else {
                         next(accessRoutes[0].children[0].path)
                     }
 
-
-
-
-
-                    // if (accessRoutes[1].path != '/') {
-
-                    //     next('/middle')
-                    //         // next(accessRoutes[0].children.path)
-                    // } else {
-                    //     // router.push({
-                    //     //     path: '/middle'
-                    //     // })
-
-                    //     next('/middle')
-
-                    //     // next({...to, replace: true })
-
-                    // }
-
                 } catch {
                     await store.dispatch('user/resetAll')
                     if (recordRoute)