gaohaiyong 1 year ago
parent
commit
ee4d790f07
2 changed files with 19 additions and 18 deletions
  1. 3 5
      src/layout/components/AppMain.vue
  2. 16 13
      src/layout/components/Breadcrumb.vue

+ 3 - 5
src/layout/components/AppMain.vue

@@ -45,13 +45,11 @@ export default {
       });
     },
     t_title(e){
-      
-      this.isRouterAlive = false;
+      this.t_name = e;
       this.$nextTick(function () {
-        this.isRouterAlive = true;
-        this.t_name = e;
-       console.log(this.t_name)
+        this.t_name = '';
       });
+      console.log(this.t_name)
     }
 
   },

+ 16 - 13
src/layout/components/Breadcrumb.vue

@@ -54,12 +54,20 @@ export default {
     //当路由变更时,执行打开页面的方法
     $route: {
       handler(v) {
-        this.openPage(v);
+        let new_route = {};
+        for(let key in v){
+          new_route[key] = v[key];
+        }
+        new_route.t_name = this.t_name;
+
+        this.openPage(new_route);
       },
       immediate: true,
     },
+    
   },
   mounted() {
+    this.t_name = this.t_name;
     //添加点击关闭右键菜单
     window.addEventListener("click", this.closeContextMenu);
   },
@@ -85,33 +93,28 @@ export default {
     //打开页面
     openPage(route) {
       this.contextMenuTargetPageRoute = route;
-      let new_route = {};
-      for(let key in route){
-        new_route[key] = route[key];
-      }
-      new_route.t_name = this.t_name;
-      console.log(new_route)
-      if (new_route.name == this.blankRouteName) {
+      if (route.name == this.blankRouteName) {
         return;
       }
       let isExist = this.openedPageRouters.some(
-        (item) => item.fullPath == new_route.fullPath
+        (item) => item.fullPath == route.fullPath
       );
       if (!isExist) {
         let openedPageRoute = this.openedPageRouters.find(
-          (item) => item.path == new_route.path
+          (item) => item.path == route.path
         );
         //判断页面是否支持不同参数多开页面功能,如果不支持且已存在path值一样的页面路由,那就替换它
-        if (!new_route.meta.canMultipleOpen && openedPageRoute != null) {
+        if (!route.meta.canMultipleOpen && openedPageRoute != null) {
           this.delRouteCache(openedPageRoute.fullPath);
           this.openedPageRouters.splice(
             this.openedPageRouters.indexOf(openedPageRoute),
             1,
-            new_route
+            route
           );
         } else {
-          this.openedPageRouters.push(new_route);
+          this.openedPageRouters.push(route);
         }
+        console.log(route)
         this.bottomScrollClick();
       }
     },