From 38e9abbd9e89ccf14389e90fa94b4b8ea36fa60d Mon Sep 17 00:00:00 2001
From: liudong <liudong>
Date: 星期五, 23 八月 2024 14:28:42 +0800
Subject: [PATCH] 修改登录页面提示信息

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

diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts
index 0a3e0d3..4c508a2 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', {
@@ -30,6 +31,7 @@
     certification: undefined,
     role: '',
     resources:undefined,
+    hrefUrl:undefined
   }),
 
   getters: {
@@ -67,15 +69,18 @@
     async login(loginForm: LoginData):string {
       try {
         const res = await userLogin(loginForm);
+
         setToken(res.data.access_token);
         const userInfo = {
           avatar: res.data.avatar,
           name: res.data.nickname,
           email: res.data.email,
         };
-        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
@@ -98,9 +103,17 @@
       try {
         await userLogout();
       } finally {
+        router.push({
+          name: "login",
+        });
         this.logoutCallBack();
       }
     },
+
+
+    getHreFurl(url: string) {
+      this.hrefUrl=url
+    },
   },
 });
 

--
Gitblit v1.8.0