czh-20260612-新增单点登录功能

This commit is contained in:
zhihao
2026-06-12 10:48:32 +08:00
parent b8d57da4e4
commit 871e296f06
9 changed files with 605 additions and 6 deletions
+16 -1
View File
@@ -8,6 +8,7 @@ import { ROLES_KEY, TOKEN_KEY, USER_INFO_KEY, LOGIN_INFO_KEY, DB_DICT_DATA_KEY,
import { getAuthCache, setAuthCache, removeAuthCache } from '/@/utils/auth';
import { GetUserInfoModel, LoginParams, ThirdLoginParams } from '/@/api/sys/model/userModel';
import { doLogout, getUserInfo, loginApi, phoneLoginApi, thirdLogin } from '/@/api/sys/user';
import { autoLoginApi } from '/@/api/sys/autologin';
import { useI18n } from '/@/hooks/web/useI18n';
import { useMessage } from '/@/hooks/web/useMessage';
import { router } from '/@/router';
@@ -161,6 +162,20 @@ export const useUserStore = defineStore({
return Promise.reject(error);
}
},
/**
* 网关自动登录 — 跳过密码,由网关注入身份
*/
async autoLogin(goHome = true): Promise<GetUserInfoModel | null> {
try {
const data = await autoLoginApi();
const { token, userInfo } = data;
this.setToken(token);
this.setTenant(userInfo.loginTenantId);
return this.afterLoginAction(goHome, data);
} catch (error) {
return Promise.reject(error);
}
},
/**
* 扫码登录事件
*/
@@ -330,7 +345,7 @@ export const useUserStore = defineStore({
}else{
// update-begin-author:sunjianlei date:20230306 for: 修复登录成功后,没有正确重定向的问题
goLogin && (await router.push({
path: PageEnum.BASE_LOGIN,
path: PageEnum.LOGOUT_RESULT_PATH,
query: {
// 传入当前的路由,登录成功后跳转到当前路由
redirect: router.currentRoute.value.fullPath,