import React, { lazy, Suspense, useEffect, useState } from 'react'; import Sidebar from '../../shared/ui/Sidebar'; import type { Item } from '../../shared/api-contract'; import { getHealth } from '../features/system/api'; import type { BuildInfo } from '../features/system/types'; // DeliveryRuleTarget 描述商品页跳转到自动化规则页时需要携带的目标信息。 export interface DeliveryRuleTarget { // cookieId 表示目标闲鱼账号标识。 cookieId: string; // itemId 表示目标商品标识。 itemId: string; // requestId 用于区分连续发起的跳转请求。 requestId: number; } // AuthenticatedShellProps 描述认证后应用壳需要的导航、权限和联动回调。 export interface AuthenticatedShellProps { // activeTab 表示当前正在展示的业务页面标识。 activeTab: string; // isAdmin 表示当前会话是否拥有管理员权限。 isAdmin: boolean; // collapsed 表示侧边栏是否处于折叠状态。 collapsed: boolean; // deliveryRuleTarget 表示待传递给规则页的商品发货目标。 deliveryRuleTarget?: DeliveryRuleTarget; // onToggleCollapsed 负责切换侧边栏折叠状态。 onToggleCollapsed: () => void; // onNavigate 负责切换业务页面并同步外部路由。 onNavigate: (tab: string) => void; // onLogout 负责注销当前会话并清理认证状态。 onLogout: () => void; // onConfigureDelivery 负责接收商品页发起的规则配置目标。 onConfigureDelivery: (target: DeliveryRuleTarget) => void; // onDeliveryTargetHandled 负责确认规则页已经消费跳转目标。 onDeliveryTargetHandled: () => void; } // Dashboard 是按需加载的仪表盘页面,避免首屏同步载入图表依赖。 const Dashboard = lazy(/* Dashboard 页面按路由激活时加载。 */ () => import('../features/dashboard/pages/Dashboard')); // AccountList 是按需加载的账号管理页面,避免未访问时载入账号弹窗和二维码代码。 const AccountList = lazy(/* AccountList 页面按路由激活时加载。 */ () => import('../features/accounts/pages/AccountList')); // OrderList 是按需加载的订单页面,避免首屏载入订单导入与刷新代码。 const OrderList = lazy(/* OrderList 页面按路由激活时加载。 */ () => import('../features/orders/pages/OrderList')); // CardList 是按需加载的卡密页面,避免首屏载入卡密批量处理代码。 const CardList = lazy(/* CardList 页面按路由激活时加载。 */ () => import('../features/cards/pages/CardList')); // ItemList 是按需加载的商品页面,避免首屏载入商品发布编辑器代码。 const ItemList = lazy(/* ItemList 页面按路由激活时加载。 */ () => import('../features/items/pages/ItemList')); // Settings 是按需加载的系统设置页面,仅在管理员访问时加载。 const Settings = lazy(/* Settings 页面按路由激活时加载。 */ () => import('../features/settings/pages/Settings')); // Rules 是按需加载的自动化规则页面,避免首屏载入规则编辑器代码。 const Rules = lazy(/* Rules 页面按路由激活时加载。 */ () => import('../features/rules/pages/Rules')); // Notifications 是按需加载的通知页面,避免首屏载入通知配置代码。 const Notifications = lazy(/* Notifications 页面按路由激活时加载。 */ () => import('../features/notifications/pages/Notifications')); // Chat 是按需加载的聊天页面,避免未访问时载入聊天历史和 WebSocket 视图。 const Chat = lazy(/* Chat 页面按路由激活时加载。 */ () => import('../features/chat/pages/Chat')); // PageLoading 展示路由页面代码加载期间的统一占位状态。 const PageLoading: React.FC = () => (