first commit

This commit is contained in:
liu
2026-07-13 15:23:29 +08:00
commit 50885a98c8
473 changed files with 33772 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
import {create, type StateCreator} from 'zustand';
import {createJSONStorage, devtools, persist} from "zustand/middleware";
import type {GlobalStoreState, GlobalStoreActions, GlobalStore} from "./types";
import {configTheme, defaultColorTheme} from "@/layout/theme.ts";
import type {LayoutType, ThemeProps} from "@/layout/typing.ts";
import {getWebInfo} from "@/api";
const globalState: GlobalStoreState = {
logo: "https://file.xinadmin.cn/file/favicons.ico",
title: "Xin Admin",
subtitle: "基于 Ant Design 的后台管理框架",
describe: "Xin Admin 是一个基于 Ant Design 的后台管理框架",
layout: "side",
themeConfig: { ...defaultColorTheme, ...configTheme },
themeDrawer: false,
};
const globalAction: StateCreator<GlobalStoreState, [], [], GlobalStoreActions> = (set) => ({
initWebInfo: async () => {
try {
const response = await getWebInfo();
if (response.data.data) {
set(response.data.data);
}
} catch (error) {
console.error('获取网站信息失败:', error);
}
},
setLayout: (layout: LayoutType) => {
set({ layout });
},
setThemeConfig: (themeConfig: ThemeProps) => {
set({ themeConfig });
},
setThemeDrawer: (themeDrawer: boolean) => {
set({ themeDrawer });
},
})
const useGlobalStore = create<GlobalStore>()(
devtools(
persist(
(...args) => ({
...globalState,
...globalAction(...args),
}),
{
name: 'global-storage',
storage: createJSONStorage(() => localStorage),
}
),
{ name: 'XinAdmin-Global' }
)
);
export type {GlobalStore, GlobalStoreState, GlobalStoreActions};
export default useGlobalStore;
+20
View File
@@ -0,0 +1,20 @@
import type {LayoutType, ThemeProps} from "@/layout/typing.ts";
export interface GlobalStoreState {
logo: string;
title: string;
subtitle: string;
describe: string;
layout: LayoutType;
themeConfig: ThemeProps;
themeDrawer: boolean;
}
export interface GlobalStoreActions {
setLayout: (layout: LayoutType) => void;
initWebInfo: () => Promise<void>;
setThemeConfig: (themeConfig: ThemeProps) => void;
setThemeDrawer: (themeDrawer: boolean) => void;
}
export type GlobalStore = GlobalStoreState & GlobalStoreActions;