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
c67e6454
authored
Sep 01, 2025
by
Archer
Committed by
GitHub
Sep 01, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: login page (#5571)
parent
f41775fe
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
71 additions
and
51 deletions
+71
-51
document/content/docs/upgrading/4-12/4123.mdx
+1
-0
document/data/doc-last-modified.json
+2
-1
packages/web/i18n/en/common.json
+1
-1
packages/web/i18n/zh-CN/common.json
+1
-1
packages/web/i18n/zh-Hant/common.json
+1
-1
projects/app/src/global/support/api/userRes.d.ts
+1
-1
projects/app/src/pageComponents/login/ForgetPasswordForm.tsx
+2
-2
projects/app/src/pageComponents/login/LoginForm/LoginForm.tsx
+2
-2
projects/app/src/pageComponents/login/LoginForm/WechatForm.tsx
+3
-3
projects/app/src/pageComponents/login/LoginModal.tsx
+2
-2
projects/app/src/pageComponents/login/RegisterForm.tsx
+2
-2
projects/app/src/pageComponents/login/index.tsx
+4
-10
projects/app/src/pages/chat/index.tsx
+9
-2
projects/app/src/pages/login/fastlogin.tsx
+2
-2
projects/app/src/pages/login/index.tsx
+17
-3
projects/app/src/pages/login/provider.tsx
+12
-10
projects/app/src/web/support/user/api.ts
+9
-8
No files found.
document/content/docs/upgrading/4-12/4123.mdx
View file @
c67e6454
...
@@ -13,5 +13,6 @@ description: 'FastGPT V4.12.3 更新说明'
...
@@ -13,5 +13,6 @@ description: 'FastGPT V4.12.3 更新说明'
## 🐛 修复
## 🐛 修复
1. 单团队模式下,如果用户离开,则无法重新进入团队。
## 🔨 工具更新
## 🔨 工具更新
document/data/doc-last-modified.json
View file @
c67e6454
...
@@ -97,7 +97,7 @@
...
@@ -97,7 +97,7 @@
"document/content/docs/protocol/terms.en.mdx"
:
"2025-08-03T22:37:45+08:00"
,
"document/content/docs/protocol/terms.en.mdx"
:
"2025-08-03T22:37:45+08:00"
,
"document/content/docs/protocol/terms.mdx"
:
"2025-08-03T22:37:45+08:00"
,
"document/content/docs/protocol/terms.mdx"
:
"2025-08-03T22:37:45+08:00"
,
"document/content/docs/toc.en.mdx"
:
"2025-08-04T13:42:36+08:00"
,
"document/content/docs/toc.en.mdx"
:
"2025-08-04T13:42:36+08:00"
,
"document/content/docs/toc.mdx"
:
"2025-08-2
0T21:58:13
+08:00"
,
"document/content/docs/toc.mdx"
:
"2025-08-2
9T01:24:19
+08:00"
,
"document/content/docs/upgrading/4-10/4100.mdx"
:
"2025-08-02T19:38:37+08:00"
,
"document/content/docs/upgrading/4-10/4100.mdx"
:
"2025-08-02T19:38:37+08:00"
,
"document/content/docs/upgrading/4-10/4101.mdx"
:
"2025-08-02T19:38:37+08:00"
,
"document/content/docs/upgrading/4-10/4101.mdx"
:
"2025-08-02T19:38:37+08:00"
,
"document/content/docs/upgrading/4-11/4110.mdx"
:
"2025-08-05T23:20:39+08:00"
,
"document/content/docs/upgrading/4-11/4110.mdx"
:
"2025-08-05T23:20:39+08:00"
,
...
@@ -105,6 +105,7 @@
...
@@ -105,6 +105,7 @@
"document/content/docs/upgrading/4-12/4120.mdx"
:
"2025-08-12T22:45:19+08:00"
,
"document/content/docs/upgrading/4-12/4120.mdx"
:
"2025-08-12T22:45:19+08:00"
,
"document/content/docs/upgrading/4-12/4121.mdx"
:
"2025-08-15T22:53:06+08:00"
,
"document/content/docs/upgrading/4-12/4121.mdx"
:
"2025-08-15T22:53:06+08:00"
,
"document/content/docs/upgrading/4-12/4122.mdx"
:
"2025-08-27T00:31:33+08:00"
,
"document/content/docs/upgrading/4-12/4122.mdx"
:
"2025-08-27T00:31:33+08:00"
,
"document/content/docs/upgrading/4-12/4123.mdx"
:
"2025-08-29T01:24:19+08:00"
,
"document/content/docs/upgrading/4-8/40.mdx"
:
"2025-08-02T19:38:37+08:00"
,
"document/content/docs/upgrading/4-8/40.mdx"
:
"2025-08-02T19:38:37+08:00"
,
"document/content/docs/upgrading/4-8/41.mdx"
:
"2025-08-02T19:38:37+08:00"
,
"document/content/docs/upgrading/4-8/41.mdx"
:
"2025-08-02T19:38:37+08:00"
,
"document/content/docs/upgrading/4-8/42.mdx"
:
"2025-08-02T19:38:37+08:00"
,
"document/content/docs/upgrading/4-8/42.mdx"
:
"2025-08-02T19:38:37+08:00"
,
...
...
packages/web/i18n/en/common.json
View file @
c67e6454
...
@@ -893,7 +893,6 @@
...
@@ -893,7 +893,6 @@
"model.type.reRank"
:
"ReRank"
,
"model.type.reRank"
:
"ReRank"
,
"model.type.stt"
:
"STT"
,
"model.type.stt"
:
"STT"
,
"model.type.tts"
:
"TTS"
,
"model.type.tts"
:
"TTS"
,
"month"
:
"Month"
,
"month"
:
"Month"
,
"move.confirm"
:
"Confirm move"
,
"move.confirm"
:
"Confirm move"
,
"move_success"
:
"Moved Successfully"
,
"move_success"
:
"Moved Successfully"
,
...
@@ -915,6 +914,7 @@
...
@@ -915,6 +914,7 @@
"no_more_data"
:
"No More Data"
,
"no_more_data"
:
"No More Data"
,
"no_pay_way"
:
"There is no suitable payment channel in the system"
,
"no_pay_way"
:
"There is no suitable payment channel in the system"
,
"no_select_data"
:
"No Data Available"
,
"no_select_data"
:
"No Data Available"
,
"not_active_team"
:
"You have no available team"
,
"not_model_config"
:
"No related model configured"
,
"not_model_config"
:
"No related model configured"
,
"not_open"
:
"Not Open"
,
"not_open"
:
"Not Open"
,
"not_permission"
:
"The current subscription package does not support team operation logs"
,
"not_permission"
:
"The current subscription package does not support team operation logs"
,
...
...
packages/web/i18n/zh-CN/common.json
View file @
c67e6454
...
@@ -893,7 +893,6 @@
...
@@ -893,7 +893,6 @@
"model.type.reRank"
:
"重排模型"
,
"model.type.reRank"
:
"重排模型"
,
"model.type.stt"
:
"语音识别"
,
"model.type.stt"
:
"语音识别"
,
"model.type.tts"
:
"语音合成"
,
"model.type.tts"
:
"语音合成"
,
"month"
:
"月"
,
"month"
:
"月"
,
"move.confirm"
:
"确认移动"
,
"move.confirm"
:
"确认移动"
,
"move_success"
:
"移动成功"
,
"move_success"
:
"移动成功"
,
...
@@ -915,6 +914,7 @@
...
@@ -915,6 +914,7 @@
"no_more_data"
:
"没有更多了~"
,
"no_more_data"
:
"没有更多了~"
,
"no_pay_way"
:
"系统无合适的支付渠道"
,
"no_pay_way"
:
"系统无合适的支付渠道"
,
"no_select_data"
:
"没有可选值"
,
"no_select_data"
:
"没有可选值"
,
"not_active_team"
:
"你没有可用的团队"
,
"not_model_config"
:
"未配置相关模型"
,
"not_model_config"
:
"未配置相关模型"
,
"not_open"
:
"未开启"
,
"not_open"
:
"未开启"
,
"not_permission"
:
"当前订阅套餐不支持团队操作日志"
,
"not_permission"
:
"当前订阅套餐不支持团队操作日志"
,
...
...
packages/web/i18n/zh-Hant/common.json
View file @
c67e6454
...
@@ -892,7 +892,6 @@
...
@@ -892,7 +892,6 @@
"model.type.reRank"
:
"重排模型"
,
"model.type.reRank"
:
"重排模型"
,
"model.type.stt"
:
"語音辨識"
,
"model.type.stt"
:
"語音辨識"
,
"model.type.tts"
:
"語音合成"
,
"model.type.tts"
:
"語音合成"
,
"month"
:
"月"
,
"month"
:
"月"
,
"move.confirm"
:
"確認移動"
,
"move.confirm"
:
"確認移動"
,
"move_success"
:
"移動成功"
,
"move_success"
:
"移動成功"
,
...
@@ -914,6 +913,7 @@
...
@@ -914,6 +913,7 @@
"no_more_data"
:
"沒有更多資料了"
,
"no_more_data"
:
"沒有更多資料了"
,
"no_pay_way"
:
"系統無合適的支付渠道"
,
"no_pay_way"
:
"系統無合適的支付渠道"
,
"no_select_data"
:
"沒有可選擇的資料"
,
"no_select_data"
:
"沒有可選擇的資料"
,
"not_active_team"
:
"你沒有可用的團隊"
,
"not_model_config"
:
"未設定相關模型"
,
"not_model_config"
:
"未設定相關模型"
,
"not_open"
:
"未開啟"
,
"not_open"
:
"未開啟"
,
"not_permission"
:
"當前訂閱套餐不支持團隊操作日誌"
,
"not_permission"
:
"當前訂閱套餐不支持團隊操作日誌"
,
...
...
projects/app/src/global/support/api/userRes.d.ts
View file @
c67e6454
import
type
{
UserType
}
from
'@fastgpt/global/support/user/type.d'
;
import
type
{
UserType
}
from
'@fastgpt/global/support/user/type.d'
;
import
type
{
PromotionRecordSchema
}
from
'@fastgpt/global/support/activity/type.d'
;
import
type
{
PromotionRecordSchema
}
from
'@fastgpt/global/support/activity/type.d'
;
export
interface
ResLogin
{
export
interface
LoginSuccessResponse
{
user
:
UserType
;
user
:
UserType
;
token
:
string
;
token
:
string
;
}
}
...
...
projects/app/src/pageComponents/login/ForgetPasswordForm.tsx
View file @
c67e6454
...
@@ -4,7 +4,7 @@ import { useForm } from 'react-hook-form';
...
@@ -4,7 +4,7 @@ import { useForm } from 'react-hook-form';
import
{
LoginPageTypeEnum
}
from
'@/web/support/user/login/constants'
;
import
{
LoginPageTypeEnum
}
from
'@/web/support/user/login/constants'
;
import
{
postFindPassword
}
from
'@/web/support/user/api'
;
import
{
postFindPassword
}
from
'@/web/support/user/api'
;
import
{
useSendCode
}
from
'@/web/support/user/hooks/useSendCode'
;
import
{
useSendCode
}
from
'@/web/support/user/hooks/useSendCode'
;
import
type
{
ResLogin
}
from
'@/global/support/api/userRes.d'
;
import
type
{
LoginSuccessResponse
}
from
'@/global/support/api/userRes.d'
;
import
{
useToast
}
from
'@fastgpt/web/hooks/useToast'
;
import
{
useToast
}
from
'@fastgpt/web/hooks/useToast'
;
import
{
useSystemStore
}
from
'@/web/common/system/useSystemStore'
;
import
{
useSystemStore
}
from
'@/web/common/system/useSystemStore'
;
import
{
useTranslation
}
from
'next-i18next'
;
import
{
useTranslation
}
from
'next-i18next'
;
...
@@ -13,7 +13,7 @@ import { checkPasswordRule } from '@fastgpt/global/common/string/password';
...
@@ -13,7 +13,7 @@ import { checkPasswordRule } from '@fastgpt/global/common/string/password';
interface
Props
{
interface
Props
{
setPageType
:
Dispatch
<
`
${
LoginPageTypeEnum
}
`
>
;
setPageType
:
Dispatch
<
`
${
LoginPageTypeEnum
}
`
>
;
loginSuccess
:
(
e
:
ResLogin
)
=>
void
;
loginSuccess
:
(
e
:
LoginSuccessResponse
)
=>
void
;
}
}
interface
RegisterType
{
interface
RegisterType
{
...
...
projects/app/src/pageComponents/login/LoginForm/LoginForm.tsx
View file @
c67e6454
...
@@ -3,7 +3,7 @@ import { FormControl, Flex, Input, Button, Box } from '@chakra-ui/react';
...
@@ -3,7 +3,7 @@ import { FormControl, Flex, Input, Button, Box } from '@chakra-ui/react';
import
{
useForm
}
from
'react-hook-form'
;
import
{
useForm
}
from
'react-hook-form'
;
import
{
LoginPageTypeEnum
}
from
'@/web/support/user/login/constants'
;
import
{
LoginPageTypeEnum
}
from
'@/web/support/user/login/constants'
;
import
{
postLogin
,
getPreLogin
}
from
'@/web/support/user/api'
;
import
{
postLogin
,
getPreLogin
}
from
'@/web/support/user/api'
;
import
type
{
ResLogin
}
from
'@/global/support/api/userRes'
;
import
type
{
LoginSuccessResponse
}
from
'@/global/support/api/userRes'
;
import
{
useToast
}
from
'@fastgpt/web/hooks/useToast'
;
import
{
useToast
}
from
'@fastgpt/web/hooks/useToast'
;
import
{
useSystemStore
}
from
'@/web/common/system/useSystemStore'
;
import
{
useSystemStore
}
from
'@/web/common/system/useSystemStore'
;
import
{
useTranslation
}
from
'next-i18next'
;
import
{
useTranslation
}
from
'next-i18next'
;
...
@@ -13,7 +13,7 @@ import PolicyTip from './PolicyTip';
...
@@ -13,7 +13,7 @@ import PolicyTip from './PolicyTip';
interface
Props
{
interface
Props
{
setPageType
:
Dispatch
<
`
${
LoginPageTypeEnum
}
`
>
;
setPageType
:
Dispatch
<
`
${
LoginPageTypeEnum
}
`
>
;
loginSuccess
:
(
e
:
ResLogin
)
=>
void
;
loginSuccess
:
(
e
:
LoginSuccessResponse
)
=>
void
;
}
}
interface
LoginFormType
{
interface
LoginFormType
{
...
...
projects/app/src/pageComponents/login/LoginForm/WechatForm.tsx
View file @
c67e6454
import
React
,
{
type
Dispatch
}
from
'react'
;
import
React
,
{
type
Dispatch
}
from
'react'
;
import
{
LoginPageTypeEnum
}
from
'@/web/support/user/login/constants'
;
import
{
LoginPageTypeEnum
}
from
'@/web/support/user/login/constants'
;
import
type
{
ResLogin
}
from
'@/global/support/api/userRes'
;
import
type
{
LoginSuccessResponse
}
from
'@/global/support/api/userRes'
;
import
{
Box
,
Center
,
Flex
,
Link
}
from
'@chakra-ui/react'
;
import
{
Box
,
Center
,
Flex
,
Link
}
from
'@chakra-ui/react'
;
import
{
useQuery
}
from
'@tanstack/react-query'
;
import
{
useQuery
}
from
'@tanstack/react-query'
;
import
{
getWXLoginQR
,
getWXLoginResult
}
from
'@/web/support/user/api'
;
import
{
getWXLoginQR
,
getWXLoginResult
}
from
'@/web/support/user/api'
;
...
@@ -23,7 +23,7 @@ import { useSystemStore } from '@/web/common/system/useSystemStore';
...
@@ -23,7 +23,7 @@ import { useSystemStore } from '@/web/common/system/useSystemStore';
import
PolicyTip
from
'./PolicyTip'
;
import
PolicyTip
from
'./PolicyTip'
;
interface
Props
{
interface
Props
{
loginSuccess
:
(
e
:
ResLogin
)
=>
void
;
loginSuccess
:
(
e
:
LoginSuccessResponse
)
=>
void
;
setPageType
:
Dispatch
<
`
${
LoginPageTypeEnum
}
`
>
;
setPageType
:
Dispatch
<
`
${
LoginPageTypeEnum
}
`
>
;
}
}
...
@@ -55,7 +55,7 @@ const WechatForm = ({ setPageType, loginSuccess }: Props) => {
...
@@ -55,7 +55,7 @@ const WechatForm = ({ setPageType, loginSuccess }: Props) => {
{
{
refetchInterval
:
3
*
1000
,
refetchInterval
:
3
*
1000
,
enabled
:
!!
wechatInfo
?.
code
,
enabled
:
!!
wechatInfo
?.
code
,
onSuccess
(
data
:
ResLogin
|
undefined
)
{
onSuccess
(
data
:
LoginSuccessResponse
|
undefined
)
{
if
(
data
)
{
if
(
data
)
{
removeFastGPTSem
();
removeFastGPTSem
();
loginSuccess
(
data
);
loginSuccess
(
data
);
...
...
projects/app/src/pageComponents/login/LoginModal.tsx
View file @
c67e6454
...
@@ -4,10 +4,10 @@ import { LoginContainer } from '@/pageComponents/login';
...
@@ -4,10 +4,10 @@ import { LoginContainer } from '@/pageComponents/login';
import
I18nLngSelector
from
'@/components/Select/I18nLngSelector'
;
import
I18nLngSelector
from
'@/components/Select/I18nLngSelector'
;
import
{
useSystem
}
from
'@fastgpt/web/hooks/useSystem'
;
import
{
useSystem
}
from
'@fastgpt/web/hooks/useSystem'
;
import
{
getWebReqUrl
}
from
'@fastgpt/web/common/system/utils'
;
import
{
getWebReqUrl
}
from
'@fastgpt/web/common/system/utils'
;
import
type
{
ResLogin
}
from
'@/global/support/api/userRes'
;
import
type
{
LoginSuccessResponse
}
from
'@/global/support/api/userRes'
;
type
LoginModalProps
=
{
type
LoginModalProps
=
{
onSuccess
?:
(
res
:
ResLogin
)
=>
void
;
onSuccess
:
(
e
:
LoginSuccessResponse
)
=>
any
;
};
};
const
LoginModal
=
({
onSuccess
}:
LoginModalProps
)
=>
{
const
LoginModal
=
({
onSuccess
}:
LoginModalProps
)
=>
{
...
...
projects/app/src/pageComponents/login/RegisterForm.tsx
View file @
c67e6454
...
@@ -4,7 +4,7 @@ import { useForm } from 'react-hook-form';
...
@@ -4,7 +4,7 @@ import { useForm } from 'react-hook-form';
import
{
LoginPageTypeEnum
}
from
'@/web/support/user/login/constants'
;
import
{
LoginPageTypeEnum
}
from
'@/web/support/user/login/constants'
;
import
{
postRegister
}
from
'@/web/support/user/api'
;
import
{
postRegister
}
from
'@/web/support/user/api'
;
import
{
useSendCode
}
from
'@/web/support/user/hooks/useSendCode'
;
import
{
useSendCode
}
from
'@/web/support/user/hooks/useSendCode'
;
import
type
{
ResLogin
}
from
'@/global/support/api/userRes'
;
import
type
{
LoginSuccessResponse
}
from
'@/global/support/api/userRes'
;
import
{
useToast
}
from
'@fastgpt/web/hooks/useToast'
;
import
{
useToast
}
from
'@fastgpt/web/hooks/useToast'
;
import
{
postCreateApp
}
from
'@/web/core/app/api'
;
import
{
postCreateApp
}
from
'@/web/core/app/api'
;
import
{
emptyTemplates
}
from
'@/web/core/app/templates'
;
import
{
emptyTemplates
}
from
'@/web/core/app/templates'
;
...
@@ -23,7 +23,7 @@ import {
...
@@ -23,7 +23,7 @@ import {
import
{
checkPasswordRule
}
from
'@fastgpt/global/common/string/password'
;
import
{
checkPasswordRule
}
from
'@fastgpt/global/common/string/password'
;
interface
Props
{
interface
Props
{
loginSuccess
:
(
e
:
ResLogin
)
=>
void
;
loginSuccess
:
(
e
:
LoginSuccessResponse
)
=>
void
;
setPageType
:
Dispatch
<
`
${
LoginPageTypeEnum
}
`
>
;
setPageType
:
Dispatch
<
`
${
LoginPageTypeEnum
}
`
>
;
}
}
...
...
projects/app/src/pageComponents/login/index.tsx
View file @
c67e6454
...
@@ -10,7 +10,7 @@ import {
...
@@ -10,7 +10,7 @@ import {
}
from
'@chakra-ui/react'
;
}
from
'@chakra-ui/react'
;
import
{
LoginPageTypeEnum
}
from
'@/web/support/user/login/constants'
;
import
{
LoginPageTypeEnum
}
from
'@/web/support/user/login/constants'
;
import
{
useSystemStore
}
from
'@/web/common/system/useSystemStore'
;
import
{
useSystemStore
}
from
'@/web/common/system/useSystemStore'
;
import
type
{
ResLogin
}
from
'@/global/support/api/userRes.d'
;
import
type
{
LoginSuccessResponse
}
from
'@/global/support/api/userRes.d'
;
import
{
useUserStore
}
from
'@/web/support/user/useUserStore'
;
import
{
useUserStore
}
from
'@/web/support/user/useUserStore'
;
import
{
useChatStore
}
from
'@/web/core/chat/context/useChatStore'
;
import
{
useChatStore
}
from
'@/web/core/chat/context/useChatStore'
;
import
dynamic
from
'next/dynamic'
;
import
dynamic
from
'next/dynamic'
;
...
@@ -21,8 +21,6 @@ import { useTranslation } from 'next-i18next';
...
@@ -21,8 +21,6 @@ import { useTranslation } from 'next-i18next';
import
LoginForm
from
'@/pageComponents/login/LoginForm/LoginForm'
;
import
LoginForm
from
'@/pageComponents/login/LoginForm/LoginForm'
;
import
{
GET
}
from
'@/web/common/api/request'
;
import
{
GET
}
from
'@/web/common/api/request'
;
import
{
getDocPath
}
from
'@/web/common/system/doc'
;
import
{
getDocPath
}
from
'@/web/common/system/doc'
;
import
{
postAcceptInvitationLink
}
from
'@/web/support/user/team/api'
;
import
{
useRouter
}
from
'next/router'
;
const
RegisterForm
=
dynamic
(()
=>
import
(
'@/pageComponents/login/RegisterForm'
));
const
RegisterForm
=
dynamic
(()
=>
import
(
'@/pageComponents/login/RegisterForm'
));
const
ForgetPasswordForm
=
dynamic
(()
=>
import
(
'@/pageComponents/login/ForgetPasswordForm'
));
const
ForgetPasswordForm
=
dynamic
(()
=>
import
(
'@/pageComponents/login/ForgetPasswordForm'
));
...
@@ -187,25 +185,21 @@ export const LoginContainer = ({
...
@@ -187,25 +185,21 @@ export const LoginContainer = ({
onSuccess
onSuccess
}:
{
}:
{
children
?:
React
.
ReactNode
;
children
?:
React
.
ReactNode
;
onSuccess
?:
(
res
:
ResLogin
)
=>
void
;
onSuccess
:
(
res
:
LoginSuccessResponse
)
=>
void
;
})
=>
{
})
=>
{
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
const
{
feConfigs
}
=
useSystemStore
();
const
{
feConfigs
}
=
useSystemStore
();
const
{
setUserInfo
}
=
useUserStore
();
const
{
setLastChatAppId
}
=
useChatStore
();
const
{
setLastChatAppId
}
=
useChatStore
();
const
[
pageType
,
setPageType
]
=
useState
<
`
${
LoginPageTypeEnum
}
`
|
null
>
(
null
);
const
[
pageType
,
setPageType
]
=
useState
<
`
${
LoginPageTypeEnum
}
`
|
null
>
(
null
);
const
[
showCommunityModal
,
setShowCommunityModal
]
=
useState
(
false
);
const
[
showCommunityModal
,
setShowCommunityModal
]
=
useState
(
false
);
const
router
=
useRouter
();
const
{
lastRoute
=
''
}
=
router
.
query
as
{
lastRoute
:
string
};
// login success handler
// login success handler
const
loginSuccess
=
useCallback
(
const
loginSuccess
=
useCallback
(
async
(
res
:
ResLogin
)
=>
{
(
res
:
LoginSuccessResponse
)
=>
{
setUserInfo
(
res
.
user
);
onSuccess
?.(
res
);
onSuccess
?.(
res
);
},
},
[
setUserInfo
,
onSuccess
]
[
onSuccess
]
);
);
// initialization logic
// initialization logic
...
...
projects/app/src/pages/chat/index.tsx
View file @
c67e6454
import
React
,
{
useMemo
}
from
'react'
;
import
React
,
{
use
Callback
,
use
Memo
}
from
'react'
;
import
NextHead
from
'@/components/common/NextHead'
;
import
NextHead
from
'@/components/common/NextHead'
;
import
{
Box
,
Flex
}
from
'@chakra-ui/react'
;
import
{
Box
,
Flex
}
from
'@chakra-ui/react'
;
import
{
useChatStore
}
from
'@/web/core/chat/context/useChatStore'
;
import
{
useChatStore
}
from
'@/web/core/chat/context/useChatStore'
;
...
@@ -27,6 +27,8 @@ import {
...
@@ -27,6 +27,8 @@ import {
}
from
'@/web/core/chat/context/chatSettingContext'
;
}
from
'@/web/core/chat/context/chatSettingContext'
;
import
ChatTeamApp
from
'@/pageComponents/chat/ChatTeamApp'
;
import
ChatTeamApp
from
'@/pageComponents/chat/ChatTeamApp'
;
import
ChatFavouriteApp
from
'@/pageComponents/chat/ChatFavouriteApp'
;
import
ChatFavouriteApp
from
'@/pageComponents/chat/ChatFavouriteApp'
;
import
{
useUserStore
}
from
'@/web/support/user/useUserStore'
;
import
type
{
LoginSuccessResponse
}
from
'@/global/support/api/userRes'
;
const
Chat
=
({
myApps
}:
{
myApps
:
AppListItemType
[]
})
=>
{
const
Chat
=
({
myApps
}:
{
myApps
:
AppListItemType
[]
})
=>
{
const
{
isPc
}
=
useSystem
();
const
{
isPc
}
=
useSystem
();
...
@@ -89,6 +91,7 @@ const Chat = ({ myApps }: { myApps: AppListItemType[] }) => {
...
@@ -89,6 +91,7 @@ const Chat = ({ myApps }: { myApps: AppListItemType[] }) => {
const
Render
=
(
props
:
{
appId
:
string
;
isStandalone
?:
string
})
=>
{
const
Render
=
(
props
:
{
appId
:
string
;
isStandalone
?:
string
})
=>
{
const
{
appId
,
isStandalone
}
=
props
;
const
{
appId
,
isStandalone
}
=
props
;
const
{
chatId
}
=
useChatStore
();
const
{
chatId
}
=
useChatStore
();
const
{
setUserInfo
}
=
useUserStore
();
const
{
feConfigs
}
=
useSystemStore
();
const
{
feConfigs
}
=
useSystemStore
();
const
{
isInitedUser
,
userInfo
,
myApps
}
=
useChat
(
appId
);
const
{
isInitedUser
,
userInfo
,
myApps
}
=
useChat
(
appId
);
...
@@ -105,6 +108,10 @@ const Render = (props: { appId: string; isStandalone?: string }) => {
...
@@ -105,6 +108,10 @@ const Render = (props: { appId: string; isStandalone?: string }) => {
};
};
},
[
appId
,
chatId
]);
},
[
appId
,
chatId
]);
const
loginSuccess
=
useCallback
(
async
(
res
:
LoginSuccessResponse
)
=>
{
setUserInfo
(
res
.
user
);
},
[]);
// Waiting for user info to be initialized
// Waiting for user info to be initialized
if
(
!
isInitedUser
)
{
if
(
!
isInitedUser
)
{
return
(
return
(
...
@@ -120,7 +127,7 @@ const Render = (props: { appId: string; isStandalone?: string }) => {
...
@@ -120,7 +127,7 @@ const Render = (props: { appId: string; isStandalone?: string }) => {
<>
<>
<
NextHead
title=
{
feConfigs
?.
systemTitle
}
></
NextHead
>
<
NextHead
title=
{
feConfigs
?.
systemTitle
}
></
NextHead
>
<
LoginModal
/>
<
LoginModal
onSuccess=
{
loginSuccess
}
/>
</>
</>
);
);
}
}
...
...
projects/app/src/pages/login/fastlogin.tsx
View file @
c67e6454
import
React
,
{
useCallback
,
useEffect
}
from
'react'
;
import
React
,
{
useCallback
,
useEffect
}
from
'react'
;
import
{
useRouter
}
from
'next/router'
;
import
{
useRouter
}
from
'next/router'
;
import
type
{
ResLogin
}
from
'@/global/support/api/userRes.d'
;
import
type
{
LoginSuccessResponse
}
from
'@/global/support/api/userRes.d'
;
import
{
useUserStore
}
from
'@/web/support/user/useUserStore'
;
import
{
useUserStore
}
from
'@/web/support/user/useUserStore'
;
import
{
clearToken
}
from
'@/web/support/user/auth'
;
import
{
clearToken
}
from
'@/web/support/user/auth'
;
import
{
postFastLogin
}
from
'@/web/support/user/api'
;
import
{
postFastLogin
}
from
'@/web/support/user/api'
;
...
@@ -23,7 +23,7 @@ const FastLogin = ({
...
@@ -23,7 +23,7 @@ const FastLogin = ({
const
{
toast
}
=
useToast
();
const
{
toast
}
=
useToast
();
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
const
loginSuccess
=
useCallback
(
const
loginSuccess
=
useCallback
(
(
res
:
ResLogin
)
=>
{
(
res
:
LoginSuccessResponse
)
=>
{
setUserInfo
(
res
.
user
);
setUserInfo
(
res
.
user
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
...
...
projects/app/src/pages/login/index.tsx
View file @
c67e6454
...
@@ -5,14 +5,22 @@ import { clearToken } from '@/web/support/user/auth';
...
@@ -5,14 +5,22 @@ import { clearToken } from '@/web/support/user/auth';
import
{
useMount
}
from
'ahooks'
;
import
{
useMount
}
from
'ahooks'
;
import
LoginModal
from
'@/pageComponents/login/LoginModal'
;
import
LoginModal
from
'@/pageComponents/login/LoginModal'
;
import
{
postAcceptInvitationLink
}
from
'@/web/support/user/team/api'
;
import
{
postAcceptInvitationLink
}
from
'@/web/support/user/team/api'
;
import
type
{
ResLogin
}
from
'@/global/support/api/userRes'
;
import
type
{
LoginSuccessResponse
}
from
'@/global/support/api/userRes'
;
import
{
useToast
}
from
'@fastgpt/web/hooks/useToast'
;
import
{
useTranslation
}
from
'next-i18next'
;
import
{
useUserStore
}
from
'@/web/support/user/useUserStore'
;
const
Login
=
()
=>
{
const
Login
=
()
=>
{
const
router
=
useRouter
();
const
router
=
useRouter
();
const
{
lastRoute
=
''
}
=
router
.
query
as
{
lastRoute
:
string
};
const
{
lastRoute
=
''
}
=
router
.
query
as
{
lastRoute
:
string
};
const
{
t
}
=
useTranslation
();
const
{
toast
}
=
useToast
();
const
{
setUserInfo
}
=
useUserStore
();
const
loginSuccess
=
useCallback
(
const
loginSuccess
=
useCallback
(
async
(
res
:
ResLogin
)
=>
{
async
(
res
:
LoginSuccessResponse
)
=>
{
setUserInfo
(
res
.
user
);
const
decodeLastRoute
=
decodeURIComponent
(
lastRoute
);
const
decodeLastRoute
=
decodeURIComponent
(
lastRoute
);
const
navigateTo
=
await
(
async
()
=>
{
const
navigateTo
=
await
(
async
()
=>
{
if
(
res
.
user
.
team
.
status
!==
'active'
)
{
if
(
res
.
user
.
team
.
status
!==
'active'
)
{
...
@@ -20,8 +28,14 @@ const Login = () => {
...
@@ -20,8 +28,14 @@ const Login = () => {
const
id
=
decodeLastRoute
.
split
(
'invitelinkid='
)[
1
];
const
id
=
decodeLastRoute
.
split
(
'invitelinkid='
)[
1
];
await
postAcceptInvitationLink
(
id
);
await
postAcceptInvitationLink
(
id
);
return
'/dashboard/apps'
;
return
'/dashboard/apps'
;
}
else
{
toast
({
status
:
'warning'
,
title
:
t
(
'common:not_active_team'
)
});
}
}
}
}
return
decodeLastRoute
&&
return
decodeLastRoute
&&
!
decodeLastRoute
.
includes
(
'/login'
)
&&
!
decodeLastRoute
.
includes
(
'/login'
)
&&
decodeLastRoute
.
startsWith
(
'/'
)
decodeLastRoute
.
startsWith
(
'/'
)
...
@@ -29,7 +43,7 @@ const Login = () => {
...
@@ -29,7 +43,7 @@ const Login = () => {
:
'/dashboard/apps'
;
:
'/dashboard/apps'
;
})();
})();
router
.
replace
(
navigateTo
);
navigateTo
&&
router
.
replace
(
navigateTo
);
},
},
[
lastRoute
,
router
]
[
lastRoute
,
router
]
);
);
...
...
projects/app/src/pages/login/provider.tsx
View file @
c67e6454
import
React
,
{
useCallback
,
useEffect
}
from
'react'
;
import
React
,
{
useCallback
,
useEffect
}
from
'react'
;
import
{
useRouter
}
from
'next/router'
;
import
{
useRouter
}
from
'next/router'
;
import
{
useSystemStore
}
from
'@/web/common/system/useSystemStore'
;
import
{
useSystemStore
}
from
'@/web/common/system/useSystemStore'
;
import
type
{
ResLogin
}
from
'@/global/support/api/userRes.d'
;
import
type
{
LoginSuccessResponse
}
from
'@/global/support/api/userRes.d'
;
import
{
useUserStore
}
from
'@/web/support/user/useUserStore'
;
import
{
useUserStore
}
from
'@/web/support/user/useUserStore'
;
import
{
clearToken
}
from
'@/web/support/user/auth'
;
import
{
clearToken
}
from
'@/web/support/user/auth'
;
import
{
oauthLogin
}
from
'@/web/support/user/api'
;
import
{
oauthLogin
}
from
'@/web/support/user/api'
;
...
@@ -32,35 +32,37 @@ const provider = () => {
...
@@ -32,35 +32,37 @@ const provider = () => {
const
{
toast
}
=
useToast
();
const
{
toast
}
=
useToast
();
const
lastRoute
=
loginStore
?.
lastRoute
const
lastRoute
=
loginStore
?.
lastRoute
?
decodeURIComponent
(
loginStore
?
.
lastRoute
)
?
decodeURIComponent
(
loginStore
.
lastRoute
)
:
'/dashboard/apps'
;
:
'/dashboard/apps'
;
const
errorRedirectPage
=
lastRoute
.
startsWith
(
'/chat'
)
?
lastRoute
:
'/login'
;
const
errorRedirectPage
=
lastRoute
.
startsWith
(
'/chat'
)
?
lastRoute
:
'/login'
;
// const loginSuccess = useCallback(async () => {
// const decodeLastRoute = decodeURIComponent(lastRoute);
// router.push(navigateTo);
// }, [lastRoute, router]);
const
loginSuccess
=
useCallback
(
const
loginSuccess
=
useCallback
(
async
(
res
:
ResLogin
)
=>
{
async
(
res
:
LoginSuccessResponse
)
=>
{
const
decodeLastRoute
=
decodeURIComponent
(
lastRoute
);
const
decodeLastRoute
=
decodeURIComponent
(
lastRoute
);
setUserInfo
(
res
.
user
);
setUserInfo
(
res
.
user
);
const
navigateTo
=
await
(
async
()
=>
{
const
navigateTo
=
await
(
async
()
=>
{
if
(
res
.
user
.
team
.
status
!==
'active'
)
{
if
(
res
.
user
.
team
.
status
!==
'active'
)
{
if
(
decodeLastRoute
.
includes
(
'/account/team?invitelinkid='
))
{
if
(
decodeLastRoute
.
includes
(
'/account/team?invitelinkid='
))
{
const
id
=
decodeLastRoute
.
split
(
'invitelinkid='
)[
1
];
const
id
=
decodeLastRoute
.
split
(
'invitelinkid='
)[
1
];
await
postAcceptInvitationLink
(
id
);
await
postAcceptInvitationLink
(
id
);
return
'/dashboard/apps'
;
return
'/dashboard/apps'
;
}
else
{
toast
({
status
:
'warning'
,
title
:
t
(
'common:not_active_team'
)
});
}
}
}
}
return
decodeLastRoute
&&
return
decodeLastRoute
&&
!
decodeLastRoute
.
includes
(
'/login'
)
&&
!
decodeLastRoute
.
includes
(
'/login'
)
&&
decodeLastRoute
.
startsWith
(
'/'
)
decodeLastRoute
.
startsWith
(
'/'
)
?
lastRoute
?
lastRoute
:
'/dashboard/apps'
;
:
'/dashboard/apps'
;
})();
})();
router
.
replace
(
navigateTo
);
navigateTo
&&
router
.
replace
(
navigateTo
);
},
},
[
setUserInfo
,
router
,
lastRoute
]
[
setUserInfo
,
router
,
lastRoute
]
);
);
...
...
projects/app/src/web/support/user/api.ts
View file @
c67e6454
import
{
GET
,
POST
,
PUT
}
from
'@/web/common/api/request'
;
import
{
GET
,
POST
,
PUT
}
from
'@/web/common/api/request'
;
import
{
hashStr
}
from
'@fastgpt/global/common/string/tools'
;
import
{
hashStr
}
from
'@fastgpt/global/common/string/tools'
;
import
type
{
ResLogin
}
from
'@/global/support/api/userRes.d'
;
import
type
{
LoginSuccessResponse
}
from
'@/global/support/api/userRes.d'
;
import
type
{
UserAuthTypeEnum
}
from
'@fastgpt/global/support/user/auth/constants'
;
import
type
{
UserAuthTypeEnum
}
from
'@fastgpt/global/support/user/auth/constants'
;
import
type
{
UserUpdateParams
}
from
'@/types/user'
;
import
type
{
UserUpdateParams
}
from
'@/types/user'
;
import
type
{
UserType
}
from
'@fastgpt/global/support/user/type.d'
;
import
type
{
UserType
}
from
'@fastgpt/global/support/user/type.d'
;
...
@@ -27,10 +27,11 @@ export const sendAuthCode = (data: {
...
@@ -27,10 +27,11 @@ export const sendAuthCode = (data: {
export
const
getTokenLogin
=
()
=>
export
const
getTokenLogin
=
()
=>
GET
<
UserType
>
(
'/support/user/account/tokenLogin'
,
{},
{
maxQuantity
:
1
});
GET
<
UserType
>
(
'/support/user/account/tokenLogin'
,
{},
{
maxQuantity
:
1
});
export
const
oauthLogin
=
(
params
:
OauthLoginProps
)
=>
export
const
oauthLogin
=
(
params
:
OauthLoginProps
)
=>
POST
<
ResLogin
>
(
'/proApi/support/user/account/login/oauth'
,
params
);
POST
<
LoginSuccessResponse
>
(
'/proApi/support/user/account/login/oauth'
,
params
);
export
const
postFastLogin
=
(
params
:
FastLoginProps
)
=>
export
const
postFastLogin
=
(
params
:
FastLoginProps
)
=>
POST
<
ResLogin
>
(
'/proApi/support/user/account/login/fastLogin'
,
params
);
POST
<
LoginSuccessResponse
>
(
'/proApi/support/user/account/login/fastLogin'
,
params
);
export
const
ssoLogin
=
(
params
:
any
)
=>
GET
<
ResLogin
>
(
'/proApi/support/user/account/sso'
,
params
);
export
const
ssoLogin
=
(
params
:
any
)
=>
GET
<
LoginSuccessResponse
>
(
'/proApi/support/user/account/sso'
,
params
);
export
const
postRegister
=
({
export
const
postRegister
=
({
username
,
username
,
...
@@ -41,7 +42,7 @@ export const postRegister = ({
...
@@ -41,7 +42,7 @@ export const postRegister = ({
msclkid
,
msclkid
,
fastgpt_sem
fastgpt_sem
}:
AccountRegisterBody
)
=>
}:
AccountRegisterBody
)
=>
POST
<
ResLogin
>
(
`/proApi/support/user/account/register/emailAndPhone`
,
{
POST
<
LoginSuccessResponse
>
(
`/proApi/support/user/account/register/emailAndPhone`
,
{
username
,
username
,
code
,
code
,
inviterId
,
inviterId
,
...
@@ -60,7 +61,7 @@ export const postFindPassword = ({
...
@@ -60,7 +61,7 @@ export const postFindPassword = ({
code
:
string
;
code
:
string
;
password
:
string
;
password
:
string
;
})
=>
})
=>
POST
<
ResLogin
>
(
`/proApi/support/user/account/password/updateByCode`
,
{
POST
<
LoginSuccessResponse
>
(
`/proApi/support/user/account/password/updateByCode`
,
{
username
,
username
,
code
,
code
,
password
:
hashStr
(
password
)
password
:
hashStr
(
password
)
...
@@ -88,7 +89,7 @@ export const updateContact = (data: { contact: string; verifyCode: string }) =>
...
@@ -88,7 +89,7 @@ export const updateContact = (data: { contact: string; verifyCode: string }) =>
};
};
export
const
postLogin
=
({
password
,
...
props
}:
PostLoginProps
)
=>
export
const
postLogin
=
({
password
,
...
props
}:
PostLoginProps
)
=>
POST
<
ResLogin
>
(
'/support/user/account/loginByPassword'
,
{
POST
<
LoginSuccessResponse
>
(
'/support/user/account/loginByPassword'
,
{
...
props
,
...
props
,
password
:
hashStr
(
password
)
password
:
hashStr
(
password
)
});
});
...
@@ -101,7 +102,7 @@ export const getWXLoginQR = () =>
...
@@ -101,7 +102,7 @@ export const getWXLoginQR = () =>
GET
<
GetWXLoginQRResponse
>
(
'/proApi/support/user/account/login/wx/getQR'
);
GET
<
GetWXLoginQRResponse
>
(
'/proApi/support/user/account/login/wx/getQR'
);
export
const
getWXLoginResult
=
(
params
:
WxLoginProps
)
=>
export
const
getWXLoginResult
=
(
params
:
WxLoginProps
)
=>
POST
<
ResLogin
>
(
`/proApi/support/user/account/login/wx/getResult`
,
params
);
POST
<
LoginSuccessResponse
>
(
`/proApi/support/user/account/login/wx/getResult`
,
params
);
export
const
getCaptchaPic
=
(
username
:
string
)
=>
export
const
getCaptchaPic
=
(
username
:
string
)
=>
GET
<
{
GET
<
{
...
...
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