mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-24 22:03:54 +00:00
pref: login/forgetpass texts (#2457)
* chore: fastgptfeconfig type * pref: login, forget password, texts
This commit is contained in:
@@ -8,6 +8,7 @@ import { updateNotificationAccount } from '@/web/support/user/api';
|
||||
import Icon from '@fastgpt/web/components/common/Icon';
|
||||
import { useSendCode } from '@/web/support/user/hooks/useSendCode';
|
||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
|
||||
type FormType = {
|
||||
account: string;
|
||||
@@ -17,6 +18,7 @@ type FormType = {
|
||||
const UpdateNotificationModal = ({ onClose }: { onClose: () => void }) => {
|
||||
const { t } = useTranslation();
|
||||
const { initUserInfo } = useUserStore();
|
||||
const { feConfigs } = useSystemStore();
|
||||
const { register, handleSubmit, trigger, getValues, watch } = useForm<FormType>({
|
||||
defaultValues: {
|
||||
account: '',
|
||||
@@ -51,6 +53,17 @@ const UpdateNotificationModal = ({ onClose }: { onClose: () => void }) => {
|
||||
});
|
||||
}, [getValues, sendCode, trigger]);
|
||||
|
||||
const placeholder = feConfigs?.bind_notification_method
|
||||
?.map((item) => {
|
||||
switch (item) {
|
||||
case 'email':
|
||||
return t('common:support.user.login.Email');
|
||||
case 'phone':
|
||||
return t('common:support.user.login.Phone number');
|
||||
}
|
||||
})
|
||||
.join('/');
|
||||
|
||||
return (
|
||||
<MyModal
|
||||
isOpen
|
||||
@@ -70,7 +83,7 @@ const UpdateNotificationModal = ({ onClose }: { onClose: () => void }) => {
|
||||
flex={1}
|
||||
bg={'myGray.50'}
|
||||
{...register('account', { required: true })}
|
||||
placeholder={t('user:password.email_phone')}
|
||||
placeholder={placeholder}
|
||||
></Input>
|
||||
</Flex>
|
||||
<Flex mt="6" alignItems="center" position={'relative'}>
|
||||
|
@@ -46,6 +46,18 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
|
||||
}, [getValues, sendCode, trigger]);
|
||||
|
||||
const [requesting, setRequesting] = useState(false);
|
||||
const placeholder = feConfigs?.find_password_method
|
||||
?.map((item) => {
|
||||
switch (item) {
|
||||
case 'email':
|
||||
return t('common:support.user.login.Email');
|
||||
case 'phone':
|
||||
return t('common:support.user.login.Phone number');
|
||||
default:
|
||||
return t('common:support.user.login.Username');
|
||||
}
|
||||
})
|
||||
.join('/');
|
||||
|
||||
const onclickFindPassword = useCallback(
|
||||
async ({ username, code, password }: RegisterType) => {
|
||||
@@ -89,7 +101,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
|
||||
<FormControl isInvalid={!!errors.username}>
|
||||
<Input
|
||||
bg={'myGray.50'}
|
||||
placeholder={t('user:password.email_phone')}
|
||||
placeholder={placeholder}
|
||||
{...register('username', {
|
||||
required: t('user:password.email_phone_void'),
|
||||
pattern: {
|
||||
|
@@ -57,24 +57,32 @@ const LoginForm = ({ setPageType, loginSuccess }: Props) => {
|
||||
[loginSuccess, t, toast]
|
||||
);
|
||||
|
||||
const isCommunityVersion = feConfigs?.show_register === false && !feConfigs?.isPlus;
|
||||
const isCommunityVersion = !!(feConfigs?.register_method && !feConfigs?.isPlus);
|
||||
|
||||
const loginOptions = [
|
||||
feConfigs?.show_phoneLogin ? t('common:support.user.login.Phone number') : '',
|
||||
feConfigs?.show_emailLogin ? t('common:support.user.login.Email') : '',
|
||||
t('common:support.user.login.Username')
|
||||
].filter(Boolean);
|
||||
|
||||
const placeholder = isCommunityVersion
|
||||
? t('common:support.user.login.Root login')
|
||||
: loginOptions.join('/');
|
||||
const placeholder = (() => {
|
||||
if (isCommunityVersion) {
|
||||
return t('common:support.user.login.Root login');
|
||||
}
|
||||
return [t('common:support.user.login.Username')]
|
||||
.concat(
|
||||
feConfigs?.login_method?.map((item) => {
|
||||
switch (item) {
|
||||
case 'email':
|
||||
return t('common:support.user.login.Email');
|
||||
case 'phone':
|
||||
return t('common:support.user.login.Phone number');
|
||||
}
|
||||
}) ?? []
|
||||
)
|
||||
.join('/');
|
||||
})();
|
||||
|
||||
return (
|
||||
<FormLayout setPageType={setPageType} pageType={LoginPageTypeEnum.passwordLogin}>
|
||||
<Box
|
||||
mt={'42px'}
|
||||
onKeyDown={(e) => {
|
||||
if (e.keyCode === 13 && !e.shiftKey && !requesting) {
|
||||
if (e.key === 'Enter' && !e.shiftKey && !requesting) {
|
||||
handleSubmit(onclickLogin)();
|
||||
}
|
||||
}}
|
||||
@@ -140,17 +148,19 @@ const LoginForm = ({ setPageType, loginSuccess }: Props) => {
|
||||
{t('common:Login')}
|
||||
</Button>
|
||||
|
||||
{feConfigs?.show_register && (
|
||||
<>
|
||||
<Flex align={'center'} justifyContent={'flex-end'} color={'primary.700'}>
|
||||
<Box
|
||||
cursor={'pointer'}
|
||||
_hover={{ textDecoration: 'underline' }}
|
||||
onClick={() => setPageType('forgetPassword')}
|
||||
fontSize="sm"
|
||||
>
|
||||
{t('common:support.user.login.Forget Password')}
|
||||
</Box>
|
||||
<Flex align={'center'} justifyContent={'flex-end'} color={'primary.700'}>
|
||||
{feConfigs?.find_password_method && feConfigs.find_password_method.length > 0 && (
|
||||
<Box
|
||||
cursor={'pointer'}
|
||||
_hover={{ textDecoration: 'underline' }}
|
||||
onClick={() => setPageType('forgetPassword')}
|
||||
fontSize="sm"
|
||||
>
|
||||
{t('common:support.user.login.Forget Password')}
|
||||
</Box>
|
||||
)}
|
||||
{feConfigs?.register_method && feConfigs.register_method.length > 0 && (
|
||||
<>
|
||||
<Box mx={3} h={'16px'} w={'1.5px'} bg={'myGray.250'}></Box>
|
||||
<Box
|
||||
cursor={'pointer'}
|
||||
@@ -160,9 +170,9 @@ const LoginForm = ({ setPageType, loginSuccess }: Props) => {
|
||||
>
|
||||
{t('common:support.user.login.Register')}
|
||||
</Box>
|
||||
</Flex>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</Flex>
|
||||
</Box>
|
||||
</FormLayout>
|
||||
);
|
||||
|
@@ -67,6 +67,9 @@ const FormLayout = ({ children, setPageType, pageType }: Props) => {
|
||||
]
|
||||
: [])
|
||||
];
|
||||
|
||||
const show_oauth = !!(feConfigs?.sso || oAuthList.length > 0);
|
||||
|
||||
return (
|
||||
<Flex flexDirection={'column'} h={'100%'}>
|
||||
<Flex alignItems={'center'}>
|
||||
@@ -87,9 +90,9 @@ const FormLayout = ({ children, setPageType, pageType }: Props) => {
|
||||
</Box>
|
||||
</Flex>
|
||||
{children}
|
||||
<Box flex={1} />
|
||||
{feConfigs?.show_register && oAuthList.length > 0 && (
|
||||
{show_oauth && (
|
||||
<>
|
||||
<Box flex={1} />
|
||||
<Box position={'relative'}>
|
||||
<Divider />
|
||||
<AbsoluteCenter bg="white" px="4" color={'myGray.500'}>
|
||||
|
@@ -90,6 +90,17 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
|
||||
[loginSuccess, t, toast]
|
||||
);
|
||||
|
||||
const placeholder = feConfigs?.register_method
|
||||
?.map((item) => {
|
||||
switch (item) {
|
||||
case 'email':
|
||||
return t('common:support.user.login.Email');
|
||||
case 'phone':
|
||||
return t('common:support.user.login.Phone number');
|
||||
}
|
||||
})
|
||||
.join('/');
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box fontWeight={'bold'} fontSize={'2xl'} textAlign={'center'}>
|
||||
@@ -98,7 +109,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
|
||||
<Box
|
||||
mt={'42px'}
|
||||
onKeyDown={(e) => {
|
||||
if (e.keyCode === 13 && !e.shiftKey && !requesting) {
|
||||
if (e.key === 'Enter' && !e.shiftKey && !requesting) {
|
||||
handleSubmit(onclickRegister)();
|
||||
}
|
||||
}}
|
||||
@@ -106,7 +117,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
|
||||
<FormControl isInvalid={!!errors.username}>
|
||||
<Input
|
||||
bg={'myGray.50'}
|
||||
placeholder={t('user:password.email_phone')}
|
||||
placeholder={placeholder}
|
||||
{...register('username', {
|
||||
required: t('user:password.email_phone_void'),
|
||||
pattern: {
|
||||
|
Reference in New Issue
Block a user