Spaces:
Sleeping
Sleeping
File size: 1,123 Bytes
d629cd4 f45e448 d629cd4 426f2a4 d629cd4 426f2a4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | 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 }),
}));
|