import { create } from "zustand";

interface State {
    isCollapse: boolean;
    isHasDesktop: boolean | undefined;
}

interface Action {
    setCollapse: (value: boolean) => void;
    setHasDesktop: (value: boolean) => void;
}

const initialState: State = {
    // 是否展开侧边栏
    isCollapse: false,
    // 是否含有快应用
    isHasDesktop: undefined,
};

/**
 * @description 系统配置
 */
export const useSystemStore = create<State & Action>()((set, get) => {
    return {
        ...initialState,
        setCollapse: (value) => set((state) => ({ ...state, isCollapse: value })),
        setHasDesktop: (value) => set((state) => ({ ...state, isHasDesktop: value })),
        reset: () => set(initialState),
    };
});
