mirror of
https://github.com/certd/certd.git
synced 2026-05-16 05:07:32 +08:00
fix: 修复切换普通用户登录时,左侧菜单没有同步更新的bug
This commit is contained in:
@@ -22,6 +22,8 @@ router.beforeEach(async (to, from, next) => {
|
||||
NProgress.start();
|
||||
const settingStore = useSettingStore();
|
||||
await settingStore.initOnce();
|
||||
const resourceStore = useResourceStore();
|
||||
resourceStore.init();
|
||||
// 修复三级以上路由页面无法缓存的问题
|
||||
if (to.matched && to.matched.length > 2) {
|
||||
to.matched.splice(1, to.matched.length - 2);
|
||||
@@ -37,11 +39,11 @@ router.beforeEach(async (to, from, next) => {
|
||||
// 请根据自身业务需要修改
|
||||
const token = userStore.getToken;
|
||||
if (token) {
|
||||
await userStore.init();
|
||||
next();
|
||||
} else {
|
||||
// 没有登录的时候跳转到登录界面
|
||||
// 携带上登陆成功之后需要跳转的页面完整路径
|
||||
resourceStore.clear();
|
||||
next({
|
||||
name: "login",
|
||||
query: {
|
||||
@@ -73,7 +75,7 @@ router.afterEach((to: any) => {
|
||||
const matched = to.matched;
|
||||
if (matched.length > 0) {
|
||||
const resourceStore = useResourceStore();
|
||||
resourceStore.setAsideMenuByCurrentRoute(matched);
|
||||
resourceStore.setCurrentTopMenuByCurrentRoute(matched);
|
||||
}
|
||||
});
|
||||
export default router;
|
||||
|
||||
@@ -10,7 +10,7 @@ export const sysResources = [
|
||||
component: LayoutPass,
|
||||
meta: {
|
||||
icon: "ion:settings-outline",
|
||||
permission: "sys"
|
||||
permission: "sys:settings:view"
|
||||
},
|
||||
children: [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user