feat: add social auth

This commit is contained in:
xingyu 2022-07-21 18:58:52 +08:00
parent 3d1afe5271
commit f2d7500822
2 changed files with 22 additions and 0 deletions

View File

@ -62,3 +62,10 @@ export const sendSmsCodeApi = (data: SmsCodeVO) => {
export const smsLoginApi = (data: SmsLoginVO) => {
return request.post({ url: '/system/auth/sms-login', data })
}
// 社交授权的跳转
export const socialAuthRedirectApi = (type: string, redirectUri: string) => {
return request.get({
url: '/system/auth/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri
})
}

View File

@ -131,6 +131,17 @@ const getRoutes = async () => {
permissionStore.setIsAddRouters(true)
push({ path: redirect.value || permissionStore.addRouters[0].path })
}
//
const doSocialLogin = async (type: string) => {
loginLoading.value = true
// redirectUri
const redirectUri =
location.origin + '/social-login?type=' + type + '&redirect=' + (redirect.value || '/')
//
const res = await LoginApi.socialAuthRedirectApi(type, encodeURIComponent(redirectUri))
window.open = res
}
watch(
() => currentRoute.value,
(route: RouteLocationNormalizedLoaded) => {
@ -267,24 +278,28 @@ onMounted(async () => {
:size="iconSize"
class="cursor-pointer anticon"
:color="iconColor"
@click="doSocialLogin('github')"
/>
<Icon
icon="ant-design:wechat-filled"
:size="iconSize"
class="cursor-pointer anticon"
:color="iconColor"
@click="doSocialLogin('wechat')"
/>
<Icon
icon="ant-design:alipay-circle-filled"
:size="iconSize"
:color="iconColor"
class="cursor-pointer anticon"
@click="doSocialLogin('alipay')"
/>
<Icon
icon="ant-design:dingtalk-circle-filled"
:size="iconSize"
:color="iconColor"
class="cursor-pointer anticon"
@click="doSocialLogin('dingtalk')"
/>
</div>
</el-form-item>