'use client'; import { create } from 'zustand'; import type { CustomsDeclaration, InspectionState, Notification, User } from '@/types'; interface AppState { user: User | null; notifications: Notification[]; selectedCustoms: CustomsDeclaration | null; inspection: InspectionState | null; setUser: (user: User | null) => void; addNotification: (notification: Notification) => void; markNotificationRead: (id: string) => void; setSelectedCustoms: (customs: CustomsDeclaration | null) => void; setInspection: (inspection: InspectionState | null) => void; updateInspectionStatus: (status: InspectionState['status']) => void; } export const useAppStore = create((set) => ({ user: { name: '张三', role: '海关查验员' }, notifications: [ { id: '1', title: '系统通知', message: '远程查验前端已连接真实后端接口', time: '当前', read: false }, ], selectedCustoms: null, inspection: null, setUser: (user) => set({ user }), addNotification: (notification) => set((state) => ({ notifications: [notification, ...state.notifications] })), markNotificationRead: (id) => set((state) => ({ notifications: state.notifications.map((notification) => ( notification.id === id ? { ...notification, read: true } : notification )), })), setSelectedCustoms: (selectedCustoms) => set({ selectedCustoms }), setInspection: (inspection) => set({ inspection }), updateInspectionStatus: (status) => set((state) => ({ inspection: state.inspection ? { ...state.inspection, status } : null, })), }));