diff --git a/apps/web-antd/src/api/core/auth.ts b/apps/web-antd/src/api/core/auth.ts index 488c25e8b..809f29cdc 100644 --- a/apps/web-antd/src/api/core/auth.ts +++ b/apps/web-antd/src/api/core/auth.ts @@ -7,6 +7,10 @@ export namespace AuthApi { password?: string; username?: string; captchaVerification?: string; + // 绑定社交登录时,需要传递如下参数 + socialType?: number; + socialCode?: string; + socialState?: string; } /** 登录接口返回值 */ @@ -49,6 +53,12 @@ export namespace AuthApi { code: string; } + /** 社交快捷登录接口参数 */ + export interface SocialLoginParams { + type: number; + code: string; + state: string; + } } /** 登录 */ @@ -117,4 +127,19 @@ export const register = (data: AuthApi.RegisterParams) => { /** 通过短信重置密码 */ export const smsResetPassword = (data: AuthApi.ResetPasswordParams) => { return requestClient.post('/system/auth/reset-password', data) -} \ No newline at end of file +} + +/** 社交授权的跳转 */ +export const socialAuthRedirect = (type: number, redirectUri: string) => { + return requestClient.get('/system/auth/social-auth-redirect', { + params: { + type, + redirectUri, + }, + }); +} + +/** 社交快捷登录 */ +export const socialLogin = (data: AuthApi.SocialLoginParams) => { + return requestClient.post('/system/auth/social-login', data); +} diff --git a/apps/web-antd/src/router/routes/core.ts b/apps/web-antd/src/router/routes/core.ts index 7218da228..9db6312d8 100644 --- a/apps/web-antd/src/router/routes/core.ts +++ b/apps/web-antd/src/router/routes/core.ts @@ -89,6 +89,14 @@ const coreRoutes: RouteRecordRaw[] = [ title: $t('page.auth.register'), }, }, + { + name: 'SocialLogin', + path: 'social-login', + component: () => import('#/views/_core/authentication/social-login.vue'), + meta: { + title: $t('page.auth.login'), + }, + }, ], }, ]; diff --git a/apps/web-antd/src/store/auth.ts b/apps/web-antd/src/store/auth.ts index a66737a27..7f91d4639 100644 --- a/apps/web-antd/src/store/auth.ts +++ b/apps/web-antd/src/store/auth.ts @@ -9,7 +9,7 @@ import { resetAllStores, useAccessStore, useUserStore } from '@vben/stores'; import { notification } from 'ant-design-vue'; import { defineStore } from 'pinia'; -import { type AuthApi, getAuthPermissionInfoApi, loginApi, logoutApi, smsLogin, register } from '#/api'; +import { type AuthApi, getAuthPermissionInfoApi, loginApi, logoutApi, smsLogin, register, socialLogin } from '#/api'; import { $t } from '#/locales'; export const useAuthStore = defineStore('auth', () => { @@ -27,7 +27,7 @@ export const useAuthStore = defineStore('auth', () => { * @param onSuccess 登录成功后的回调函数 */ async function authLogin( - type: 'mobile' | 'username' | 'register', + type: 'mobile' | 'username' | 'register' | 'social', params: Recordable, onSuccess?: () => Promise | void, ) { @@ -37,6 +37,7 @@ export const useAuthStore = defineStore('auth', () => { loginLoading.value = true; const { accessToken, refreshToken } = type === 'mobile' ? await smsLogin(params as AuthApi.SmsLoginParams) : type === 'register' ? await register(params as AuthApi.RegisterParams) + : type === 'social' ? await socialLogin(params as AuthApi.SocialLoginParams) : await loginApi(params); // 如果成功获取到 accessToken diff --git a/apps/web-antd/src/views/_core/authentication/login.vue b/apps/web-antd/src/views/_core/authentication/login.vue index 34a88eec2..50102a439 100644 --- a/apps/web-antd/src/views/_core/authentication/login.vue +++ b/apps/web-antd/src/views/_core/authentication/login.vue @@ -1,6 +1,6 @@ + + diff --git a/packages/effects/common-ui/src/ui/authentication/login.vue b/packages/effects/common-ui/src/ui/authentication/login.vue index 08777c820..850697a49 100644 --- a/packages/effects/common-ui/src/ui/authentication/login.vue +++ b/packages/effects/common-ui/src/ui/authentication/login.vue @@ -44,6 +44,7 @@ const props = withDefaults(defineProps(), { const emit = defineEmits<{ submit: [Recordable]; + thirdLogin: [type: number]; }>(); const [Form, formApi] = useVbenForm( @@ -80,6 +81,15 @@ function handleGo(path: string) { router.push(path); } +/** + * 处理第三方登录 + * + * @param type 第三方平台类型 + */ +function handleThirdLogin(type: number) { + emit('thirdLogin', type); +} + onMounted(() => { if (localUsername) { formApi.setFieldValue('username', localUsername); @@ -168,7 +178,7 @@ defineExpose({ - + diff --git a/packages/effects/common-ui/src/ui/authentication/third-party-login.vue b/packages/effects/common-ui/src/ui/authentication/third-party-login.vue index 16533f490..fcfb9c1b3 100644 --- a/packages/effects/common-ui/src/ui/authentication/third-party-login.vue +++ b/packages/effects/common-ui/src/ui/authentication/third-party-login.vue @@ -1,5 +1,5 @@ diff --git a/packages/icons/src/iconify/index.ts b/packages/icons/src/iconify/index.ts index ae9230f9e..967204cdc 100644 --- a/packages/icons/src/iconify/index.ts +++ b/packages/icons/src/iconify/index.ts @@ -8,10 +8,10 @@ export const MdiWechat = createIconifyIcon('mdi:wechat'); export const MdiGithub = createIconifyIcon('mdi:github'); -export const MdiGoogle = createIconifyIcon('mdi:google'); - export const MdiQqchat = createIconifyIcon('mdi:qqchat'); +export const AntdDingTalk = createIconifyIcon('ant-design:dingtalk') + export const MdiCheckboxMarkedCircleOutline = createIconifyIcon( 'mdi:checkbox-marked-circle-outline', );