fix:修复所有的包导入错误问题

This commit is contained in:
2026-06-09 18:30:49 +08:00
parent 6e64ed35f4
commit 016bc6fd2c
13 changed files with 69 additions and 44 deletions
+10 -6
View File
@@ -6,7 +6,9 @@
*
* 注:仅在浏览器环境可用;SSR/Server Components 中调用会抛错。
*/
import { authStorage } from "../data/storage/auth_storage";
import { AuthStorage } from "../data/storage/auth/auth_storage";
import { SpAsyncUtil } from "./storage";
import { StorageKeys } from "../data/storage/storage_keys";
export class DeviceIdentifier {
private cachedId: string | null = null;
@@ -30,16 +32,18 @@ export class DeviceIdentifier {
/**
* 重置缓存与持久化(用于测试或多账号切换)
*/
reset(): void {
async reset(): Promise<void> {
this.cachedId = null;
this.initPromise = null;
authStorage.removeDeviceId();
await SpAsyncUtil.remove(StorageKeys.deviceId);
}
private async initialize(): Promise<string> {
// 1. 优先从 localStorage 读取
const stored = authStorage.getDeviceId();
if (stored) return stored;
const storedR = await AuthStorage.getInstance().getDeviceId();
if (storedR.success && storedR.data && storedR.data.length > 0) {
return storedR.data;
}
// 2. SSR/Node 环境守卫:调用方必须保证在浏览器中调用
if (typeof window === "undefined") {
@@ -55,7 +59,7 @@ export class DeviceIdentifier {
const result = await fp.get();
// 4. 持久化
authStorage.setDeviceId(result.visitorId);
await AuthStorage.getInstance().setDeviceId(result.visitorId);
return result.visitorId;
}
}