From b99cb1a331a505aa41893fdefd54bda72c961a62 Mon Sep 17 00:00:00 2001 From: wulin Date: Mon, 7 Sep 2020 15:29:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index e87db19..9ae19c5 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -9,9 +9,9 @@ import Router from 'vue-router' import { apiGetMenuNav } from '@/api/api_menu' import { isURL } from '@/utils/validate' import {clearLoginInfo} from '@/utils' -//import VConsole from 'vconsole' +import VConsole from 'vconsole' -//let vConsole = new VConsole() +let vConsole = new VConsole() Vue.use(Router) // 开发环境不使用懒加载, 因为懒加载页面太多的话会造成webpack热更新太慢, 所以只有生产环境使用懒加载 @@ -75,7 +75,17 @@ router.beforeEach((to, from, next) => { // 2. 获取菜单列表, 添加并保存本地存储 if (router.options.isAddDynamicMenuRoutes || fnCurrentRouteType(to, globalRoutes) === 'global') { next() - } else { + } /*else if (fnIsInRoutes(to, configRoutes)) {//判断是否全屏路由 + console.log(to) + let newpage = router.resolve({ + name: to.path, + query:to.query + }) + + console.log(newpage.href) + window.open(newpage.href, '_blank') + next() + }*/ else { apiGetMenuNav({}).then(res => { if (res && res.code === 0) { fnAddDynamicMenuRoutes(res.menuList) @@ -108,6 +118,15 @@ function fnCurrentRouteType (route, globalRoutes = []) { return temp.length >= 1 ? fnCurrentRouteType(route, temp) : 'main' } +function fnIsInRoutes(route, routes = []){ + for(var i = 0; i < routes.length; i++) { + if(route.path === routes[i].path){ + return true; + } + } + return false; +} + /** * 添加动态(菜单)路由 * @param {*} menuList 菜单列表