mirror of
https://github.com/basketikun/infinite-canvas.git
synced 2026-08-05 17:04:27 +08:00
e319481976
- 统一调整 admin.ts 文件中的接口定义缩进格式 - 优化 animated-theme-toggler.tsx 组件的代码结构和缩进 - 规范 app-config-modal.tsx 中 JSX 元素的嵌套格式 - 整理 app-providers.tsx 中的组件层级缩进 - 标准化 app-theme.ts 中的对象属性缩进格式
35 lines
968 B
TypeScript
35 lines
968 B
TypeScript
import localforage from "localforage";
|
|
import type { StateStorage } from "zustand/middleware";
|
|
|
|
localforage.config({
|
|
name: "infinite-canvas",
|
|
storeName: "app_state",
|
|
});
|
|
|
|
export const localForageStorage: StateStorage = {
|
|
getItem: async (name) => {
|
|
if (typeof window === "undefined") return null;
|
|
try {
|
|
return (await localforage.getItem<string>(name)) || null;
|
|
} catch {
|
|
return window.localStorage.getItem(name);
|
|
}
|
|
},
|
|
setItem: async (name, value) => {
|
|
if (typeof window === "undefined") return;
|
|
try {
|
|
await localforage.setItem(name, value);
|
|
} catch {
|
|
window.localStorage.setItem(name, value);
|
|
}
|
|
},
|
|
removeItem: async (name) => {
|
|
if (typeof window === "undefined") return;
|
|
try {
|
|
await localforage.removeItem(name);
|
|
} catch {
|
|
window.localStorage.removeItem(name);
|
|
}
|
|
},
|
|
};
|