From 7faf1532a00bb886860ea5150cf80939b0b69f81 Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期一, 20 十月 2025 16:32:22 +0800
Subject: [PATCH] fix: bug
---
src/store/modules/user.ts | 35 +++++++++++++++++++++++++++++++----
1 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index d472450..91a830c 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -8,6 +8,9 @@
setUserInfo,
getUserInfo,
md5Encrypt,
+ getUserDetail,
+ setUserDetail,
+ removeUserDetail,
} from '@/utils';
import { resetRouter, router } from '@/router';
import { useTagsViewStoreHook } from './tagsView';
@@ -19,16 +22,19 @@
export interface UserState {
token: string;
- userInfo: API.PasswordLoginCommandCallback;
+ userInfo: API.LoginCommandCallback;
+ userDetail?: Nullable<API.GetEnterpriseLoginInfoQueryResult>;
}
function getDefaultState() {
const accessToken = getToken();
const userInfo = getUserInfo();
+ const userDetail = getUserDetail();
return {
token: accessToken,
userInfo: userInfo || {},
+ userDetail: userDetail,
} as UserState;
}
@@ -44,7 +50,7 @@
},
userId(state) {
- return '';
+ return state.userDetail?.id;
},
},
actions: {
@@ -52,9 +58,14 @@
this.token = token;
setToken(token);
},
- setUserInfo(userInfo: API.PasswordLoginCommandCallback) {
+ setUserInfo(userInfo: API.LoginCommandCallback) {
this.userInfo = userInfo;
setUserInfo(userInfo);
+ },
+
+ setUserDetail(detail: API.GetEnterpriseLoginInfoQueryResult) {
+ this.userDetail = detail;
+ setUserDetail(detail);
},
// 鐢ㄦ埛鐧诲叆
@@ -62,7 +73,8 @@
let res = await authServices.passwordLogin(
{
...params,
- password: md5Encrypt(params.password),
+ password: params.password,
+ // password: md5Encrypt(params.password),
type: AppLocalConfig.userType,
clientType: AppLocalConfig.clientType,
},
@@ -73,7 +85,21 @@
if (res) {
this.setToken(res.accessToken);
this.setUserInfo(res);
+ this.getCurrentUserInfo();
}
+ },
+
+ async getCurrentUserInfo() {
+ try {
+ let res = await authServices.getEnterpriseLoginInfo({}, { showLoading: false });
+ if (res) {
+ // res.frontStatus = getUserCertificationFrontStatusAdapter(
+ // res.userCertificationStatus,
+ // res.userCertificationAuditStatus
+ // );
+ this.setUserDetail(res);
+ }
+ } catch (error) {}
},
// 鐧诲嚭 娓呯┖缂撳瓨
@@ -81,6 +107,7 @@
return new Promise(async (resolve) => {
removeToken();
removeUserInfo();
+ removeUserDetail();
this.resetState();
resetRouter();
myClient.removeQueries();
--
Gitblit v1.9.1