|
@@ -8,7 +8,6 @@ import { isRelogin } from '@/utils/request';
|
|
|
import useUserStore from '@/store/modules/user';
|
|
|
import useSettingsStore from '@/store/modules/settings';
|
|
|
import usePermissionStore from '@/store/modules/permission';
|
|
|
-import { RouteRecordRaw } from 'vue-router';
|
|
|
|
|
|
NProgress.configure({ showSpinner: false });
|
|
|
const whiteList = ['/login', '/register', '/social-callback'];
|
|
@@ -36,12 +35,14 @@ router.beforeEach(async (to, from, next) => {
|
|
|
isRelogin.show = false;
|
|
|
const accessRoutes = await usePermissionStore().generateRoutes();
|
|
|
// 根据roles权限生成可访问的路由表
|
|
|
- accessRoutes.forEach((route: RouteRecordRaw) => {
|
|
|
+ accessRoutes.forEach((route) => {
|
|
|
if (!isHttp(route.path)) {
|
|
|
router.addRoute(route); // 动态添加可访问路由表
|
|
|
}
|
|
|
});
|
|
|
- next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
|
|
|
+ const n = { ...to, replace: true };
|
|
|
+ console.log(n);
|
|
|
+ next({ path: to.path, replace: true, params: to.params, query: to.query, hash: to.hash, name: to.name as string }); // hack方法 确保addRoutes已完成
|
|
|
}
|
|
|
} else {
|
|
|
next();
|