From fb4db4ae9b6a7f113ba049f6789e6916c0dcc276 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 12 十月 2026 09:15:08 +0800
Subject: [PATCH] feat(mes): 新增业务码支持并优化追溯查询功能

---
 src/store/auth.ts |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/store/auth.ts b/src/store/auth.ts
index 7d09f0e..a4776ec 100644
--- a/src/store/auth.ts
+++ b/src/store/auth.ts
@@ -21,6 +21,7 @@
   socialLogin,
 } from '#/api';
 import { $t } from '#/locales';
+import { resetTerminal, safeDestination, terminalHome, terminalType } from '#/mobile/terminal';
 
 export const useAuthStore = defineStore('auth', () => {
   const accessStore = useAccessStore();
@@ -28,6 +29,7 @@
   const router = useRouter();
 
   const loginLoading = ref(false);
+  const loadedTerminal = ref<string>();
 
   /**
    * 寮傛澶勭悊鐧诲綍鎿嶄綔
@@ -67,6 +69,7 @@
 
       // 濡傛灉鎴愬姛鑾峰彇鍒� accessToken
       if (accessToken) {
+        accessStore.setIsAccessChecked(false);
         accessStore.setAccessToken(accessToken);
         accessStore.setRefreshToken(refreshToken);
 
@@ -87,11 +90,12 @@
           onSuccess
             ? await onSuccess?.()
             : await router.push(
-                userInfo.homePath || preferences.app.defaultHomePath,
+                safeDestination(router.currentRoute.value.query.redirect,
+                  terminalHome() || userInfo.homePath || preferences.app.defaultHomePath),
               );
         }
 
-        if (userInfo?.nickname) {
+        if (userInfo?.nickname && terminalType.value === 'pc') {
           notification.success({
             description: `${$t('authentication.loginSuccessDesc')}:${userInfo?.nickname}`,
             duration: 3,
@@ -108,7 +112,7 @@
     };
   }
 
-  async function logout(redirect: boolean = true) {
+  async function logout(redirect: boolean = true, preserveTerminal: boolean = false) {
     try {
       const accessToken = accessStore.accessToken as string;
       if (accessToken) {
@@ -118,6 +122,8 @@
       // 涓嶅仛浠讳綍澶勭悊
     }
     resetAllStores();
+    if (!preserveTerminal) resetTerminal();
+    loadedTerminal.value = undefined;
     accessStore.setLoginExpired(false);
 
     // 鍥炵櫥褰曢〉甯︿笂褰撳墠璺敱鍦板潃
@@ -135,18 +141,20 @@
     // 鍔犺浇
     // eslint-disable-next-line no-useless-assignment
     let authPermissionInfo: AuthPermissionInfo | null = null;
-    authPermissionInfo = await getAuthPermissionInfoApi();
+    authPermissionInfo = await getAuthPermissionInfoApi(terminalType.value);
     // userStore
     userStore.setUserInfo(authPermissionInfo.user);
     userStore.setUserRoles(authPermissionInfo.roles);
     // accessStore
     accessStore.setAccessMenus(authPermissionInfo.menus);
     accessStore.setAccessCodes(authPermissionInfo.permissions);
+    loadedTerminal.value = terminalType.value;
     return authPermissionInfo;
   }
 
   function $reset() {
     loginLoading.value = false;
+    loadedTerminal.value = undefined;
   }
 
   return {
@@ -154,6 +162,7 @@
     authLogin,
     fetchUserInfo,
     loginLoading,
+    loadedTerminal,
     logout,
   };
 });

--
Gitblit v1.9.3