This commit is contained in:
archer
2023-07-16 13:20:25 +08:00
parent 877aab858b
commit 98a5796592
6 changed files with 51 additions and 10 deletions

View File

@@ -7,7 +7,8 @@ type State = {
setLoading: (val: boolean) => null;
screenWidth: number;
setScreenWidth: (val: number) => void;
isPc: boolean;
isPc?: boolean;
initIsPc(val: boolean): void;
};
export const useGlobalStore = create<State>()(
@@ -27,7 +28,14 @@ export const useGlobalStore = create<State>()(
state.isPc = val < 900 ? false : true;
});
},
isPc: false
isPc: undefined,
initIsPc(val: boolean) {
if (get().isPc !== undefined) return;
set((state) => {
state.isPc = val;
});
}
}))
)
);