57ea4d9858
- **docs**: 完善组件注释、README 目录结构及 AGENTS.md 文档。 - **refactor**: - 提取通用 `PageHeader`、`Button`、`DashboardCard` 及 `ErrorBoundary` 组件。 - 重构消息通信机制,采用 `@webext-core/messaging` 实现类型安全。 - 将全局通知系统重构为 `SnackbarProvider` (后合并至 `GlobalSnackbar`)。 - 迁移样式系统至 MUI 主题,移除冗余 CSS。 - 优化路由配置,支持独立标签页模式及页面懒加载。 - 移除未使用文件、URL 工具及表单映射相关功能。 - **feat**: - 新增配置导出功能(JSON)及状态提示。 - 新增侧边栏状态变化通知机制。 - 新增文本统计及 JWT 解析工具。 - 优化二维码生成与解析逻辑,换用更轻量的 `qrious` 和 `qr-scanner`。 - 增强高亮器功能,支持闪烁效果及 Shadow DOM 穿透。 - **style**: 优化仪表盘响应式网格布局及 UI 细节。 - **fix**: 修复 `useStorageState` 依赖缺失及路由初始化性能问题。 - **test**: 更新单元测试以覆盖新增的工具函数及功能特性。
72 lines
2.3 KiB
TypeScript
72 lines
2.3 KiB
TypeScript
import RouterProvider from '@/providers/RouterProvider';
|
|
import TopBar from '@/components/TopBar';
|
|
import RouterContainer from '@/components/RouterContainer';
|
|
import ErrorBoundary from '@/components/ErrorBoundary';
|
|
import { globalStyles } from '@/config/pageTheme';
|
|
import { SnackbarProvider } from '@/components/GlobalSnackbar';
|
|
import { Box } from '@mui/material';
|
|
import { getEntryPointType } from '@/config/features';
|
|
import { useMemo } from 'react';
|
|
|
|
export default function App() {
|
|
// 打开Chrome扩展选项页面,需确保manifest中已配置options_page或options_ui
|
|
const handleOpenOptions = () => {
|
|
chrome.runtime.openOptionsPage().catch(console.error);
|
|
};
|
|
|
|
const entryType = useMemo(() => getEntryPointType(), []);
|
|
|
|
const routerConfig = useMemo(() => {
|
|
if (entryType === 'tab') {
|
|
return {
|
|
syncKey: 'app/tabRoute' as const,
|
|
visiblePagesKey: 'app/tabVisiblePages' as const,
|
|
pageOrderKey: 'app/tabPageOrder' as const,
|
|
};
|
|
}
|
|
return {
|
|
syncKey: 'app/popupRoute' as const,
|
|
visiblePagesKey: 'app/popupVisiblePages' as const,
|
|
pageOrderKey: 'app/popupPageOrder' as const,
|
|
};
|
|
}, [entryType]);
|
|
|
|
return (
|
|
<RouterProvider
|
|
syncKey={routerConfig.syncKey}
|
|
visiblePagesKey={routerConfig.visiblePagesKey}
|
|
pageOrderKey={routerConfig.pageOrderKey}
|
|
>
|
|
<SnackbarProvider initialOptions={{ autoHideDuration: 1500 }}>
|
|
<Box
|
|
className="app"
|
|
sx={{
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
width: '400px',
|
|
maxWidth: '400px',
|
|
minWidth: '400px',
|
|
height: '600px',
|
|
minHeight: '600px',
|
|
overflow: 'hidden',
|
|
backgroundColor: globalStyles.backgroundColor,
|
|
// 仅在明确的大屏幕(如独立页面或侧边栏拉伸)下才允许扩展
|
|
'@media screen and (min-width: 600px)': {
|
|
width: '100vw',
|
|
maxWidth: 'none',
|
|
minWidth: 'none',
|
|
height: '100vh',
|
|
minHeight: 'none',
|
|
},
|
|
}}
|
|
>
|
|
<TopBar onOpenOptions={handleOpenOptions} />
|
|
<ErrorBoundary>
|
|
<RouterContainer />
|
|
</ErrorBoundary>
|
|
</Box>
|
|
</SnackbarProvider>
|
|
</RouterProvider>
|
|
);
|
|
}
|