Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
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
Commit
4d77d7e1
authored
Oct 15, 2023
by
dhb52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 社交平台登录
parent
889334bc
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
5 deletions
+26
-5
src/api/login/index.ts
+12
-0
src/api/login/types.ts
+3
-0
src/locales/zh-CN.ts
+1
-0
src/router/modules/remaining.ts
+4
-4
src/views/Login/SocialLogin.vue
+0
-0
src/views/Login/components/LoginForm.vue
+6
-1
No files found.
src/api/login/index.ts
View file @
4d77d7e1
...
@@ -47,6 +47,18 @@ export const smsLogin = (data: SmsLoginVO) => {
...
@@ -47,6 +47,18 @@ export const smsLogin = (data: SmsLoginVO) => {
return
request
.
post
({
url
:
'/system/auth/sms-login'
,
data
})
return
request
.
post
({
url
:
'/system/auth/sms-login'
,
data
})
}
}
// 社交快捷登录,使用 code 授权码
export
function
socialLogin
(
type
:
string
,
code
:
string
,
state
:
string
)
{
return
request
.
post
({
url
:
'/system/auth/social-login'
,
data
:
{
type
,
code
,
state
}
})
}
// 社交授权的跳转
// 社交授权的跳转
export
const
socialAuthRedirect
=
(
type
:
number
,
redirectUri
:
string
)
=>
{
export
const
socialAuthRedirect
=
(
type
:
number
,
redirectUri
:
string
)
=>
{
return
request
.
get
({
return
request
.
get
({
...
...
src/api/login/types.ts
View file @
4d77d7e1
...
@@ -2,6 +2,9 @@ export type UserLoginVO = {
...
@@ -2,6 +2,9 @@ export type UserLoginVO = {
username
:
string
username
:
string
password
:
string
password
:
string
captchaVerification
:
string
captchaVerification
:
string
socialType
?:
string
socialCode
?:
string
socialState
?:
string
}
}
export
type
TokenType
=
{
export
type
TokenType
=
{
...
...
src/locales/zh-CN.ts
View file @
4d77d7e1
...
@@ -141,6 +141,7 @@ export default {
...
@@ -141,6 +141,7 @@ export default {
},
},
router
:
{
router
:
{
login
:
'登录'
,
login
:
'登录'
,
socialLogin
:
'社交登录'
,
home
:
'首页'
,
home
:
'首页'
,
analysis
:
'分析页'
,
analysis
:
'分析页'
,
workplace
:
'工作台'
workplace
:
'工作台'
...
...
src/router/modules/remaining.ts
View file @
4d77d7e1
...
@@ -186,12 +186,12 @@ const remainingRouter: AppRouteRecordRaw[] = [
...
@@ -186,12 +186,12 @@ const remainingRouter: AppRouteRecordRaw[] = [
}
}
},
},
{
{
path
:
'/s
so
'
,
path
:
'/s
ocial-login
'
,
component
:
()
=>
import
(
'@/views/Login/Login.vue'
),
component
:
()
=>
import
(
'@/views/Login/
Social
Login.vue'
),
name
:
'S
SO
Login'
,
name
:
'S
ocial
Login'
,
meta
:
{
meta
:
{
hidden
:
true
,
hidden
:
true
,
title
:
t
(
'router.
l
ogin'
),
title
:
t
(
'router.
socialL
ogin'
),
noTagsView
:
true
noTagsView
:
true
}
}
},
},
...
...
src/views/Login/SocialLogin.vue
0 → 100644
View file @
4d77d7e1
This diff is collapsed.
Click to expand it.
src/views/Login/components/LoginForm.vue
View file @
4d77d7e1
...
@@ -284,8 +284,13 @@ const doSocialLogin = async (type: number) => {
...
@@ -284,8 +284,13 @@ const doSocialLogin = async (type: number) => {
})
})
}
}
// 计算 redirectUri
// 计算 redirectUri
// tricky: type、redirect需要先encode一次,否则钉钉回调会丢失。
// 配合 Login/SocialLogin.vue#getUrlValue() 使用
const
redirectUri
=
const
redirectUri
=
location
.
origin
+
'/social-login?type='
+
type
+
'&redirect='
+
(
redirect
.
value
||
'/'
)
location
.
origin
+
'/social-login?'
+
encodeURIComponent
(
`type=
${
type
}
&redirect=
${
redirect
.
value
||
'/'
}
`
)
// 进行跳转
// 进行跳转
const
res
=
await
LoginApi
.
socialAuthRedirect
(
type
,
encodeURIComponent
(
redirectUri
))
const
res
=
await
LoginApi
.
socialAuthRedirect
(
type
,
encodeURIComponent
(
redirectUri
))
window
.
location
.
href
=
res
window
.
location
.
href
=
res
...
...
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