import { useI18n } from '@/utils/chromeI18n'; import JsonDiffInput from './components/JsonDiffInput'; import DiffResult from './components/DiffResult'; import DiffNavigator from './components/DiffNavigator'; import JsonFormatSection from './components/JsonFormatSection'; import JsonConvertSection from './components/JsonConvertSection'; import SwitchButtonGroup from '@/components/SwitchButtonGroup'; import { useJsonTools } from './useJsonTools'; import type { JsonToolsPageMode } from '@/types/storage'; import type { ViewMode } from './types'; type PageMode = JsonToolsPageMode; export default function Index() { const { t } = useI18n(['jsonDiff', 'jsonFormat']); const { pageMode, setPageMode, leftInput, rightInput, setLeftInput, setRightInput, leftError, rightError, viewMode, setViewMode, diffResult, total, currentDiffIndex, handlePrev, handleNext, activePath, yamlConvert, tomlConvert, minifyConvert, } = useJsonTools(); return (
setPageMode(v)} options={[ { value: 'diff', label: t('jsonFormat:diffMode') }, { value: 'format', label: t('jsonFormat:formatMode') }, { value: 'yaml', label: t('jsonFormat:yamlMode') }, { value: 'toml', label: t('jsonFormat:tomlMode') }, { value: 'minify', label: t('jsonFormat:minifyMode') }, ]} size="small" className="w-full sm:w-auto" /> {pageMode === 'diff' ? (
setViewMode(v)} options={[ { value: 'sideBySide', label: t('jsonDiff:sideBySideMode') }, { value: 'unified', label: t('jsonDiff:unifiedMode') }, ]} size="small" />
{diffResult ? (
) : (

{leftError || rightError ? t('jsonDiff:fixErrorHint') : t('jsonDiff:emptyHint')}

)}
) : pageMode === 'format' ? ( ) : pageMode === 'yaml' ? ( ) : pageMode === 'toml' ? ( ) : ( )}
); }