|
|
@@ -6,10 +6,11 @@ import NProgress from 'nprogress';
|
|
|
import VueRouter from 'vue-router';
|
|
|
import { WHITE_LIST, REDIRECT_PATH, LAYOUT_PATH } from '@/config/setting';
|
|
|
import store from '@/store';
|
|
|
-import { getToken } from '@/utils/token-util';
|
|
|
+import { getToken, setToken } from '@/utils/token-util';
|
|
|
import { routes, getMenuRoutes } from './routes';
|
|
|
import { SYSTEM_NAME } from '@/config/setting';
|
|
|
import { getLoginUser } from '@/api/login';
|
|
|
+import { changeRole } from '@/api/layout/index';
|
|
|
|
|
|
Vue.use(VueRouter);
|
|
|
|
|
|
@@ -117,14 +118,18 @@ router.afterEach((to) => {
|
|
|
}
|
|
|
});
|
|
|
router.roleChange = ({ menus, homePath, authoritiesRouter }) => {
|
|
|
- if (menus&&menus.length > 0) {
|
|
|
+ if (menus && menus.length > 0) {
|
|
|
router.addRoute(
|
|
|
getMenuRoutes([...menus, ...authoritiesRouter], homePath)
|
|
|
);
|
|
|
+
|
|
|
router.push({
|
|
|
- path:menus[0].redirect||menus[0].path,
|
|
|
- }).then(res=>{
|
|
|
- window.location.reload()
|
|
|
+ path: menus[0].redirect || menus[0].path,
|
|
|
+ }).then(res => {
|
|
|
+ changeRole({ groupId: store.state.user.info.currentGroupId, roleId: store.state.user.info.currentRoleId }).then(res => {
|
|
|
+ setToken(res)
|
|
|
+ window.location.reload()
|
|
|
+ })
|
|
|
|
|
|
})
|
|
|
}
|