gaoshp
2024-11-10 5d0a077b235fa694bd356b94edbba7c2f483d36a
src/layout/index.vue
@@ -104,7 +104,7 @@
         </div>
         <div class="adminui-header-right">
            <div v-if="!ismobile" class="adminui-header-menu">
               <el-menu mode="horizontal" :default-active="active" router background-color="#222b45" text-color="#fff" active-text-color="var(--el-color-primary)">
               <el-menu mode="horizontal" @select="handleSelect" :default-active="active" background-color="#222b45" text-color="#fff" active-text-color="var(--el-color-primary)">
                  <NavMenu :navMenus="menu"></NavMenu>
               </el-menu>
            </div>
@@ -267,6 +267,38 @@
         }
      },
      methods: {
         findRouteByPath(routes, targetPath) {
            for (let i = 0; i < routes.length; i++) {
               if (routes[i].path === targetPath) {
                  // 如果找到匹配的path,直接返回当前对象
                  return routes[i];
               }
               if (routes[i].children) {
                  // 如果当前对象有children,递归查找
                  const found = this.findRouteByPath(routes[i].children, targetPath);
                  if (found) {
                     return found;
                  }
               }
            }
            // 如果没有找到匹配的path,返回null
            return null;
         },
         handleSelect(key, keyPath,index,routeResult) {
            var MENU = this.$TOOL.data.get("MENU");
            var foundRoute = this.findRouteByPath(MENU, key);
            //http://116.63.148.72:8080/xxl-job-admin
            var TOKEN = this.$TOOL.cookie.get("TOKEN");
            if(key == "/myiframe/urlPath") {  //任务调度
               this.$router.push({path: '/myiframe/urlPath',query:{name: foundRoute.name,src:foundRoute.origin}});
               return;
            }
            if(foundRoute.isOpen != "2") {
               this.$router.push({path: key});
            }else {
               window.open(key + `?token=${TOKEN}`,'_blank');
            }
         },
         openSetting(){
            this.settingDialog = true;
         },