zhangqi 1 vuosi sitten
vanhempi
commit
b4363994a4

+ 8 - 8
src/components/layout/modules/historyTabs.vue

@@ -35,14 +35,14 @@ const onChange = (val)=>{
   let path = historyRoutes.value.filter(element => element.name == val)
   router.push({name:path[0].name,query:path[0].query,meta:{keepAlive:false}})
 }
-router.beforeEach((to,from,next)=>{
-  let rs = historyRoutes.value.some(item=>item.name == from.name)
- 
-  rotTabs.saveRoute(to)
-  store.appData(to.meta.name)
-  activeKey.value = to.name
-  next()
-})
+// router.beforeEach((to,from,next)=>{
+//   console.log(to,from)
+//   let rs = historyRoutes.value.some(item=>item.name == from.name)
+//   // rotTabs.saveRoute(to)
+//   // store.appData(to.meta.name)
+//   // activeKey.value = to.name
+//   next()
+// })
 </script>
 <style>
 .sw-tabs .ant-tabs-tab-active{

+ 7 - 1
src/router/index.js

@@ -1,5 +1,7 @@
 
 import { useAuthStore } from '@/stores/modules/auth'
+import { useRouteTabsStore } from '@/stores/modules/routeTabs'
+
 import { createRouter, createWebHashHistory} from 'vue-router'
 import HDrpManagement from './HDrpManagement.js'
 import SDrpManagement from './SDrpManagement.js'
@@ -110,8 +112,8 @@ const router = createRouter({
   history: createWebHashHistory(),
   routes
 })
-
 router.beforeEach((to, from,next)=> {
+  console.log(to,from)
   const store = useAuthStore()
   store.appData(to.meta.name).then(()=>{
     let app = store.app
@@ -123,6 +125,10 @@ router.beforeEach((to, from,next)=> {
         if (app && app.isneedpay) {
           return { name: 'modulesPay' }
         }
+        const rotTabs = useRouteTabsStore()
+        rotTabs.saveRoute(to)
+        store.appData(to.meta.name)
+        rotTabs.activeKey = to.name
         next()
       }
     } else {

+ 1 - 1
src/stores/modules/routeTabs.js

@@ -53,7 +53,7 @@ export const useRouteTabsStore = defineStore('routeTabs', {
       })
       if(route == currentRoute) {
         if (this.historyRoutes.length > 0)
-          return router.replace({name:this.historyRoutes[this.historyRoutes.length - 1].name,query:this.historyRoutes[this.historyRoutes.length - 1].query})
+          return router.replace({path:this.historyRoutes[this.historyRoutes.length - 1].path,query:this.historyRoutes[this.historyRoutes.length - 1].query})
         if (this.historyRoutes.length == 0)
           return router.replace({path:mods[0].apps[0].path})
       }