mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-09 19:46:37 +08:00
Before this change, even with "tight border" enabled, resizing the window from mobile to non-mobile does not use tight border. After this change, the "tight border" config is respected as expected.
21 lines
440 B
TypeScript
21 lines
440 B
TypeScript
import { create } from "zustand";
|
|
import { isMobileScreen } from "../utils";
|
|
|
|
interface Screen {
|
|
isMobile: boolean;
|
|
update: () => void;
|
|
}
|
|
|
|
export const useScreen = create<Screen>(set => {
|
|
const state = {
|
|
isMobile: isMobileScreen(),
|
|
update: () => set({ isMobile: isMobileScreen() }),
|
|
};
|
|
if (typeof window !== "undefined") {
|
|
window.addEventListener("resize", e => {
|
|
state.update();
|
|
});
|
|
}
|
|
return state;
|
|
});
|