|
|
@ -6,8 +6,6 @@ import { get } from "@/plugins/requests/index.js"; |
|
|
|
import api from "@/api"; |
|
|
|
import api from "@/api"; |
|
|
|
import util from "@/libs/util"; |
|
|
|
import util from "@/libs/util"; |
|
|
|
import BasicLayout from "@/layouts/home"; |
|
|
|
import BasicLayout from "@/layouts/home"; |
|
|
|
import store from '@/store' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vue.use(Router); |
|
|
|
Vue.use(Router); |
|
|
|
const createRouter = () => new Router({ |
|
|
|
const createRouter = () => new Router({ |
|
|
|
mode: Setting.routerMode, |
|
|
|
mode: Setting.routerMode, |
|
|
@ -61,6 +59,7 @@ function getPermission() { |
|
|
|
|
|
|
|
|
|
|
|
let data = res.permissionMenu[0].children; |
|
|
|
let data = res.permissionMenu[0].children; |
|
|
|
if (data.length > 0) { |
|
|
|
if (data.length > 0) { |
|
|
|
|
|
|
|
console.log(11, data) |
|
|
|
data.forEach(e => { |
|
|
|
data.forEach(e => { |
|
|
|
// 第一级路由,需要根据匹配到的path,塞进对应的路由children里
|
|
|
|
// 第一级路由,需要根据匹配到的path,塞进对应的路由children里
|
|
|
|
let str = e.path.split("/")[1]; |
|
|
|
let str = e.path.split("/")[1]; |
|
|
@ -77,6 +76,7 @@ function getPermission() { |
|
|
|
let children = []; |
|
|
|
let children = []; |
|
|
|
// 第二级是按钮级数据,一级归属当前页的同级页面,实际上一共就一级路由
|
|
|
|
// 第二级是按钮级数据,一级归属当前页的同级页面,实际上一共就一级路由
|
|
|
|
if (e.children && e.children.length > 0) { |
|
|
|
if (e.children && e.children.length > 0) { |
|
|
|
|
|
|
|
console.log(e.children) |
|
|
|
e.children.forEach(i => { |
|
|
|
e.children.forEach(i => { |
|
|
|
// 避免重复生成路由
|
|
|
|
// 避免重复生成路由
|
|
|
|
if (i.path && permissionRouters[index] && !permissionRouters[index].children.some(e => i.path === e.path)) { |
|
|
|
if (i.path && permissionRouters[index] && !permissionRouters[index].children.some(e => i.path === e.path)) { |
|
|
@ -260,14 +260,10 @@ router.beforeEach(function(to, from, next) { |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (to.path !== "/login" && to.path !== '/redirect') { |
|
|
|
if (to.path !== "/login" && to.path !== '/redirect') { |
|
|
|
if (store.state.user.fromClient) { |
|
|
|
next({ |
|
|
|
location.href = `${location.origin}/student` |
|
|
|
path: "/login", |
|
|
|
} else { |
|
|
|
query: { redirect: to.path } |
|
|
|
next({ |
|
|
|
}) |
|
|
|
path: "/login", |
|
|
|
|
|
|
|
query: { redirect: to.path } |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 根据路由元信息设置文档标题
|
|
|
|
// 根据路由元信息设置文档标题
|
|
|
|