import { useState, useEffect } from 'react'; import { useNavigate, Form } from '@remix-run/react'; import { type MetaFunction, type ActionFunctionArgs, LoaderFunctionArgs, redirect } from "@remix-run/node"; import styles from "~/styles/pages/home.css?url"; import dayjs from 'dayjs'; // import { getUserSession, logout } from "~/root"; export const links = () => [ { rel: "stylesheet", href: styles } ]; export const meta: MetaFunction = () => { return [ { title: "中国烟草AI合同及卷宗审核系统 - 首页" }, { name: "description", content: "中国烟草AI合同及卷宗审核系统首页" }, ]; }; // 处理登出请求 export async function action({ request }: ActionFunctionArgs) { const formData = await request.formData(); const intent = formData.get("intent"); if (intent === "logout") { // return logout(request); } return null; } // 验证用户登录状态 // export async function loader({ request }: LoaderFunctionArgs) { // const { isAuthenticated } = await getUserSession(request); // if (!isAuthenticated) { // return redirect("/login"); // } // return Response.json({ isAuthenticated }); // } export default function Index() { const navigate = useNavigate(); const [currentDateTime, setCurrentDateTime] = useState({ date: '', time: '' }); // 更新日期时间 useEffect(() => { const updateDateTime = () => { const now = dayjs(); // 格式化日期: YYYY/MM/DD setCurrentDateTime({ date: now.format('YYYY/MM/DD'), time: now.format('HH:mm:ss') }); }; // 初始化时间 updateDateTime(); // 每秒更新一次 const timerID = setInterval(updateDateTime, 1000); return () => clearInterval(timerID); }, []); // 处理模块点击 const handleModuleClick = (path: string) => { navigate(path); }; // 处理键盘事件 const handleKeyDown = (path: string, e: React.KeyboardEvent) => { if (e.key === 'Enter' || e.key === ' ') { handleModuleClick(path); } }; // 处理登出 const handleLogout = () => { // 使用Form组件提交登出请求 const form = document.getElementById('logout-form') as HTMLFormElement; if (form) { form.submit(); } }; return (
{/* 登出表单 - 隐藏 */}
{/* 头部 */}
中国烟草
中国烟草 CHINA TOBACCO
{currentDateTime.date} {currentDateTime.time}
用户头像 系统管理员
{/* 主要内容 */}

- 欢迎来到智慧法务平台 -

{/* 合同管理模块 */}
handleModuleClick('/documents')} onKeyDown={(e) => handleKeyDown('/documents', e)} role="button" tabIndex={0} aria-label="合同管理" > 合同管理
{/* 案卷智能评查模块 */}
handleModuleClick('/home')} onKeyDown={(e) => handleKeyDown('/home', e)} role="button" tabIndex={0} aria-label="案卷智能评查" > 案卷智能评查
{/* 智慧法务大模型模块 */}
handleModuleClick('/prompts')} onKeyDown={(e) => handleKeyDown('/prompts', e)} role="button" tabIndex={0} aria-label="智慧法务大模型" > 智慧法务大模型
{/* 底部山水背景 */}
); }