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
4e2ab1f6
authored
Jul 15, 2025
by
Zhuangzai fa
Committed by
GitHub
Jul 15, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enhance WeChat login functionality (#5213)
* Enhance WeChat login functionality * Add inviterId
parent
0c0e54cb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
15 deletions
+36
-15
packages/global/support/user/api.d.ts
+4
-0
projects/app/src/pageComponents/login/LoginForm/WechatForm.tsx
+28
-7
projects/app/src/pages/login/index.tsx
+1
-6
projects/app/src/web/support/user/api.ts
+3
-2
No files found.
packages/global/support/user/api.d.ts
View file @
4e2ab1f6
...
@@ -21,6 +21,10 @@ export type OauthLoginProps = {
...
@@ -21,6 +21,10 @@ export type OauthLoginProps = {
export
type
WxLoginProps
=
{
export
type
WxLoginProps
=
{
inviterId
?:
string
;
inviterId
?:
string
;
code
:
string
;
code
:
string
;
bd_vid
?:
string
;
msclkid
?:
string
;
fastgpt_sem
?:
string
;
sourceDomain
?:
string
;
};
};
export
type
FastLoginProps
=
{
export
type
FastLoginProps
=
{
...
...
projects/app/src/pageComponents/login/LoginForm/WechatForm.tsx
View file @
4e2ab1f6
...
@@ -10,6 +10,14 @@ import FormLayout from './FormLayout';
...
@@ -10,6 +10,14 @@ import FormLayout from './FormLayout';
import
{
useTranslation
}
from
'next-i18next'
;
import
{
useTranslation
}
from
'next-i18next'
;
import
Loading
from
'@fastgpt/web/components/common/MyLoading'
;
import
Loading
from
'@fastgpt/web/components/common/MyLoading'
;
import
MyImage
from
'@fastgpt/web/components/common/Image/MyImage'
;
import
MyImage
from
'@fastgpt/web/components/common/Image/MyImage'
;
import
{
getBdVId
,
getFastGPTSem
,
getMsclkid
,
getSourceDomain
,
removeFastGPTSem
,
getInviterId
}
from
'@/web/support/marketing/utils'
;
interface
Props
{
interface
Props
{
loginSuccess
:
(
e
:
ResLogin
)
=>
void
;
loginSuccess
:
(
e
:
ResLogin
)
=>
void
;
...
@@ -29,15 +37,28 @@ const WechatForm = ({ setPageType, loginSuccess }: Props) => {
...
@@ -29,15 +37,28 @@ const WechatForm = ({ setPageType, loginSuccess }: Props) => {
}
}
});
});
useQuery
([
'getWXLoginResult'
,
wechatInfo
?.
code
],
()
=>
getWXLoginResult
(
wechatInfo
?.
code
||
''
),
{
useQuery
(
refetchInterval
:
3
*
1000
,
[
'getWXLoginResult'
,
wechatInfo
?.
code
],
enabled
:
!!
wechatInfo
?.
code
,
()
=>
onSuccess
(
data
:
ResLogin
|
undefined
)
{
getWXLoginResult
({
if
(
data
)
{
inviterId
:
getInviterId
(),
loginSuccess
(
data
);
code
:
wechatInfo
?.
code
||
''
,
bd_vid
:
getBdVId
(),
msclkid
:
getMsclkid
(),
fastgpt_sem
:
getFastGPTSem
(),
sourceDomain
:
getSourceDomain
()
}),
{
refetchInterval
:
3
*
1000
,
enabled
:
!!
wechatInfo
?.
code
,
onSuccess
(
data
:
ResLogin
|
undefined
)
{
if
(
data
)
{
removeFastGPTSem
();
loginSuccess
(
data
);
}
}
}
}
}
}
);
);
return
(
return
(
<
FormLayout
setPageType=
{
setPageType
}
pageType=
{
LoginPageTypeEnum
.
wechat
}
>
<
FormLayout
setPageType=
{
setPageType
}
pageType=
{
LoginPageTypeEnum
.
wechat
}
>
...
...
projects/app/src/pages/login/index.tsx
View file @
4e2ab1f6
...
@@ -90,15 +90,10 @@ const Login = ({ ChineseRedirectUrl }: { ChineseRedirectUrl: string }) => {
...
@@ -90,15 +90,10 @@ const Login = ({ ChineseRedirectUrl }: { ChineseRedirectUrl: string }) => {
/* default login type */
/* default login type */
useEffect
(()
=>
{
useEffect
(()
=>
{
const
bd_vid
=
getBdVId
();
//delete bd_vid and show WeChat login
if
(
bd_vid
)
{
setPageType
(
LoginPageTypeEnum
.
passwordLogin
);
return
;
}
setPageType
(
setPageType
(
feConfigs
?.
oauth
?.
wechat
?
LoginPageTypeEnum
.
wechat
:
LoginPageTypeEnum
.
passwordLogin
feConfigs
?.
oauth
?.
wechat
?
LoginPageTypeEnum
.
wechat
:
LoginPageTypeEnum
.
passwordLogin
);
);
// init store
// init store
setLastChatAppId
(
''
);
setLastChatAppId
(
''
);
},
[
feConfigs
?.
oauth
,
setLastChatAppId
]);
},
[
feConfigs
?.
oauth
,
setLastChatAppId
]);
...
...
projects/app/src/web/support/user/api.ts
View file @
4e2ab1f6
...
@@ -15,6 +15,7 @@ import type {
...
@@ -15,6 +15,7 @@ import type {
GetWXLoginQRResponse
GetWXLoginQRResponse
}
from
'@fastgpt/global/support/user/login/api.d'
;
}
from
'@fastgpt/global/support/user/login/api.d'
;
import
type
{
preLoginResponse
}
from
'@/pages/api/support/user/account/preLogin'
;
import
type
{
preLoginResponse
}
from
'@/pages/api/support/user/account/preLogin'
;
import
type
{
WxLoginProps
}
from
'@fastgpt/global/support/user/api.d'
;
export
const
sendAuthCode
=
(
data
:
{
export
const
sendAuthCode
=
(
data
:
{
username
:
string
;
username
:
string
;
...
@@ -99,8 +100,8 @@ export const putUserInfo = (data: UserUpdateParams) => PUT('/support/user/accoun
...
@@ -99,8 +100,8 @@ export const putUserInfo = (data: UserUpdateParams) => PUT('/support/user/accoun
export
const
getWXLoginQR
=
()
=>
export
const
getWXLoginQR
=
()
=>
GET
<
GetWXLoginQRResponse
>
(
'/proApi/support/user/account/login/wx/getQR'
);
GET
<
GetWXLoginQRResponse
>
(
'/proApi/support/user/account/login/wx/getQR'
);
export
const
getWXLoginResult
=
(
code
:
string
)
=>
export
const
getWXLoginResult
=
(
params
:
WxLoginProps
)
=>
GET
<
ResLogin
>
(
`/proApi/support/user/account/login/wx/getResult`
,
{
code
}
);
GET
<
ResLogin
>
(
`/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