4850c92365
* feat(formRecognizer): 添加表单识别功能及相关组件 添加表单识别功能,包括以下内容: 1. 在路由配置中添加表单识别页面 2. 实现表单识别页面和侧边栏面板 3. 添加表单数据生成工具类 4. 实现与内容脚本的通信机制 5. 添加faker-js依赖用于生成测试数据 6. 支持不同入口点(popup/sidepanel)的组件渲染 * refactor(消息通信): 重构消息通信机制并集中管理消息协议 将分散的消息协议和通信逻辑集中到 utils/messages.ts 中 移除旧的 messages.tsx 文件并更新相关引用 添加消息动作枚举和类型定义,提高类型安全性 优化内容脚本注入失败时的处理逻辑 * feat(QR码): 添加粘贴图片功能并优化上传组件 添加全局粘贴事件监听,支持从剪贴板直接粘贴二维码图片进行解析。重构上传组件为独立组件QrCodeUploader,包含拖拽上传、预览、进度显示和错误处理功能。优化页面样式和用户体验。 - 在QrCodePage添加粘贴事件监听 - 创建QrCodeUploader组件整合上传功能 - 更新测试用例格式 - 调整多个页面的背景色样式 * feat(表单识别): 新增表单识别页面功能与模板管理 - 添加表单识别页面样式配置 - 实现表单字段扫描与展示功能 - 新增数据模板管理工具类 - 添加数据验证工具类 - 扩展表单识别页面功能,包括操作历史记录 - 支持模板的导入导出功能 - 优化表单填充操作的用户体验 * feat(消息系统): 添加标签页刷新功能 在消息系统中新增 RELOAD_TAB 动作类型和 tabId 字段,用于处理标签页刷新请求 修改 StorageCleanerPage 使用后台脚本发送刷新请求,确保弹窗关闭后仍能执行 在 background.ts 中添加标签页刷新处理逻辑,包括错误处理和响应返回 * refactor(theme): 重构主题颜色和样式配置 - 更新主题颜色以满足 WCAG AA 可访问性标准 - 提取全局样式配置到统一变量 - 使用语义化颜色变量替换硬编码值 - 为输入框样式创建统一配置 * feat: add URL entry management components and QR code generation feature - Introduced `UrlEntryItem` and `UrlEntryList` components for displaying and managing URL entries. - Added `UrlToQrCodeSection` component for generating QR codes from URLs with download and copy functionality. - Implemented `AutoRefreshToggle`, `CleaningResult`, `DomainHeader`, `ErrorDisplay`, `OptionItem`, and `StorageOptionsGrid` components for enhanced user interface in storage cleaning. - Created custom hooks `useStorageCleaner` and `useStorageState` for managing storage-related states and preferences. - Added utility hook `useUrlPreferences` for handling URL entry preferences. * feat: 新增时间戳转换器和相关组件,优化时间戳页面功能 * Refactor message handling and storage cleaning logic * feat: 添加 GitHub Actions CI/CD 工作流,支持自动化构建与发布
229 lines
6.8 KiB
TypeScript
229 lines
6.8 KiB
TypeScript
import {
|
|
TextField,
|
|
Select,
|
|
MenuItem,
|
|
Stack,
|
|
Typography,
|
|
Box,
|
|
Container,
|
|
alpha,
|
|
} from '@mui/material';
|
|
import GlobalSnackbar, { useSnackbar } from '@/components/GlobalSnackbar';
|
|
import AccessTimeIcon from '@mui/icons-material/AccessTime';
|
|
import Button from '@/components/Button';
|
|
import { ZONES, globalStyles, timestampPageStyles } from '@/config/pageTheme';
|
|
import LiveClock from './components/LiveClock';
|
|
import ResultView from './components/ResultView';
|
|
import { useTimestampConverter } from './hooks/useTimestampConverter';
|
|
|
|
export default function TimestampPage() {
|
|
const { snackbarProps, showMessage } = useSnackbar({ autoHideDuration: 1500 });
|
|
const {
|
|
mode,
|
|
tsInput,
|
|
dtInput,
|
|
unit,
|
|
zone,
|
|
result,
|
|
error,
|
|
setMode,
|
|
setTsInput,
|
|
setDtInput,
|
|
setUnit,
|
|
setZone,
|
|
handleUseNow,
|
|
convert,
|
|
} = useTimestampConverter();
|
|
|
|
return (
|
|
<Box sx={{ bgcolor: globalStyles.backgroundColor, minHeight: '100%', pb: 3 }}>
|
|
<Container sx={{ py: 2, bgcolor: globalStyles.backgroundColor }}>
|
|
{/* Header with Icon */}
|
|
<Stack direction="row" spacing={1.5} alignItems="center" sx={{ mb: 2.5 }}>
|
|
<Box
|
|
sx={{
|
|
p: 1,
|
|
borderRadius: 2.5,
|
|
bgcolor: alpha(timestampPageStyles.primaryColor, 0.1),
|
|
color: timestampPageStyles.primaryColor,
|
|
display: 'flex',
|
|
}}
|
|
>
|
|
<AccessTimeIcon sx={{ fontSize: 20 }} />
|
|
</Box>
|
|
<Box sx={{ flex: 1 }}>
|
|
<Typography
|
|
variant="subtitle1"
|
|
fontWeight={900}
|
|
sx={{ letterSpacing: '-0.5px', lineHeight: 1.2 }}
|
|
>
|
|
时间戳转换
|
|
</Typography>
|
|
<Typography variant="caption" color="text.secondary" sx={{ fontWeight: 600 }}>
|
|
Unix 毫秒数转换与格式化
|
|
</Typography>
|
|
</Box>
|
|
</Stack>
|
|
|
|
{/* Live Clock Card */}
|
|
<LiveClock
|
|
unit={unit}
|
|
onUseNow={handleUseNow}
|
|
onUnitChange={setUnit}
|
|
showMessage={showMessage}
|
|
/>
|
|
|
|
{/* Mode Switcher */}
|
|
<Box
|
|
sx={{
|
|
position: 'relative',
|
|
display: 'flex',
|
|
p: 0.6,
|
|
bgcolor: 'grey.100',
|
|
borderRadius: 4,
|
|
mb: 2.5,
|
|
border: '1px solid',
|
|
borderColor: 'grey.200',
|
|
}}
|
|
>
|
|
<Box
|
|
sx={{
|
|
position: 'absolute',
|
|
height: 'calc(100% - 10px)',
|
|
width: 'calc(50% - 5px)',
|
|
bgcolor: '#fff',
|
|
borderRadius: 3.5,
|
|
boxShadow: '0 4px 12px rgba(0,0,0,0.08)',
|
|
transition: 'transform 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
|
|
transform: mode === 'ts2dt' ? 'translateX(0)' : 'translateX(100%)',
|
|
top: 5,
|
|
left: 5,
|
|
}}
|
|
/>
|
|
{(['ts2dt', 'dt2ts'] as const).map((m) => (
|
|
<Box
|
|
key={m}
|
|
onClick={() => setMode(m)}
|
|
sx={{
|
|
flex: 1,
|
|
py: 1,
|
|
textAlign: 'center',
|
|
position: 'relative',
|
|
zIndex: 1,
|
|
cursor: 'pointer',
|
|
fontWeight: 800,
|
|
fontSize: '0.75rem',
|
|
color: mode === m ? 'primary.main' : 'text.secondary',
|
|
transition: 'color 0.3s',
|
|
}}
|
|
>
|
|
{m === 'ts2dt' ? '时间戳 → 日期' : '日期 → 时间戳'}
|
|
</Box>
|
|
))}
|
|
</Box>
|
|
|
|
{/* Input Area */}
|
|
<Stack spacing={2} sx={{ mb: 3 }}>
|
|
<TextField
|
|
placeholder={mode === 'ts2dt' ? '输入时间戳...' : 'YYYY-MM-DD HH:mm:ss'}
|
|
value={mode === 'ts2dt' ? tsInput : dtInput}
|
|
onChange={(e) => {
|
|
const val = e.target.value;
|
|
if (mode === 'ts2dt') {
|
|
setTsInput(val);
|
|
} else {
|
|
setDtInput(val);
|
|
}
|
|
}}
|
|
error={!!error}
|
|
helperText={error}
|
|
fullWidth
|
|
sx={timestampPageStyles.INPUT_STYLE}
|
|
/>
|
|
|
|
<Stack direction="row" spacing={1.5}>
|
|
{/* 优化后的单位选择按钮组 */}
|
|
<Box
|
|
sx={{
|
|
flex: 1,
|
|
display: 'flex',
|
|
bgcolor: 'grey.50',
|
|
p: 0.5,
|
|
borderRadius: 3.5,
|
|
border: '1px solid',
|
|
borderColor: 'grey.100',
|
|
}}
|
|
>
|
|
{(['ms', 's'] as const).map((u) => (
|
|
<Box
|
|
key={u}
|
|
onClick={() => setUnit(u)}
|
|
sx={{
|
|
flex: 1,
|
|
py: 0.8,
|
|
textAlign: 'center',
|
|
borderRadius: 3,
|
|
cursor: 'pointer',
|
|
fontSize: '0.75rem',
|
|
fontWeight: 800,
|
|
transition: 'all 0.2s',
|
|
bgcolor: unit === u ? '#fff' : 'transparent',
|
|
color: unit === u ? 'primary.main' : 'text.disabled',
|
|
boxShadow: unit === u ? '0 2px 8px rgba(0,0,0,0.05)' : 'none',
|
|
}}
|
|
>
|
|
{u === 'ms' ? '毫秒 (ms)' : '秒 (s)'}
|
|
</Box>
|
|
))}
|
|
</Box>
|
|
|
|
<Select
|
|
fullWidth
|
|
value={zone}
|
|
onChange={(e) => setZone(e.target.value as typeof zone)}
|
|
sx={{ ...timestampPageStyles.INPUT_STYLE, flex: 1 }}
|
|
MenuProps={{
|
|
PaperProps: {
|
|
sx: { borderRadius: 3, mt: 1, boxShadow: '0 12px 32px rgba(0,0,0,0.1)' },
|
|
},
|
|
}}
|
|
>
|
|
{ZONES.map((z) => (
|
|
<MenuItem key={z} value={z} sx={{ fontSize: '0.8rem', fontWeight: 600 }}>
|
|
{z}
|
|
</MenuItem>
|
|
))}
|
|
</Select>
|
|
</Stack>
|
|
</Stack>
|
|
|
|
{/* Main Action */}
|
|
<Button
|
|
fullWidth
|
|
variant="contained"
|
|
onClick={convert}
|
|
sx={{
|
|
py: 1.4,
|
|
borderRadius: 4,
|
|
bgcolor: 'primary.main',
|
|
fontWeight: 800,
|
|
fontSize: '0.9rem',
|
|
boxShadow: 'none',
|
|
'&:hover': {
|
|
bgcolor: 'primary.dark',
|
|
boxShadow: `0 8px 24px ${alpha(timestampPageStyles.primaryColor, 0.2)}`,
|
|
},
|
|
}}
|
|
>
|
|
立即转换
|
|
</Button>
|
|
|
|
{/* Result View */}
|
|
<ResultView result={result} mode={mode} unit={unit} zone={zone} showMessage={showMessage} />
|
|
</Container>
|
|
|
|
<GlobalSnackbar {...snackbarProps} />
|
|
</Box>
|
|
);
|
|
}
|