From ee7ac8df8bce38add1f75baf876b49de94b9e00a Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期五, 16 十月 2026 17:58:33 +0800
Subject: [PATCH] feat(mes): 赋码管理绑定托盘支持未录入批次的袋码
---
src/store/auth.ts | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/src/store/auth.ts b/src/store/auth.ts
index d014bfa..a4776ec 100644
--- a/src/store/auth.ts
+++ b/src/store/auth.ts
@@ -1,13 +1,13 @@
-import type { AuthPermissionInfo, Recordable, UserInfo } from '../packages/types/src';
+import type { AuthPermissionInfo, Recordable, UserInfo } from '@vben/types';
import type { AuthApi } from '#/api';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
-import { LOGIN_PATH } from '../packages/constants/src';
-import { preferences } from '../packages/preferences/src';
-import { resetAllStores, useAccessStore, useUserStore } from '../packages/stores/src';
+import { LOGIN_PATH } from '@vben/constants';
+import { preferences } from '@vben/preferences';
+import { resetAllStores, useAccessStore, useUserStore } from '@vben/stores';
import { notification } from 'ant-design-vue';
import { defineStore } from 'pinia';
@@ -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