From 30c1eeca00527a1294c62b1c708edd32ba079b67 Mon Sep 17 00:00:00 2001
From: yinbangzhong <zhongbangyin@126.com>
Date: 星期四, 29 八月 2024 17:35:47 +0800
Subject: [PATCH] select role

---
 src/store/modules/user/index.ts |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts
index 7bb51c3..84388d7 100644
--- a/src/store/modules/user/index.ts
+++ b/src/store/modules/user/index.ts
@@ -71,19 +71,28 @@
         const res = await userLogin(loginForm);
 
         setToken(res.data.access_token);
+       
         const userInfo = {
           avatar: res.data.avatar,
-          name: res.data.nickname,
+          name: res.data.userName,
           email: res.data.email,
+          role: res.data.roles[0].roleKey,
         };
-        if(res.data.roles && res.data.roles.length>0)
-            this.resources=res.data.roles[0].resources;
-        else
-            this.resources=res.data.resources;
-        setUserInfo(JSON.stringify(userInfo));
-        setUserResources(JSON.stringify(this.resources))
+        this.name=res.data.userName
+     
+        if(res.data?.roles.length>0)
+          //閬嶅巻roles
+          for (const r of res.data.roles) {
+            if (!(this.resources)) {
+              this.resources = [];
+            }
+            this.resources = this.resources.concat(r.resources);
+          }
+            setUserInfo(JSON.stringify(userInfo));
+            setUserResources(JSON.stringify(this.resources))
         for (const r of this.resources) {
           if (r.menuType == 0) {
+            
             return r.component
           }
         }

--
Gitblit v1.8.0