// import React from 'react'; import { type MetaFunction } from "@remix-run/node"; import { useLoaderData } from "@remix-run/react"; import { Card } from "~/components/ui/Card"; import { Button } from "~/components/ui/Button"; import { StatusBadge, links as statusBadgeLinks } from "~/components/ui/StatusBadge"; import { FileTag, links as fileTagLinks } from "~/components/ui/FileTag"; import { FileTypeTag, links as fileTypeTagLinks } from "~/components/ui/FileTypeTag"; import homeStyles from "~/styles/pages/home.css?url"; export const links = () => [ { rel: "stylesheet", href: homeStyles }, ...statusBadgeLinks(), ...fileTagLinks(), ...fileTypeTagLinks() ]; export const meta: MetaFunction = () => { return [ { title: "中国烟草AI合同及卷宗审核系统 - 首页" }, { name: "description", content: "AI审核系统首页" } ]; }; // API 响应的类型定义 interface StatsData { totalFiles: number; reviewedFiles: number; pendingFiles: number; passRate: number; } interface RecentFile { id: string; name: string; type: string; reviewStatus: string; updatedAt: string; } // interface LoaderData { // stats: StatsData; // recentFiles: RecentFile[]; // } // 模拟数据,实际项目中应该从API获取 export async function loader() { try { // 实际项目中这里应该是 API 调用 // const response = await fetch('/api/dashboard/stats'); // const stats: StatsData = await response.json(); // const filesResponse = await fetch('/api/files/recent'); // const recentFiles: RecentFile[] = await filesResponse.json(); // 模拟数据 const stats = { totalFiles: 156, reviewedFiles: 124, pendingFiles: 32, passRate: 92.5 } as StatsData; const recentFiles = [ { id: "1", name: "2023年度烟草专卖零售许可证.pdf", type: "专卖许可证", reviewStatus: "pass", updatedAt: "2023-12-24 14:30" }, { id: "2", name: "烟草制品购销合同(2023-12).docx", type: "合同文档", reviewStatus: "warning", updatedAt: "2023-12-23 09:15" }, { id: "3", name: "专卖管理处罚决定书(2023-145).pdf", type: "行政处罚决定书", reviewStatus: "fail", updatedAt: "2023-12-22 16:45" }, { id: "4", name: "2023年第四季度采购合同.docx", type: "合同文档", reviewStatus: "pass", updatedAt: "2023-12-20 11:20" }, { id: "5", name: "广告宣传协议书.pdf", type: "合同文档", reviewStatus: "pass", updatedAt: "2023-12-18 15:30" } ] as RecentFile[]; return Response.json({ stats, recentFiles }); } catch (error) { // 错误处理 console.error('Failed to fetch dashboard data:', error); return Response.json( { error: '获取数据失败,请稍后重试' }, { status: 500 } ); } } export default function Index() { const { stats, recentFiles } = useLoaderData(); return (
{/* 页面标识 */}

当前页面: 首页 (_index.tsx)

如果你看到这个提示,说明你正在浏览首页,而不是评查点列表页面。

查看路由诊断页面 | 通过原生链接访问评查点列表
{/* 统计卡片区域 */}
{/* 快捷访问区域 */}
{/* 最近文档区域 */} 查看全部} className="mt-6" >
{recentFiles.map((file: RecentFile) => (
{file.name}
· {file.updatedAt}
))}
); } // 统计卡片组件 interface StatCardProps { title: string; value: number | string; icon: string; trend?: { value: number; isUp: boolean; }; } function StatCard({ title, value, icon, trend }: StatCardProps) { return (
{title}
{value}
{trend && (
{trend.value}% 较上月
)}
); } // 快捷方式组件 interface ShortcutItemProps { icon: string; label: string; to: string; } function ShortcutItem({ icon, label, to }: ShortcutItemProps) { return ( ); }