feat: add login page ip detect (#2819)

* feat: add login page ip detect

* code perf
This commit is contained in:
papapatrick
2024-09-27 13:39:10 +08:00
committed by GitHub
parent efcb53cd6d
commit 691476c821
11 changed files with 255 additions and 45 deletions

View File

@@ -0,0 +1,40 @@
import { langMap } from '@/web/common/utils/i18n';
import { Avatar, Box, Flex } from '@chakra-ui/react';
import MySelect from '@fastgpt/web/components/common/MySelect';
import { useI18nLng } from '@fastgpt/web/hooks/useI18n';
import { useTranslation } from 'next-i18next';
import { useMemo } from 'react';
import MyIcon from '@fastgpt/web/components/common/Icon';
const I18nLngSelector = () => {
const { i18n } = useTranslation();
const { onChangeLng } = useI18nLng();
const list = useMemo(() => {
return Object.entries(langMap).map(([key, lang]) => ({
label: (
<Flex alignItems={'center'}>
<MyIcon borderRadius={'0'} mr={2} name={lang.avatar as any} w={'14px'} h={'9px'} />
<Box>{lang.label}</Box>
</Flex>
),
value: key
}));
}, []);
return (
<MySelect
_hover={{
bg: 'myGray.200'
}}
value={i18n.language}
list={list}
onchange={(val: any) => {
const lang = val;
onChangeLng(lang);
}}
/>
);
};
export default I18nLngSelector;