refactor: Business logic and dependencies updates
- 核心服务代码更新 (db, server, auth, proxy) - Agent 相关模块更新 (mindspace, experience) - 前端组件和 hooks 更新 - 数据库 schema 更新 - 依赖版本更新
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
const LEGACY_SESSION_KEY = 'tkmind-h5-session-id';
|
||||
|
||||
export function resolveSessionStorageKey(userId?: string | null): string {
|
||||
return userId ? `${LEGACY_SESSION_KEY}:${userId}` : LEGACY_SESSION_KEY;
|
||||
}
|
||||
|
||||
export function readStoredSessionId(userId?: string | null): string | null {
|
||||
if (userId) {
|
||||
// Only use per-user scoped storage. Do not migrate the legacy global key,
|
||||
// which may belong to another account on the same browser profile.
|
||||
return localStorage.getItem(resolveSessionStorageKey(userId));
|
||||
}
|
||||
return localStorage.getItem(LEGACY_SESSION_KEY);
|
||||
}
|
||||
|
||||
export function writeStoredSessionId(userId: string | null | undefined, sessionId: string) {
|
||||
localStorage.setItem(resolveSessionStorageKey(userId), sessionId);
|
||||
}
|
||||
|
||||
export function clearStoredSessionId(userId?: string | null) {
|
||||
localStorage.removeItem(resolveSessionStorageKey(userId));
|
||||
if (!userId) {
|
||||
localStorage.removeItem(LEGACY_SESSION_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
export function clearAllStoredSessionIds() {
|
||||
const keysToRemove: string[] = [];
|
||||
for (let i = 0; i < localStorage.length; i += 1) {
|
||||
const key = localStorage.key(i);
|
||||
if (!key) continue;
|
||||
if (key === LEGACY_SESSION_KEY || key.startsWith(`${LEGACY_SESSION_KEY}:`)) {
|
||||
keysToRemove.push(key);
|
||||
}
|
||||
}
|
||||
for (const key of keysToRemove) {
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user