new framwork

This commit is contained in:
archer
2023-06-09 12:57:42 +08:00
parent d9450bd7ee
commit ba9d9c3d5f
263 changed files with 12269 additions and 11599 deletions

View File

@@ -0,0 +1,49 @@
import { create } from 'zustand';
import { devtools } from 'zustand/middleware';
import { immer } from 'zustand/middleware/immer';
import type { InitDateResponse } from '@/pages/api/system/getInitData';
import { getInitData } from '@/api/system';
type State = {
initData: InitDateResponse;
loadInitData: () => Promise<void>;
loading: boolean;
setLoading: (val: boolean) => null;
screenWidth: number;
setScreenWidth: (val: number) => void;
isPc: boolean;
};
export const useGlobalStore = create<State>()(
devtools(
immer((set, get) => ({
initData: {
beianText: '',
googleVerKey: ''
},
async loadInitData() {
try {
const res = await getInitData();
set((state) => {
state.initData = res;
});
} catch (error) {}
},
loading: false,
setLoading: (val: boolean) => {
set((state) => {
state.loading = val;
});
return null;
},
screenWidth: 600,
setScreenWidth(val: number) {
set((state) => {
state.screenWidth = val;
state.isPc = val < 900 ? false : true;
});
},
isPc: false
}))
)
);