diff --git a/pages/JsonTools/DiffNavigator.tsx b/pages/JsonTools/DiffNavigator.tsx index 96004c1..45ca5c6 100644 --- a/pages/JsonTools/DiffNavigator.tsx +++ b/pages/JsonTools/DiffNavigator.tsx @@ -1,8 +1,5 @@ -import { Box, IconButton, Typography } from '@mui/material'; -import NavigateBeforeIcon from '@mui/icons-material/NavigateBefore'; -import NavigateNextIcon from '@mui/icons-material/NavigateNext'; +import { ChevronLeft, ChevronRight } from 'lucide-react'; import { useLazyTranslation } from '@/utils/useLazyTranslation'; -import { jsonDiffPageStyles } from '@/config/pageTheme'; interface DiffNavigatorProps { total: number; @@ -17,29 +14,34 @@ export default function DiffNavigator({ total, currentIndex, onPrev, onNext }: D if (total === 0) { return ( - - - {t('jsonDiff:noDiffs')} - - +
+ {t('jsonDiff:noDiffs')} +
); } return ( - - - - - + + {currentIndex + 1} / {total} - - - - - + + + ); } diff --git a/pages/JsonTools/DiffResult.tsx b/pages/JsonTools/DiffResult.tsx index ef043e3..cbde70f 100644 --- a/pages/JsonTools/DiffResult.tsx +++ b/pages/JsonTools/DiffResult.tsx @@ -1,7 +1,4 @@ -import { Box, Stack, Typography, useTheme } from '@mui/material'; -import type { Theme } from '@mui/material/styles'; import { useLazyTranslation } from '@/utils/useLazyTranslation'; -import { jsonDiffPageStyles, surfaceTint } from '@/config/pageTheme'; import JsonTree from './JsonTree'; import type { DiffNode, DiffResult as DiffResultType, DiffType, ViewMode } from './types'; @@ -16,41 +13,30 @@ export default function DiffResult({ result, viewMode, activePath }: DiffResultP if (viewMode === 'sideBySide') { return ( - - +
+
- - +
+
- - +
+
); } return ( - +
- +
); } const SectionLabel = ({ text }: { text: string }) => ( - + {text} - + ); const formatPrimitive = (v: unknown): string => { @@ -71,17 +57,17 @@ const prefixForType = (type: DiffType): string => { return ' '; }; -const colorForType = (type: DiffType): string | undefined => { - if (type === 'added') return jsonDiffPageStyles.addedText; - if (type === 'removed') return jsonDiffPageStyles.removedText; - if (type === 'modified') return jsonDiffPageStyles.modifiedText; - return undefined; +const colorForType = (type: DiffType): string => { + if (type === 'added') return 'text-green-600'; + if (type === 'removed') return 'text-red-600'; + if (type === 'modified') return 'text-amber-600'; + return 'text-gray-900'; }; -const bgForType = (type: DiffType, theme: Theme): string | undefined => { - if (type === 'added') return surfaceTint(theme, theme.palette.success.main, 0.15); - if (type === 'removed') return surfaceTint(theme, theme.palette.error.main, 0.15); - if (type === 'modified') return surfaceTint(theme, theme.palette.warning.main, 0.15); +const bgForType = (type: DiffType): string | undefined => { + if (type === 'added') return 'bg-green-50'; + if (type === 'removed') return 'bg-red-50'; + if (type === 'modified') return 'bg-amber-50'; return undefined; }; @@ -177,29 +163,18 @@ interface UnifiedRowProps { } const UnifiedRow = ({ depth, type, text, active, multiline }: UnifiedRowProps) => { - const theme = useTheme(); const color = colorForType(type); - const bg = bgForType(type, theme); + const bg = bgForType(type); return ( - - - {prefixForType(type)} - - {text} - + {prefixForType(type)} + {text} + ); }; diff --git a/pages/JsonTools/JsonConvertSection.tsx b/pages/JsonTools/JsonConvertSection.tsx index c99beb8..8717cbf 100644 --- a/pages/JsonTools/JsonConvertSection.tsx +++ b/pages/JsonTools/JsonConvertSection.tsx @@ -1,5 +1,5 @@ import { useEffect, useMemo, useState } from 'react'; -import { Box, Button, Stack, Typography } from '@mui/material'; +import { Button } from '@/components/ui/button'; import { useLazyTranslation } from '@/utils/useLazyTranslation'; import { formatByteSize } from '@/utils/textStatistics'; import { useSnackbar } from '@/components/GlobalSnackbar'; @@ -88,29 +88,24 @@ export default function JsonConvertSection({ }; return ( - +
{/* 工具栏 */} - - - - - - +
+ {/* 输入区 */} +
{/* 结果头部 */} - - theme.palette.mode === 'dark' ? 'rgba(255,255,255,0.03)' : 'grey.50', - }} - > - - +
+
+ {t(`jsonFormat:${pk}OutputLabel`)} - - + + {t('jsonFormat:originalSize')}: {formatByteSize(result.originalBytes)} - - + + {t('jsonFormat:formattedSize')}: {formatByteSize(result.outputBytes)} - - + +
- +
{/* 转换内容 */} - +
{result.output} - - +
+
) : ( - - theme.palette.mode === 'dark' ? 'rgba(255,255,255,0.03)' : 'grey.50', - border: '1px dashed', - borderColor: (theme) => - theme.palette.mode === 'dark' ? 'rgba(255,255,255,0.15)' : 'grey.300', - textAlign: 'center', - }} - > - - {t(`jsonFormat:${pk}EmptyHint`)} - - +
+

{t(`jsonFormat:${pk}EmptyHint`)}

+
)} -
+ ); } diff --git a/pages/JsonTools/JsonDiffInput.tsx b/pages/JsonTools/JsonDiffInput.tsx index 5e10150..7ab3541 100644 --- a/pages/JsonTools/JsonDiffInput.tsx +++ b/pages/JsonTools/JsonDiffInput.tsx @@ -1,4 +1,3 @@ -import { Box, Typography } from '@mui/material'; import TextInputArea from '@/components/TextInputArea'; interface JsonDiffInputProps { @@ -17,21 +16,10 @@ export default function JsonDiffInput({ error, }: JsonDiffInputProps) { return ( - - +
+ {label} - + - +
); } diff --git a/pages/JsonTools/JsonFormatSection.tsx b/pages/JsonTools/JsonFormatSection.tsx index 966d797..412dbdd 100644 --- a/pages/JsonTools/JsonFormatSection.tsx +++ b/pages/JsonTools/JsonFormatSection.tsx @@ -1,14 +1,5 @@ import { useEffect, useMemo, useState } from 'react'; -import { - Box, - Button, - FormControlLabel, - FormHelperText, - Stack, - Switch, - TextField, - Typography, -} from '@mui/material'; +import { Button } from '@/components/ui/button'; import { useLazyTranslation } from '@/utils/useLazyTranslation'; import { formatJson, @@ -18,7 +9,6 @@ import { } from '@/utils/jsonFormatter'; import { formatByteSize } from '@/utils/textStatistics'; import { useSnackbar } from '@/components/GlobalSnackbar'; -import { jsonDiffPageStyles } from '@/config/pageTheme'; import CopyButton from '@/components/CopyButton'; import SwitchButtonGroup from '@/components/SwitchButtonGroup'; @@ -78,22 +68,14 @@ export default function JsonFormatSection() { }; return ( - +
{/* 工具栏 */} - - +
+
{/* 缩进选择 */} - + {t('jsonFormat:indentSize')} - + setIndentSize(v)} @@ -103,134 +85,79 @@ export default function JsonFormatSection() { /> {/* 键名排序开关 */} - setSortKeys(e.target.checked)} - /> - } - label={ - - {t('jsonFormat:sortKeys')} - - } - sx={{ ml: 1 }} - /> - + +
- - - - +
+
{/* 输入区 */} - - +