feat(runtime): 即梦本机运行时 - 接入安全生成闭环与桌面本机渠道
Refs #225 Co-authored-by: zkhyww <127009345+zkhyww@users.noreply.github.com>
This commit is contained in:
1 parent
8f2232feee
commit
57e1820f41
179 files changed
+49746
-1897
No files matched your search
@@ -8,32 +8,22 @@ localforage.config({
|
||||
storeName: "app_state",
|
||||
});
|
||||
|
||||
export const localForageStorage: StateStorage = {
|
||||
getItem: async (name) => {
|
||||
if (typeof window === "undefined") return null;
|
||||
const key = scopedStorageKey(name);
|
||||
try {
|
||||
return (await localforage.getItem<string>(key)) || null;
|
||||
} catch {
|
||||
return window.localStorage.getItem(key);
|
||||
}
|
||||
},
|
||||
setItem: async (name, value) => {
|
||||
if (typeof window === "undefined") return;
|
||||
const key = scopedStorageKey(name);
|
||||
try {
|
||||
await localforage.setItem(key, value);
|
||||
} catch {
|
||||
window.localStorage.setItem(key, value);
|
||||
}
|
||||
},
|
||||
removeItem: async (name) => {
|
||||
if (typeof window === "undefined") return;
|
||||
const key = scopedStorageKey(name);
|
||||
try {
|
||||
await localforage.removeItem(key);
|
||||
} catch {
|
||||
window.localStorage.removeItem(key);
|
||||
}
|
||||
},
|
||||
};
|
||||
export function localForageStorageForScope(scope?: string): StateStorage {
|
||||
const keyFor = (name: string) => scopedStorageKey(name, scope);
|
||||
return {
|
||||
getItem: async (name) => {
|
||||
if (typeof window === "undefined") return null;
|
||||
return (await localforage.getItem<string>(keyFor(name))) || null;
|
||||
},
|
||||
setItem: async (name, value) => {
|
||||
if (typeof window === "undefined") return;
|
||||
await localforage.setItem(keyFor(name), value);
|
||||
},
|
||||
removeItem: async (name) => {
|
||||
if (typeof window === "undefined") return;
|
||||
await localforage.removeItem(keyFor(name));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export const localForageStorage: StateStorage = localForageStorageForScope();
|
||||
Reference in new issue
Block a user