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 = {
...
@@ -24,7 +24,10 @@ export type FastGPTConfigFileType = {
export
type
FastGPTFeConfigsType
=
{
export
type
FastGPTFeConfigsType
=
{
show_emptyChat
?:
boolean
;
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_appStore
?:
boolean
;
show_git
?:
boolean
;
show_git
?:
boolean
;
show_pay
?:
boolean
;
show_pay
?:
boolean
;
...
@@ -43,8 +46,6 @@ export type FastGPTFeConfigsType = {
...
@@ -43,8 +46,6 @@ export type FastGPTFeConfigsType = {
systemDescription
?:
string
;
systemDescription
?:
string
;
googleClientVerKey
?:
string
;
googleClientVerKey
?:
string
;
isPlus
?:
boolean
;
isPlus
?:
boolean
;
show_phoneLogin
?:
boolean
;
show_emailLogin
?:
boolean
;
sso
?:
{
sso
?:
{
icon
?:
string
;
icon
?:
string
;
title
?:
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';
...
@@ -8,6 +8,7 @@ import { updateNotificationAccount } from '@/web/support/user/api';
import
Icon
from
'@fastgpt/web/components/common/Icon'
;
import
Icon
from
'@fastgpt/web/components/common/Icon'
;
import
{
useSendCode
}
from
'@/web/support/user/hooks/useSendCode'
;
import
{
useSendCode
}
from
'@/web/support/user/hooks/useSendCode'
;
import
{
useUserStore
}
from
'@/web/support/user/useUserStore'
;
import
{
useUserStore
}
from
'@/web/support/user/useUserStore'
;
import
{
useSystemStore
}
from
'@/web/common/system/useSystemStore'
;
type
FormType
=
{
type
FormType
=
{
account
:
string
;
account
:
string
;
...
@@ -17,6 +18,7 @@ type FormType = {
...
@@ -17,6 +18,7 @@ type FormType = {
const
UpdateNotificationModal
=
({
onClose
}:
{
onClose
:
()
=>
void
})
=>
{
const
UpdateNotificationModal
=
({
onClose
}:
{
onClose
:
()
=>
void
})
=>
{
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
const
{
initUserInfo
}
=
useUserStore
();
const
{
initUserInfo
}
=
useUserStore
();
const
{
feConfigs
}
=
useSystemStore
();
const
{
register
,
handleSubmit
,
trigger
,
getValues
,
watch
}
=
useForm
<
FormType
>
({
const
{
register
,
handleSubmit
,
trigger
,
getValues
,
watch
}
=
useForm
<
FormType
>
({
defaultValues
:
{
defaultValues
:
{
account
:
''
,
account
:
''
,
...
@@ -51,6 +53,17 @@ const UpdateNotificationModal = ({ onClose }: { onClose: () => void }) => {
...
@@ -51,6 +53,17 @@ const UpdateNotificationModal = ({ onClose }: { onClose: () => void }) => {
});
});
},
[
getValues
,
sendCode
,
trigger
]);
},
[
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
(
return
(
<
MyModal
<
MyModal
isOpen
isOpen
...
@@ -70,7 +83,7 @@ const UpdateNotificationModal = ({ onClose }: { onClose: () => void }) => {
...
@@ -70,7 +83,7 @@ const UpdateNotificationModal = ({ onClose }: { onClose: () => void }) => {
flex=
{
1
}
flex=
{
1
}
bg=
{
'myGray.50'
}
bg=
{
'myGray.50'
}
{
...
register
('
account
',
{
required
:
true
})}
{
...
register
('
account
',
{
required
:
true
})}
placeholder=
{
t
(
'user:password.email_phone'
)
}
placeholder=
{
placeholder
}
></
Input
>
></
Input
>
</
Flex
>
</
Flex
>
<
Flex
mt=
"6"
alignItems=
"center"
position=
{
'relative'
}
>
<
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) => {
...
@@ -46,6 +46,18 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
},
[
getValues
,
sendCode
,
trigger
]);
},
[
getValues
,
sendCode
,
trigger
]);
const
[
requesting
,
setRequesting
]
=
useState
(
false
);
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
(
const
onclickFindPassword
=
useCallback
(
async
({
username
,
code
,
password
}:
RegisterType
)
=>
{
async
({
username
,
code
,
password
}:
RegisterType
)
=>
{
...
@@ -89,7 +101,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
...
@@ -89,7 +101,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
<
FormControl
isInvalid=
{
!!
errors
.
username
}
>
<
FormControl
isInvalid=
{
!!
errors
.
username
}
>
<
Input
<
Input
bg=
{
'myGray.50'
}
bg=
{
'myGray.50'
}
placeholder=
{
t
(
'user:password.email_phone'
)
}
placeholder=
{
placeholder
}
{
...
register
('
username
',
{
{
...
register
('
username
',
{
required
:
t
('
user
:
password
.
email_phone_void
'),
required
:
t
('
user
:
password
.
email_phone_void
'),
pattern
:
{
pattern
:
{
...
...
projects/app/src/pages/login/components/LoginForm/LoginForm.tsx
View file @
649de7f0
...
@@ -57,24 +57,32 @@ const LoginForm = ({ setPageType, loginSuccess }: Props) => {
...
@@ -57,24 +57,32 @@ const LoginForm = ({ setPageType, loginSuccess }: Props) => {
[
loginSuccess
,
t
,
toast
]
[
loginSuccess
,
t
,
toast
]
);
);
const
isCommunityVersion
=
feConfigs
?.
show_register
===
false
&&
!
feConfigs
?.
isPlus
;
const
isCommunityVersion
=
!!
(
feConfigs
?.
register_method
&&
!
feConfigs
?.
isPlus
)
;
const
loginOptions
=
[
const
placeholder
=
(()
=>
{
feConfigs
?.
show_phoneLogin
?
t
(
'common:support.user.login.Phone number'
)
:
''
,
if
(
isCommunityVersion
)
{
feConfigs
?.
show_emailLogin
?
t
(
'common:support.user.login.Email'
)
:
''
,
return
t
(
'common:support.user.login.Root login'
);
t
(
'common:support.user.login.Username'
)
}
].
filter
(
Boolean
);
return
[
t
(
'common:support.user.login.Username'
)]
.
concat
(
const
placeholder
=
isCommunityVersion
feConfigs
?.
login_method
?.
map
((
item
)
=>
{
?
t
(
'common:support.user.login.Root login'
)
switch
(
item
)
{
:
loginOptions
.
join
(
'/'
);
case
'email'
:
return
t
(
'common:support.user.login.Email'
);
case
'phone'
:
return
t
(
'common:support.user.login.Phone number'
);
}
})
??
[]
)
.
join
(
'/'
);
})();
return
(
return
(
<
FormLayout
setPageType=
{
setPageType
}
pageType=
{
LoginPageTypeEnum
.
passwordLogin
}
>
<
FormLayout
setPageType=
{
setPageType
}
pageType=
{
LoginPageTypeEnum
.
passwordLogin
}
>
<
Box
<
Box
mt=
{
'42px'
}
mt=
{
'42px'
}
onKeyDown=
{
(
e
)
=>
{
onKeyDown=
{
(
e
)
=>
{
if
(
e
.
key
Code
===
13
&&
!
e
.
shiftKey
&&
!
requesting
)
{
if
(
e
.
key
===
'Enter'
&&
!
e
.
shiftKey
&&
!
requesting
)
{
handleSubmit
(
onclickLogin
)();
handleSubmit
(
onclickLogin
)();
}
}
}
}
}
}
...
@@ -140,17 +148,19 @@ const LoginForm = ({ setPageType, loginSuccess }: Props) => {
...
@@ -140,17 +148,19 @@ const LoginForm = ({ setPageType, loginSuccess }: Props) => {
{
t
(
'common:Login'
)
}
{
t
(
'common:Login'
)
}
</
Button
>
</
Button
>
{
feConfigs
?.
show_register
&&
(
<
Flex
align=
{
'center'
}
justifyContent=
{
'flex-end'
}
color=
{
'primary.700'
}
>
<>
{
feConfigs
?.
find_password_method
&&
feConfigs
.
find_password_method
.
length
>
0
&&
(
<
Flex
align=
{
'center'
}
justifyContent=
{
'flex-end'
}
color=
{
'primary.700'
}
>
<
Box
<
Box
cursor=
{
'pointer'
}
cursor=
{
'pointer'
}
_hover=
{
{
textDecoration
:
'underline'
}
}
_hover=
{
{
textDecoration
:
'underline'
}
}
onClick=
{
()
=>
setPageType
(
'forgetPassword'
)
}
onClick=
{
()
=>
setPageType
(
'forgetPassword'
)
}
fontSize=
"sm"
fontSize=
"sm"
>
>
{
t
(
'common:support.user.login.Forget Password'
)
}
{
t
(
'common:support.user.login.Forget Password'
)
}
</
Box
>
</
Box
>
)
}
{
feConfigs
?.
register_method
&&
feConfigs
.
register_method
.
length
>
0
&&
(
<>
<
Box
mx=
{
3
}
h=
{
'16px'
}
w=
{
'1.5px'
}
bg=
{
'myGray.250'
}
></
Box
>
<
Box
mx=
{
3
}
h=
{
'16px'
}
w=
{
'1.5px'
}
bg=
{
'myGray.250'
}
></
Box
>
<
Box
<
Box
cursor=
{
'pointer'
}
cursor=
{
'pointer'
}
...
@@ -160,9 +170,9 @@ const LoginForm = ({ setPageType, loginSuccess }: Props) => {
...
@@ -160,9 +170,9 @@ const LoginForm = ({ setPageType, loginSuccess }: Props) => {
>
>
{
t
(
'common:support.user.login.Register'
)
}
{
t
(
'common:support.user.login.Register'
)
}
</
Box
>
</
Box
>
</
Flex
>
</>
</>
)
}
)
}
</
Flex
>
</
Box
>
</
Box
>
</
FormLayout
>
</
FormLayout
>
);
);
...
...
projects/app/src/pages/login/components/LoginForm/components/FormLayout.tsx
View file @
649de7f0
...
@@ -67,6 +67,9 @@ const FormLayout = ({ children, setPageType, pageType }: Props) => {
...
@@ -67,6 +67,9 @@ const FormLayout = ({ children, setPageType, pageType }: Props) => {
]
]
:
[])
:
[])
];
];
const
show_oauth
=
!!
(
feConfigs
?.
sso
||
oAuthList
.
length
>
0
);
return
(
return
(
<
Flex
flexDirection=
{
'column'
}
h=
{
'100%'
}
>
<
Flex
flexDirection=
{
'column'
}
h=
{
'100%'
}
>
<
Flex
alignItems=
{
'center'
}
>
<
Flex
alignItems=
{
'center'
}
>
...
@@ -87,9 +90,9 @@ const FormLayout = ({ children, setPageType, pageType }: Props) => {
...
@@ -87,9 +90,9 @@ const FormLayout = ({ children, setPageType, pageType }: Props) => {
</
Box
>
</
Box
>
</
Flex
>
</
Flex
>
{
children
}
{
children
}
<
Box
flex=
{
1
}
/>
{
show_oauth
&&
(
{
feConfigs
?.
show_register
&&
oAuthList
.
length
>
0
&&
(
<>
<>
<
Box
flex=
{
1
}
/>
<
Box
position=
{
'relative'
}
>
<
Box
position=
{
'relative'
}
>
<
Divider
/>
<
Divider
/>
<
AbsoluteCenter
bg=
"white"
px=
"4"
color=
{
'myGray.500'
}
>
<
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) => {
...
@@ -90,6 +90,17 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
[
loginSuccess
,
t
,
toast
]
[
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
(
return
(
<>
<>
<
Box
fontWeight=
{
'bold'
}
fontSize=
{
'2xl'
}
textAlign=
{
'center'
}
>
<
Box
fontWeight=
{
'bold'
}
fontSize=
{
'2xl'
}
textAlign=
{
'center'
}
>
...
@@ -98,7 +109,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
...
@@ -98,7 +109,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
<
Box
<
Box
mt=
{
'42px'
}
mt=
{
'42px'
}
onKeyDown=
{
(
e
)
=>
{
onKeyDown=
{
(
e
)
=>
{
if
(
e
.
key
Code
===
13
&&
!
e
.
shiftKey
&&
!
requesting
)
{
if
(
e
.
key
===
'Enter'
&&
!
e
.
shiftKey
&&
!
requesting
)
{
handleSubmit
(
onclickRegister
)();
handleSubmit
(
onclickRegister
)();
}
}
}
}
}
}
...
@@ -106,7 +117,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
...
@@ -106,7 +117,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
<
FormControl
isInvalid=
{
!!
errors
.
username
}
>
<
FormControl
isInvalid=
{
!!
errors
.
username
}
>
<
Input
<
Input
bg=
{
'myGray.50'
}
bg=
{
'myGray.50'
}
placeholder=
{
t
(
'user:password.email_phone'
)
}
placeholder=
{
placeholder
}
{
...
register
('
username
',
{
{
...
register
('
username
',
{
required
:
t
('
user
:
password
.
email_phone_void
'),
required
:
t
('
user
:
password
.
email_phone_void
'),
pattern
:
{
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