|
@@ -49,18 +49,22 @@ router.beforeEach(async (to, from, next) => {
|
|
|
} else {
|
|
|
try {
|
|
|
const treeData = await store.dispatch('user/getMenuInfo')
|
|
|
- if (Array.isArray(treeData) && treeData.length) {
|
|
|
- const ndOrder = _.orderBy(treeData, ['displaynumber'])
|
|
|
- const nd = ndOrder.filter(item => item.pageconfigurationid)
|
|
|
- store.dispatch('auth/changeAuthArrs', nd)
|
|
|
- // const typeData = setType(treeData, 'up_auth_id', 'auth_id')
|
|
|
- const menusArray = parseMenuItem(nd)
|
|
|
- const treeMenu = listToTree(menusArray, 'up_auth_id', 'auth_id')
|
|
|
- const dataMenu = _.unionBy(treeMenu, 'auth_id')
|
|
|
- const menus = parseMenu(dataMenu)
|
|
|
- store.dispatch('permission/setRoutes', menus)
|
|
|
- router.addRoutes(menus)
|
|
|
- next({ ...to, replace: true })
|
|
|
+ if (Array.isArray(treeData)) {
|
|
|
+ if (treeData.length) {
|
|
|
+ const ndOrder = _.orderBy(treeData, ['displaynumber'])
|
|
|
+ const nd = ndOrder.filter(item => item.pageconfigurationid)
|
|
|
+ store.dispatch('auth/changeAuthArrs', nd)
|
|
|
+ const menusArray = parseMenuItem(nd)
|
|
|
+ const treeMenu = listToTree(menusArray, 'up_auth_id', 'auth_id')
|
|
|
+ const dataMenu = _.unionBy(treeMenu, 'auth_id')
|
|
|
+ const menus = parseMenu(dataMenu)
|
|
|
+ store.dispatch('permission/setRoutes', menus)
|
|
|
+ router.addRoutes(menus)
|
|
|
+ next({ ...to, replace: true })
|
|
|
+ } else {
|
|
|
+ next({ path: '/' })
|
|
|
+ NProgress.done()
|
|
|
+ }
|
|
|
} else {
|
|
|
await store.dispatch('user/resetToken')
|
|
|
Message.error(error || 'Has Error')
|