fix: 🐛 管理员按钮错误消失
This commit is contained in:
parent
63b3adfa2c
commit
53f887d0d6
@ -50,7 +50,7 @@ router.beforeEach(async (to, from, next) => {
|
||||
if (!userState.token && storageToken) restoreToken(storageToken);
|
||||
|
||||
// 4. Vuex 有 token,但还没有动态路由,获取用户资源, 生成动态路由
|
||||
if (userState.token && dynamicRoutes.length === 0) loadRoutes(userState.isAdmin, next);
|
||||
if (userState.token && dynamicRoutes.length === 0) loadRoutes(userState, next);
|
||||
|
||||
// 5. 放行
|
||||
next();
|
||||
@ -88,13 +88,13 @@ function restoreToken(token) {
|
||||
}
|
||||
|
||||
/** 生成并加载动态路由 */
|
||||
async function loadRoutes(isAdmin, next) {
|
||||
async function loadRoutes(userState, next) {
|
||||
try {
|
||||
await store.dispatch('user/getUserInfo')
|
||||
const routesResource = await store.dispatch("user/getRoutesResource");
|
||||
dynamicRoutes = generateIndexRouter(routesResource);
|
||||
router.addRoutes(dynamicRoutes);
|
||||
|
||||
if (isAdmin) {
|
||||
if (userState.isAdmin) {
|
||||
router.addRoutes([systemSettings]);
|
||||
}
|
||||
} catch (err) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user