修改路由
This commit is contained in:
parent
0a82d7d2fe
commit
b99cb1a331
@ -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 菜单列表
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user