From 669390b30e1328e32b35c1a1bbd6d7e8ee9d96d3 Mon Sep 17 00:00:00 2001
From: yinbangzhong <zhongbangyin@126.com>
Date: 星期六, 24 八月 2024 17:59:37 +0800
Subject: [PATCH] bug fix
---
src/store/modules/user/index.ts | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts
index 51faef3..426abc7 100644
--- a/src/store/modules/user/index.ts
+++ b/src/store/modules/user/index.ts
@@ -9,6 +9,7 @@
import { removeRouteListener } from '@/utils/route-listener';
import { UserState } from './types';
import useAppStore from '../app';
+import router from "@/router";
const useUserStore = defineStore('user', {
@@ -74,10 +75,13 @@
avatar: res.data.avatar,
name: res.data.nickname,
email: res.data.email,
+ role: res.data.roles[0].roleKey,
};
- this.resources=res.data.resources;
- setUserInfo(JSON.stringify(userInfo));
- setUserResources(JSON.stringify(this.resources))
+
+ if(res.data?.roles.length>0)
+ this.resources=res.data.roles[0].resources;
+ setUserInfo(JSON.stringify(userInfo));
+ setUserResources(JSON.stringify(this.resources))
for (const r of this.resources) {
if (r.menuType == 0) {
return r.component
@@ -100,6 +104,9 @@
try {
await userLogout();
} finally {
+ router.push({
+ name: "login",
+ });
this.logoutCallBack();
}
},
--
Gitblit v1.8.0