Skip to content

Commit 04e83e2

Browse files
YunaiVgitee-org
authored andcommitted
!271 添加社交登录页面,修复登录多次重定向问题
Merge pull request !271 from dhb52/master
2 parents 889334b + 89417ac commit 04e83e2

File tree

7 files changed

+373
-7
lines changed

7 files changed

+373
-7
lines changed

src/api/login/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ export const smsLogin = (data: SmsLoginVO) => {
4747
return request.post({ url: '/system/auth/sms-login', data })
4848
}
4949

50+
// 社交快捷登录,使用 code 授权码
51+
export function socialLogin(type: string, code: string, state: string) {
52+
return request.post({
53+
url: '/system/auth/social-login',
54+
data: {
55+
type,
56+
code,
57+
state
58+
}
59+
})
60+
}
61+
5062
// 社交授权的跳转
5163
export const socialAuthRedirect = (type: number, redirectUri: string) => {
5264
return request.get({

src/api/login/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ export type UserLoginVO = {
22
username: string
33
password: string
44
captchaVerification: string
5+
socialType?: string
6+
socialCode?: string
7+
socialState?: string
58
}
69

710
export type TokenType = {

src/locales/zh-CN.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export default {
141141
},
142142
router: {
143143
login: '登录',
144+
socialLogin: '社交登录',
144145
home: '首页',
145146
analysis: '分析页',
146147
workplace: '工作台'

src/router/modules/remaining.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,12 @@ const remainingRouter: AppRouteRecordRaw[] = [
186186
}
187187
},
188188
{
189-
path: '/sso',
190-
component: () => import('@/views/Login/Login.vue'),
191-
name: 'SSOLogin',
189+
path: '/social-login',
190+
component: () => import('@/views/Login/SocialLogin.vue'),
191+
name: 'SocialLogin',
192192
meta: {
193193
hidden: true,
194-
title: t('router.login'),
194+
title: t('router.socialLogin'),
195195
noTagsView: true
196196
}
197197
},
@@ -333,6 +333,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
333333
{
334334
path: '/mall/product', // 商品中心
335335
component: Layout,
336+
name: 'Product',
336337
meta: {
337338
hidden: true
338339
},
@@ -394,6 +395,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
394395
{
395396
path: '/mall/trade', // 交易中心
396397
component: Layout,
398+
name: 'Trade',
397399
meta: {
398400
hidden: true
399401
},

src/views/Login/Login.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<!-- 注册 -->
5656
<RegisterForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />
5757
<!-- 三方登录 -->
58-
<SSOLoginVue class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />
58+
<!-- <SSOLoginVue class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" /> -->
5959
</div>
6060
</Transition>
6161
</div>
@@ -70,7 +70,7 @@ import { useAppStore } from '@/store/modules/app'
7070
import { ThemeSwitch } from '@/layout/components/ThemeSwitch'
7171
import { LocaleDropdown } from '@/layout/components/LocaleDropdown'
7272
73-
import { LoginForm, MobileForm, QrCodeForm, RegisterForm, SSOLoginVue } from './components'
73+
import { LoginForm, MobileForm, QrCodeForm, RegisterForm } from './components'
7474
7575
defineOptions({ name: 'Login' })
7676

0 commit comments

Comments
 (0)