feat(web): 主题设置联动 — 扩展 ThemeConfig 品牌字段 + 设置页面表单
- ThemeConfig 接口增加 brand_name/brand_slogan/brand_features/brand_copyright - 新增 BrandConfig 接口和 getPublicBrand 公开品牌信息获取 - app store 增加 themeConfig 缓存和 loadThemeConfig 方法 - ThemeSettings 页面增加品牌设置表单(品牌名称/标语/特性/版权)
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { create } from 'zustand';
|
||||
import type { ThemeConfig } from '../api/themes';
|
||||
import { getTheme } from '../api/themes';
|
||||
|
||||
export type ThemeName = 'blue' | 'warm' | 'dark' | 'emerald';
|
||||
|
||||
@@ -49,16 +51,25 @@ function loadTheme(): ThemeName {
|
||||
interface AppState {
|
||||
theme: ThemeName;
|
||||
sidebarCollapsed: boolean;
|
||||
themeConfig: ThemeConfig | null;
|
||||
toggleSidebar: () => void;
|
||||
setTheme: (theme: ThemeName) => void;
|
||||
loadThemeConfig: () => Promise<void>;
|
||||
}
|
||||
|
||||
export const useAppStore = create<AppState>((set) => ({
|
||||
theme: loadTheme(),
|
||||
sidebarCollapsed: false,
|
||||
themeConfig: null,
|
||||
toggleSidebar: () => set((s) => ({ sidebarCollapsed: !s.sidebarCollapsed })),
|
||||
setTheme: (theme) => {
|
||||
try { localStorage.setItem(STORAGE_KEY, theme); } catch {}
|
||||
set({ theme });
|
||||
},
|
||||
loadThemeConfig: async () => {
|
||||
try {
|
||||
const config = await getTheme();
|
||||
set({ themeConfig: config });
|
||||
} catch {}
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user