mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-17 14:33:41 +08:00
fix build error
This commit is contained in:
@@ -6,6 +6,9 @@ const localStorage = safeLocalStorage();
|
||||
|
||||
class IndexedDBStorage implements StateStorage {
|
||||
public async getItem(name: string): Promise<string | null> {
|
||||
if (typeof window === "undefined") {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const value = (await get(name)) || localStorage.getItem(name);
|
||||
return value;
|
||||
@@ -15,6 +18,9 @@ class IndexedDBStorage implements StateStorage {
|
||||
}
|
||||
|
||||
public async setItem(name: string, value: string): Promise<void> {
|
||||
if (typeof window === "undefined") {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const _value = JSON.parse(value);
|
||||
if (!_value?.state?._hasHydrated) {
|
||||
|
||||
@@ -35,7 +35,7 @@ export function createPersistStore<T extends object, M>(
|
||||
persistOptions: SecondParam<typeof persist<T & M & MakeUpdater<T>>>,
|
||||
) {
|
||||
// TODO: merge 报错,很离谱,后续再排查
|
||||
// persistOptions.storage = createJSONStorage(() => indexedDBStorage);
|
||||
persistOptions.storage = createJSONStorage(() => indexedDBStorage);
|
||||
const oldOonRehydrateStorage = persistOptions?.onRehydrateStorage;
|
||||
persistOptions.onRehydrateStorage = (state) => {
|
||||
oldOonRehydrateStorage?.(state);
|
||||
|
||||
Reference in New Issue
Block a user