merge: Merge soybean.

This commit is contained in:
xlsea
2025-05-16 16:48:05 +08:00
8 changed files with 1088 additions and 732 deletions

View File

@ -39,6 +39,8 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
async function resetStore() {
const authStore = useAuthStore();
recordUserId();
clearAuthStorage();
authStore.$reset();
@ -56,6 +58,41 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
resetStore();
}
/** Record the user ID of the previous login session Used to compare with the current user ID on next login */
function recordUserId() {
if (!userInfo.user?.userId) {
return;
}
// Store current user ID locally for next login comparison
localStg.set('lastLoginUserId', userInfo.user?.userId);
}
/**
* Check if current login user is different from previous login user If different, clear all tabs
*
* @returns {boolean} Whether to clear all tabs
*/
function checkTabClear(): boolean {
if (!userInfo.user?.userId) {
return false;
}
const lastLoginUserId = localStg.get('lastLoginUserId');
// Clear all tabs if current user is different from previous user
if (!lastLoginUserId || lastLoginUserId !== userInfo.user?.userId) {
localStg.remove('globalTabs');
tabStore.clearTabs();
localStg.remove('lastLoginUserId');
return true;
}
localStg.remove('lastLoginUserId');
return false;
}
/**
* Login
*
@ -79,10 +116,19 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
const pass = await loginByToken(loginToken);
if (pass) {
await redirectFromLogin(redirect);
// Check if the tab needs to be cleared
const isClear = checkTabClear();
let needRedirect = redirect;
if (isClear) {
// If the tab needs to be cleared,it means we don't need to redirect.
needRedirect = false;
}
await redirectFromLogin(needRedirect);
// window.$notification?.success({
// title: $t('page.login.common.loginSuccess'),
// content: $t('page.login.common.welcomeBack', { userName: userInfo.user?.nickName }),
// content: $t('page.login.common.welcomeBack', { userName: userInfo.userName }),
// duration: 4500
// });
}

View File

@ -42,6 +42,8 @@ declare namespace StorageType {
layout: UnionKey.ThemeLayoutMode;
siderCollapse: boolean;
};
/** The last login user id */
lastLoginUserId: CommonType.IdType;
/** The login form rember */
loginRember: Api.Auth.PwdLoginForm;
/** The tenant id */