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 ( {/* Header with Icon */} 时间戳转换 Unix 毫秒数转换与格式化 {/* Live Clock Card */} {/* Mode Switcher */} {(['ts2dt', 'dt2ts'] as const).map((m) => ( 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' ? '时间戳 → 日期' : '日期 → 时间戳'} ))} {/* Input Area */} { const val = e.target.value; if (mode === 'ts2dt') { setTsInput(val); } else { setDtInput(val); } }} error={!!error} helperText={error} fullWidth sx={timestampPageStyles.INPUT_STYLE} /> {/* 优化后的单位选择按钮组 */} {(['ms', 's'] as const).map((u) => ( 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)'} ))} {/* Main Action */} {/* Result View */} ); }