mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
I18n Translations (#2267)
* rebase * i18n-1 * add error info i18n * fix * fix * refactor: 删除error.json * delete useI18n
This commit is contained in:
@@ -2,7 +2,7 @@ import { useRef, useState, useCallback, useMemo, useEffect } from 'react';
|
||||
import { IconButton, Flex, Box, Input } from '@chakra-ui/react';
|
||||
import { ArrowBackIcon, ArrowForwardIcon } from '@chakra-ui/icons';
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { throttle } from 'lodash';
|
||||
import { useToast } from './useToast';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
@@ -34,6 +34,7 @@ export function usePagination<T = any>({
|
||||
elementRef?: React.RefObject<HTMLDivElement>;
|
||||
}) {
|
||||
const { toast } = useToast();
|
||||
const { t } = useTranslation();
|
||||
const [pageNum, setPageNum] = useState(1);
|
||||
const pageNumRef = useRef(pageNum);
|
||||
pageNumRef.current = pageNum;
|
||||
@@ -63,7 +64,7 @@ export function usePagination<T = any>({
|
||||
onChange && onChange(num);
|
||||
} catch (error: any) {
|
||||
toast({
|
||||
title: getErrText(error, '获取数据异常'),
|
||||
title: getErrText(error, t('common:core.chat.error.data_error')),
|
||||
status: 'error'
|
||||
});
|
||||
console.log(error);
|
||||
@@ -138,9 +139,9 @@ export function usePagination<T = any>({
|
||||
const ScrollData = useCallback(
|
||||
({ children, ...props }: { children: React.ReactNode }) => {
|
||||
const loadText = useMemo(() => {
|
||||
if (isLoading) return '请求中……';
|
||||
if (total <= data.length) return '已加载全部';
|
||||
return '点击加载更多';
|
||||
if (isLoading) return t('common:common.is_requesting');
|
||||
if (total <= data.length) return t('common:common.request_end');
|
||||
return t('common:common.request_more');
|
||||
}, []);
|
||||
|
||||
return (
|
||||
@@ -151,9 +152,9 @@ export function usePagination<T = any>({
|
||||
fontSize={'xs'}
|
||||
color={'blackAlpha.500'}
|
||||
textAlign={'center'}
|
||||
cursor={loadText === '点击加载更多' ? 'pointer' : 'default'}
|
||||
cursor={loadText === t('common:common.request_more') ? 'pointer' : 'default'}
|
||||
onClick={() => {
|
||||
if (loadText !== '点击加载更多') return;
|
||||
if (loadText !== t('common:common.request_more')) return;
|
||||
mutate(pageNum + 1);
|
||||
}}
|
||||
>
|
||||
|
@@ -85,7 +85,7 @@ export function useScrollPagination<
|
||||
}
|
||||
} catch (error: any) {
|
||||
toast({
|
||||
title: getErrText(error, '获取数据异常'),
|
||||
title: getErrText(error, t('common:core.chat.error.data_error')),
|
||||
status: 'error'
|
||||
});
|
||||
console.log(error);
|
||||
|
Reference in New Issue
Block a user