From 2542ae393e12cee28b2ffd81a3e6723386c58492 Mon Sep 17 00:00:00 2001 From: liudong <liudong> Date: 星期四, 15 八月 2024 15:07:26 +0800 Subject: [PATCH] 新建对话页面开发 --- src/store/modules/user/index.ts | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts index 0849edf..faa226d 100644 --- a/src/store/modules/user/index.ts +++ b/src/store/modules/user/index.ts @@ -9,6 +9,8 @@ import { removeRouteListener } from '@/utils/route-listener'; import { UserState } from './types'; import useAppStore from '../app'; +import router from "@/router"; + const useUserStore = defineStore('user', { state: (): UserState => ({ @@ -29,6 +31,7 @@ certification: undefined, role: '', resources:undefined, + hrefUrl:undefined }), getters: { @@ -63,9 +66,10 @@ }, // Login - async login(loginForm: LoginData) { + async login(loginForm: LoginData):string { try { const res = await userLogin(loginForm); + setToken(res.data.access_token); const userInfo = { avatar: res.data.avatar, @@ -75,6 +79,11 @@ this.resources=res.data.resources; setUserInfo(JSON.stringify(userInfo)); setUserResources(JSON.stringify(this.resources)) + for (const r of this.resources) { + if (r.menuType == 0) { + return r.component + } + } } catch (err) { clearToken(); throw err; @@ -92,9 +101,17 @@ try { await userLogout(); } finally { + router.push({ + name: "login", + }); this.logoutCallBack(); } }, + + + getHreFurl(url: string) { + this.hrefUrl=url + }, }, }); -- Gitblit v1.8.0