fix: nextjs 14.2.24 cannot auto create local storage (#4249) (#4250)

This commit is contained in:
Archer
2025-03-20 11:40:47 +08:00
committed by GitHub
parent de87639fce
commit 9a1fff74fd
2 changed files with 28 additions and 19 deletions

View File

@@ -1,14 +1,10 @@
import { create } from 'zustand';
import { devtools, persist } from 'zustand/middleware';
import { immer } from 'zustand/middleware/immer';
import { customAlphabet } from 'nanoid';
const nanoid = customAlphabet(
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWSYZ1234567890_',
24
);
type State = {
localUId: string;
localUId?: string;
setLocalUId: (localUId: string) => void;
loaded: boolean;
};
@@ -16,7 +12,10 @@ export const useShareChatStore = create<State>()(
devtools(
persist(
immer((set, get) => ({
localUId: `shareChat-${Date.now()}-${nanoid()}`,
localUId: undefined,
setLocalUId(localUId: string) {
set({ localUId });
},
loaded: false
})),
{