Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
649de7f0
authored
Aug 21, 2024
by
Finley Ge
Committed by
GitHub
Aug 21, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pref: login/forgetpass texts (#2457)
* chore: fastgptfeconfig type * pref: login, forget password, texts
parent
26d80098
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
34 deletions
+84
-34
packages/global/common/system/types/index.d.ts
+4
-3
projects/app/src/pages/account/components/UpdateNotificationModal.tsx
+14
-1
projects/app/src/pages/login/components/ForgetPasswordForm.tsx
+13
-1
projects/app/src/pages/login/components/LoginForm/LoginForm.tsx
+35
-25
projects/app/src/pages/login/components/LoginForm/components/FormLayout.tsx
+5
-2
projects/app/src/pages/login/components/RegisterForm.tsx
+13
-2
No files found.
packages/global/common/system/types/index.d.ts
View file @
649de7f0
...
...
@@ -24,7 +24,10 @@ export type FastGPTConfigFileType = {
export
type
FastGPTFeConfigsType
=
{
show_emptyChat
?:
boolean
;
show_register
?:
boolean
;
register_method
?:
[
'email'
|
'phone'
];
login_method
?:
[
'email'
|
'phone'
];
// Attention: login method is diffrent with oauth
find_password_method
?:
[
'email'
|
'phone'
];
bind_notification_method
?:
[
'email'
|
'phone'
];
show_appStore
?:
boolean
;
show_git
?:
boolean
;
show_pay
?:
boolean
;
...
...
@@ -43,8 +46,6 @@ export type FastGPTFeConfigsType = {
systemDescription
?:
string
;
googleClientVerKey
?:
string
;
isPlus
?:
boolean
;
show_phoneLogin
?:
boolean
;
show_emailLogin
?:
boolean
;
sso
?:
{
icon
?:
string
;
title
?:
string
;
...
...
projects/app/src/pages/account/components/UpdateNotificationModal.tsx
View file @
649de7f0
...
...
@@ -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'
}
>
...
...
projects/app/src/pages/login/components/ForgetPasswordForm.tsx
View file @
649de7f0
...
...
@@ -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
:
{
...
...
projects/app/src/pages/login/components/LoginForm/LoginForm.tsx
View file @
649de7f0
...
...
@@ -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
.
key
Code
===
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
>
);
...
...
projects/app/src/pages/login/components/LoginForm/components/FormLayout.tsx
View file @
649de7f0
...
...
@@ -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'
}
>
...
...
projects/app/src/pages/login/components/RegisterForm.tsx
View file @
649de7f0
...
...
@@ -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
.
key
Code
===
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
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment