Spaces:
Sleeping
Sleeping
| import { create } from 'zustand'; | |
| interface User { | |
| id: number; | |
| email: string; | |
| nickname: string; | |
| role: string; | |
| isVip?: boolean; | |
| } | |
| interface AuthState { | |
| user: User | null; | |
| token: string | null; | |
| setAuth: (user: User, token: string) => void; | |
| logout: () => void; | |
| } | |
| export const useAuthStore = create<AuthState>((set) => ({ | |
| user: null, | |
| token: null, | |
| setAuth: (user, token) => { | |
| localStorage.setItem('token', token); | |
| set({ user, token }); | |
| }, | |
| logout: () => { | |
| localStorage.removeItem('token'); | |
| set({ user: null, token: null }); | |
| }, | |
| })); | |
| export interface NavLink { | |
| label: string; | |
| value: string; | |
| } | |
| export interface Banner { | |
| imageUrl: string; | |
| linkUrl: string; | |
| } | |
| export interface UiConfig { | |
| siteName: string; | |
| logo: string; | |
| footerText: string; | |
| heroBackground?: string; | |
| navLinks: NavLink[]; | |
| banners?: Banner[]; | |
| memberFee?: number; | |
| } | |
| interface ConfigState { | |
| uiConfig: UiConfig | null; | |
| setUiConfig: (config: UiConfig) => void; | |
| } | |
| export const useConfigStore = create<ConfigState>((set) => ({ | |
| uiConfig: null, | |
| setUiConfig: (uiConfig) => set({ uiConfig }), | |
| })); | |