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**: 更新单元测试以覆盖新增的工具函数及功能特性。
108 lines
2.8 KiB
TypeScript
108 lines
2.8 KiB
TypeScript
import { Box, Checkbox, Typography } from '@mui/material';
|
|
import { formatSize } from '@/utils/storageCleaner';
|
|
import { storageCleanerPageStyles } from '@/config/pageTheme';
|
|
|
|
interface OptionItemProps {
|
|
label: string;
|
|
checked: boolean;
|
|
size?: number;
|
|
isCount?: boolean;
|
|
onChange: () => void;
|
|
}
|
|
|
|
export default function OptionItem({
|
|
label,
|
|
checked,
|
|
size,
|
|
isCount = false,
|
|
onChange,
|
|
}: OptionItemProps) {
|
|
return (
|
|
<Box
|
|
sx={{
|
|
display: 'flex',
|
|
justifyContent: 'space-between',
|
|
alignItems: 'center',
|
|
py: 1,
|
|
px: { xs: 1, sm: 1.5 },
|
|
borderRadius: 3,
|
|
transition: 'all 0.25s cubic-bezier(0.4, 0, 0.2, 1)',
|
|
bgcolor: checked ? 'rgba(255, 152, 0, 0.05)' : 'transparent',
|
|
border: `1px solid ${checked ? 'rgba(255, 152, 0, 0.2)' : 'transparent'}`,
|
|
'&:hover': {
|
|
bgcolor: checked ? 'rgba(255, 152, 0, 0.1)' : 'rgba(0, 0, 0, 0.02)',
|
|
transform: 'translateY(-1px)',
|
|
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.08)',
|
|
},
|
|
}}
|
|
>
|
|
<Box sx={{ flex: 1, minWidth: 0, mr: 1.5 }}>
|
|
<Typography
|
|
variant="body2"
|
|
fontWeight={700}
|
|
color={checked ? storageCleanerPageStyles.warningColor : 'text.primary'}
|
|
sx={{
|
|
fontSize: '0.75rem',
|
|
display: 'block',
|
|
lineHeight: 1.2,
|
|
whiteSpace: 'nowrap',
|
|
overflow: 'hidden',
|
|
textOverflow: 'ellipsis',
|
|
transition: 'color 0.2s',
|
|
}}
|
|
>
|
|
{label}
|
|
</Typography>
|
|
{size !== undefined && size > 0 ? (
|
|
<Typography
|
|
variant="caption"
|
|
sx={{
|
|
color: 'text.secondary',
|
|
fontSize: '0.65rem',
|
|
fontWeight: 600,
|
|
display: 'block',
|
|
mt: 0.3,
|
|
lineHeight: 1,
|
|
whiteSpace: 'nowrap',
|
|
opacity: 0.8,
|
|
}}
|
|
>
|
|
{isCount ? `${size} 个` : formatSize(size)}
|
|
</Typography>
|
|
) : (
|
|
<Typography
|
|
variant="caption"
|
|
sx={{
|
|
color: 'grey.400',
|
|
fontSize: '0.65rem',
|
|
fontWeight: 500,
|
|
display: 'block',
|
|
mt: 0.3,
|
|
lineHeight: 1,
|
|
fontStyle: 'italic',
|
|
}}
|
|
>
|
|
无数据
|
|
</Typography>
|
|
)}
|
|
</Box>
|
|
<Checkbox
|
|
size="small"
|
|
checked={checked}
|
|
onChange={onChange}
|
|
color="warning"
|
|
sx={{
|
|
p: 0.6,
|
|
'& .MuiSvgIcon-root': {
|
|
fontSize: 18,
|
|
transition: 'transform 0.2s',
|
|
},
|
|
'&:hover .MuiSvgIcon-root': {
|
|
transform: 'scale(1.1)',
|
|
},
|
|
}}
|
|
/>
|
|
</Box>
|
|
);
|
|
}
|