fix(i18n): 统一使用 useLazyTranslation 避免翻译 key 闪烁
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Box, IconButton, Typography } from '@mui/material';
|
||||
import NavigateBeforeIcon from '@mui/icons-material/NavigateBefore';
|
||||
import NavigateNextIcon from '@mui/icons-material/NavigateNext';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useLazyTranslation } from '@/utils/useLazyTranslation';
|
||||
import { jsonDiffPageStyles } from '@/config/pageTheme';
|
||||
|
||||
interface DiffNavigatorProps {
|
||||
@@ -13,7 +13,7 @@ interface DiffNavigatorProps {
|
||||
}
|
||||
|
||||
export default function DiffNavigator({ total, currentIndex, onPrev, onNext }: DiffNavigatorProps) {
|
||||
const { t } = useTranslation(['jsonDiff']);
|
||||
const { t } = useLazyTranslation('jsonDiff');
|
||||
|
||||
if (total === 0) {
|
||||
return (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Box, Stack, Typography, useTheme } from '@mui/material';
|
||||
import type { Theme } from '@mui/material/styles';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
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';
|
||||
@@ -12,7 +12,7 @@ interface DiffResultProps {
|
||||
}
|
||||
|
||||
export default function DiffResult({ result, viewMode, activePath }: DiffResultProps) {
|
||||
const { t } = useTranslation(['jsonDiff']);
|
||||
const { t } = useLazyTranslation('jsonDiff');
|
||||
|
||||
if (viewMode === 'sideBySide') {
|
||||
return (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { Box, Button, Stack, Typography } from '@mui/material';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useLazyTranslation } from '@/utils/useLazyTranslation';
|
||||
import { formatByteSize } from '@/utils/textStatistics';
|
||||
import { useSnackbar } from '@/components/GlobalSnackbar';
|
||||
import CopyButton from '@/components/CopyButton';
|
||||
@@ -43,7 +43,7 @@ export default function JsonConvertSection({
|
||||
convertFunction,
|
||||
convertButtonKey = 'convertButton',
|
||||
}: JsonConvertSectionProps) {
|
||||
const { t } = useTranslation(['jsonFormat']);
|
||||
const { t } = useLazyTranslation('jsonFormat');
|
||||
const { showMessage } = useSnackbar();
|
||||
|
||||
const [input, setInput] = useState('');
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
TextField,
|
||||
Typography,
|
||||
} from '@mui/material';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useLazyTranslation } from '@/utils/useLazyTranslation';
|
||||
import {
|
||||
formatJson,
|
||||
validateJson,
|
||||
@@ -32,7 +32,7 @@ const INDENT_OPTIONS = [2, 4, 6, 8] as const;
|
||||
* 支持一键复制格式化后的 JSON。
|
||||
*/
|
||||
export default function JsonFormatSection() {
|
||||
const { t } = useTranslation(['jsonFormat']);
|
||||
const { t } = useLazyTranslation('jsonFormat');
|
||||
const { showMessage } = useSnackbar();
|
||||
|
||||
const [input, setInput] = useState('');
|
||||
|
||||
Reference in New Issue
Block a user