Skip to content

Commit c223d3a

Browse files
committed
perf: document icon and language select
1 parent ae4c479 commit c223d3a

File tree

4 files changed

+57
-6
lines changed

4 files changed

+57
-6
lines changed

client/public/locales/en/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@
231231
"Copy invite url": "Copy invitation link",
232232
"Invite Url": "Invite Url",
233233
"Invite url tip": "Friends who register through this link will be permanently bound to you, and you will get a certain balance reward when they recharge. In addition, when friends register with their mobile phone number, you will get 5 yuan reward immediately.",
234+
"Language": "Language",
234235
"Notice": "Notice",
235236
"Old password is error": "Old password is error",
236237
"OpenAI Account Setting": "OpenAI Account Setting",

client/public/locales/zh/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@
231231
"Copy invite url": "复制邀请链接",
232232
"Invite Url": "邀请链接",
233233
"Invite url tip": "通过该链接注册的好友将永久与你绑定,其充值时你会获得一定余额奖励。\n此外,好友使用手机号注册时,你将立即获得 5 元奖励。",
234+
"Language": "语言",
234235
"Notice": "通知",
235236
"Old password is error": "旧密码错误",
236237
"OpenAI Account Setting": "OpenAI 账号配置",

client/src/components/Layout/navbar.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import NextLink from 'next/link';
99
import Badge from '../Badge';
1010
import Avatar from '../Avatar';
1111
import MyIcon from '../Icon';
12-
import Language from '../Language';
1312
import { useTranslation } from 'next-i18next';
1413
import { useGlobalStore } from '@/store/global';
1514
import MyTooltip from '../MyTooltip';
@@ -167,8 +166,20 @@ const Navbar = ({ unread }: { unread: number }) => {
167166
</Link>
168167
</Box>
169168
)}
170-
171-
<Language {...itemStyles} />
169+
{feConfigs?.show_doc && (
170+
<MyTooltip label={t('home.Docs')} placement={'right-end'}>
171+
<Box
172+
{...itemStyles}
173+
mb={0}
174+
color={'#9096a5'}
175+
onClick={() => {
176+
window.open(`https://doc.fastgpt.run/docs/intro`);
177+
}}
178+
>
179+
<MyIcon name={'courseLight'} width={'26px'} height={'26px'} />
180+
</Box>
181+
</MyTooltip>
182+
)}
172183
{feConfigs?.show_git && (
173184
<MyTooltip label={`Git Star: ${gitStar}`} placement={'right-end'}>
174185
<Link

client/src/pages/account/components/Info.tsx

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1-
import React, { useCallback, useRef } from 'react';
2-
import { Box, Flex, Button, useDisclosure, useTheme, Divider, Select } from '@chakra-ui/react';
1+
import React, { useCallback, useRef, useState } from 'react';
2+
import {
3+
Box,
4+
Flex,
5+
Button,
6+
useDisclosure,
7+
useTheme,
8+
Divider,
9+
Select,
10+
Menu,
11+
MenuButton,
12+
MenuList,
13+
MenuItem
14+
} from '@chakra-ui/react';
315
import { useForm } from 'react-hook-form';
416
import { UserUpdateParams } from '@/types/user';
517
import { useToast } from '@/hooks/useToast';
@@ -16,6 +28,10 @@ import Loading from '@/components/Loading';
1628
import Avatar from '@/components/Avatar';
1729
import MyIcon from '@/components/Icon';
1830
import MyTooltip from '@/components/MyTooltip';
31+
import { getLangStore, LangEnum, langMap, setLangStore } from '@/utils/i18n';
32+
import { useRouter } from 'next/router';
33+
import MyMenu from '@/components/MyMenu';
34+
import MySelect from '@/components/Select';
1935

2036
const PayModal = dynamic(() => import('./PayModal'), {
2137
loading: () => <Loading fixed={false} />,
@@ -32,7 +48,8 @@ const OpenAIAccountModal = dynamic(() => import('./OpenAIAccountModal'), {
3248

3349
const UserInfo = () => {
3450
const theme = useTheme();
35-
const { t } = useTranslation();
51+
const router = useRouter();
52+
const { t, i18n } = useTranslation();
3653
const { userInfo, updateUserInfo, initUserInfo } = useUserStore();
3754
const timezones = useRef(timezoneList());
3855
const { reset } = useForm<UserUpdateParams>({
@@ -57,6 +74,8 @@ const UserInfo = () => {
5774
multiple: false
5875
});
5976

77+
const [language, setLanguage] = useState<`${LangEnum}`>(getLangStore());
78+
6079
const onclickSave = useCallback(
6180
async (data: UserType) => {
6281
await updateUserInfo({
@@ -149,6 +168,25 @@ const UserInfo = () => {
149168
<Box flex={'0 0 80px'}>{t('user.Account')}:&nbsp;</Box>
150169
<Box flex={1}>{userInfo?.username}</Box>
151170
</Flex>
171+
<Flex mt={6} alignItems={'center'} w={['85%', '300px']}>
172+
<Box flex={'0 0 80px'}>{t('user.Language')}:&nbsp;</Box>
173+
<Box flex={'1 0 0'}>
174+
<MySelect
175+
value={language}
176+
list={Object.entries(langMap).map(([key, lang]) => ({
177+
label: lang.label,
178+
value: key
179+
}))}
180+
onchange={(val: any) => {
181+
const lang = val;
182+
setLangStore(lang);
183+
setLanguage(lang);
184+
i18n?.changeLanguage?.(lang);
185+
router.reload();
186+
}}
187+
/>
188+
</Box>
189+
</Flex>
152190
<Flex mt={6} alignItems={'center'} w={['85%', '300px']}>
153191
<Box flex={'0 0 80px'}>{t('user.Timezone')}:&nbsp;</Box>
154192
<Select

0 commit comments

Comments
 (0)