feat: 实现记住我功能并重构认证逻辑为统一的Auth工具类

This commit is contained in:
Ray.Hao
2025-05-21 17:40:14 +08:00
parent aee9443fe0
commit 521ba98d6a
11 changed files with 194 additions and 73 deletions

View File

@@ -1,6 +1,5 @@
import { useDictSync } from "@/composables/useDictSync";
import { Storage } from "@/utils/storage";
import { ACCESS_TOKEN_KEY } from "@/constants/cache-keys";
import { Auth } from "@/utils/auth";
// 用于防止重复初始化的状态标记
let isInitialized = false;
@@ -24,9 +23,8 @@ export function setupWebSocket() {
return;
}
// 检查token是否存在
const token = Storage.get(ACCESS_TOKEN_KEY, "");
if (!token) {
// 检查是否已登录
if (!Auth.isLoggedIn()) {
console.warn(
"[WebSocketPlugin] 未找到访问令牌WebSocket初始化已跳过。用户登录后将自动重新连接。"
);