Commit 72e455f0 authored by 张伯涛's avatar 张伯涛

接口getinfo重复调用问题

parent d29df8b9
...@@ -26,8 +26,8 @@ router.beforeEach((to, from, next) => { ...@@ -26,8 +26,8 @@ router.beforeEach((to, from, next) => {
// 判断用户是否有权限 有角色 // 判断用户是否有权限 有角色
if (res.data.roles && res.data.roles.length > 0 && res.data.permissions && res.data.permissions.length > 0) { if (res.data.roles && res.data.roles.length > 0 && res.data.permissions && res.data.permissions.length > 0) {
// 拉取user_info // 拉取user_info
const roles = res.data.roles // const roles = res.data.roles
store.dispatch('GenerateRoutes', { roles }).then((routers) => { store.dispatch('GenerateRoutes', res).then((routers) => {
// 判断用户是否有路由 // 判断用户是否有路由
if (routers.accessedRoutes && routers.accessedRoutes.length > 0 && routers.getRouters && routers.getRouters.length > 0) { if (routers.accessedRoutes && routers.accessedRoutes.length > 0 && routers.getRouters && routers.getRouters.length > 0) {
// 测试 默认静态页面 // 测试 默认静态页面
......
...@@ -16,20 +16,20 @@ const permission = { ...@@ -16,20 +16,20 @@ const permission = {
}, },
actions: { actions: {
// 生成路由 // 生成路由
GenerateRoutes({ commit }) { GenerateRoutes({ commit }, res) {
return new Promise(resolve => { return new Promise(resolve => {
// 向后端请求路由数据 // 向后端请求路由数据
getInfo().then(res => { // getInfo().then(res => {
const accessedRoutes = filterAsyncRouter(res.data.menus) const accessedRoutes = filterAsyncRouter(res.data.menus)
if (accessedRoutes[0]) { if (accessedRoutes[0]) {
const firstChild = getFirstChild(accessedRoutes[0]) const firstChild = getFirstChild(accessedRoutes[0])
accessedRoutes.push({ path: '*', redirect: '/404', hidden: true }) accessedRoutes.push({ path: '*', redirect: '/404', hidden: true })
accessedRoutes.push({ path: '/', redirect: firstChild, hidden: true }) accessedRoutes.push({ path: '/', redirect: firstChild, hidden: true })
commit('SET_ROUTES', accessedRoutes) commit('SET_ROUTES', accessedRoutes)
} }
const routers = { accessedRoutes: accessedRoutes, getRouters: res.data.menus } const routers = { accessedRoutes: accessedRoutes, getRouters: res.data.menus }
resolve(routers) resolve(routers)
}) // })
}) })
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment