fix(*): 平台稳定性 - 修复会话隔离、运行时缓存与部署镜像更新链路

This commit is contained in:
ddcat666
2026-09-24 06:05:04 +08:00
parent 88abdd1b75
commit e77c26d2b0
32 changed files with 788 additions and 116 deletions

View File

@@ -1,5 +1,19 @@
const ACTIVE_USER_SCOPE_KEY = "infinite-canvas:active-user-scope";
const GUEST_SCOPE = "guest";
let userScopedPersistenceSuppressionDepth = 0;
export function withUserScopedPersistenceSuppressed<T>(operation: () => T) {
userScopedPersistenceSuppressionDepth += 1;
try {
return operation();
} finally {
userScopedPersistenceSuppressionDepth -= 1;
}
}
export function isUserScopedPersistenceSuppressed() {
return userScopedPersistenceSuppressionDepth > 0;
}
export function getActiveUserScope() {
if (typeof window === "undefined") return GUEST_SCOPE;
@@ -22,10 +36,12 @@ export const scopedLocalStorage = {
},
setItem: (name: string, value: string) => {
if (typeof window === "undefined") return;
if (isUserScopedPersistenceSuppressed()) return;
window.localStorage.setItem(scopedStorageKey(name), value);
},
removeItem: (name: string) => {
if (typeof window === "undefined") return;
if (isUserScopedPersistenceSuppressed()) return;
window.localStorage.removeItem(scopedStorageKey(name));
},
};