0379f96e80
* feat(formRecognizer): 添加表单识别功能及相关组件 添加表单识别功能,包括以下内容: 1. 在路由配置中添加表单识别页面 2. 实现表单识别页面和侧边栏面板 3. 添加表单数据生成工具类 4. 实现与内容脚本的通信机制 5. 添加faker-js依赖用于生成测试数据 6. 支持不同入口点(popup/sidepanel)的组件渲染 * refactor(消息通信): 重构消息通信机制并集中管理消息协议 将分散的消息协议和通信逻辑集中到 utils/messages.ts 中 移除旧的 messages.tsx 文件并更新相关引用 添加消息动作枚举和类型定义,提高类型安全性 优化内容脚本注入失败时的处理逻辑
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { Box } from '@mui/material';
|
|
import { ROUTES, getEntryPointType } from '@/config/routes';
|
|
import { useRouter } from '@/providers/RouterProvider';
|
|
import { useMemo } from 'react';
|
|
|
|
export default function RouterContainer() {
|
|
const { currentPage, isLoaded } = useRouter();
|
|
|
|
const animationClass = useMemo(() => {
|
|
return currentPage === 'dashboard' ? 'page-transition-dashboard' : 'page-transition-enter';
|
|
}, [currentPage]);
|
|
|
|
const entryPointType = useMemo(() => {
|
|
return getEntryPointType();
|
|
}, []);
|
|
|
|
if (!isLoaded) {
|
|
return <div className="app">Loading...</div>;
|
|
}
|
|
|
|
const currentRoute = ROUTES.find((route) => route.key === currentPage);
|
|
const Component = currentRoute ? currentRoute.components[entryPointType] : null;
|
|
|
|
return (
|
|
<Box
|
|
key={currentPage} // Trigger animation on navigation
|
|
className={animationClass}
|
|
sx={{
|
|
flex: 1,
|
|
overflowY: 'auto',
|
|
overflowX: 'hidden',
|
|
scrollbarGutter: 'stable',
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
}}
|
|
>
|
|
{Component && <Component />}
|
|
</Box>
|
|
);
|
|
}
|