refactor(*): 代码质量 - 优化前后端实现并完善协议与画布验证
This commit is contained in:
@@ -20,7 +20,7 @@ type CanvasHistoryStore = {
|
||||
clearDeletedHistory: () => void;
|
||||
};
|
||||
|
||||
export const CANVAS_HISTORY_STORE_KEY = "infinite-canvas:deleted_history_store";
|
||||
export const CANVAS_HISTORY_STORE_KEY = "yingce:deleted_history_store";
|
||||
|
||||
const historyStorage: PersistStorage<CanvasHistoryStore> = {
|
||||
getItem: async (name) => {
|
||||
|
||||
@@ -47,7 +47,7 @@ type CanvasStore = {
|
||||
};
|
||||
|
||||
const initialViewport: ViewportTransform = { x: 0, y: 0, k: 1 };
|
||||
export const CANVAS_STORE_KEY = "infinite-canvas:canvas_store";
|
||||
export const CANVAS_STORE_KEY = "yingce:canvas_store";
|
||||
type PersistedCanvasState = Pick<CanvasStore, "projects">;
|
||||
type QueuedCanvasPersist = {
|
||||
name: string;
|
||||
@@ -85,7 +85,7 @@ type CanvasStorageLockOptions = {
|
||||
requireCrossRealmLock?: boolean;
|
||||
};
|
||||
|
||||
const CANVAS_STORAGE_LOCK_PREFIX = "infinite-canvas:canvas-generation-storage-lock:";
|
||||
const CANVAS_STORAGE_LOCK_PREFIX = "yingce:canvas-generation-storage-lock:";
|
||||
const canvasStorageTails = new Map<string, Promise<void>>();
|
||||
|
||||
function runWithBrowserCanvasStorageLock<T>(scope: string, operation: () => Promise<T>, options: CanvasStorageLockOptions) {
|
||||
|
||||
@@ -12,7 +12,7 @@ export const useCanvasThemeStore = create<CanvasThemeStore>()(
|
||||
persist(
|
||||
(set) => ({ theme: DEFAULT_CANVAS_COLOR_THEME, active: false, setTheme: (theme) => { if (theme === "light" || theme === "dark") set({ theme }); } }),
|
||||
{
|
||||
name: "infinite-canvas:canvas-theme",
|
||||
name: "yingce:canvas-theme",
|
||||
partialize: ({ theme }) => ({ theme }),
|
||||
merge: (persisted, current) => {
|
||||
const theme = (persisted as Partial<CanvasThemeStore> | null)?.theme;
|
||||
|
||||
@@ -75,7 +75,7 @@ type AssetStore = {
|
||||
cleanupImages: (extra?: unknown) => Promise<void>;
|
||||
};
|
||||
|
||||
export const ASSET_STORE_KEY = "infinite-canvas:asset_store";
|
||||
export const ASSET_STORE_KEY = "yingce:asset_store";
|
||||
|
||||
type PersistedAssetState = Pick<AssetStore, "assets">;
|
||||
type ObservedAssetPersist = {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { localForageStorageForScope } from "@/lib/localforage-storage";
|
||||
import type { PluginInstallation, PluginManifest, PluginManifestV2 } from "@/lib/plugins/plugin-types";
|
||||
import type { PluginState } from "@/services/api/plugins";
|
||||
|
||||
export const PLUGIN_STORE_KEY = "infinite-canvas:plugin-store";
|
||||
export const PLUGIN_STORE_KEY = "yingce:plugin-store";
|
||||
|
||||
type PluginStore = {
|
||||
hydrated: boolean;
|
||||
|
||||
@@ -18,7 +18,7 @@ export const useThemeStore = create<ThemeStore>()(
|
||||
setTheme: (next) => set((state) => (VALID_THEMES.includes(next) ? { theme: next } : state)),
|
||||
}),
|
||||
{
|
||||
name: "infinite-canvas:theme_store",
|
||||
name: "yingce:theme_store",
|
||||
// 持久化恢复校验:旧版本/坏 session 写入的非法值回退到 light,
|
||||
// 避免 canvasThemes[非法值] = undefined 触发 "reading 'node'" 崩溃
|
||||
merge: (persisted, current) => {
|
||||
|
||||
Reference in New Issue
Block a user