feat: add social auth
This commit is contained in:
parent
3d1afe5271
commit
f2d7500822
@ -62,3 +62,10 @@ export const sendSmsCodeApi = (data: SmsCodeVO) => {
|
|||||||
export const smsLoginApi = (data: SmsLoginVO) => {
|
export const smsLoginApi = (data: SmsLoginVO) => {
|
||||||
return request.post({ url: '/system/auth/sms-login', data })
|
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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -131,6 +131,17 @@ const getRoutes = async () => {
|
|||||||
permissionStore.setIsAddRouters(true)
|
permissionStore.setIsAddRouters(true)
|
||||||
push({ path: redirect.value || permissionStore.addRouters[0].path })
|
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(
|
watch(
|
||||||
() => currentRoute.value,
|
() => currentRoute.value,
|
||||||
(route: RouteLocationNormalizedLoaded) => {
|
(route: RouteLocationNormalizedLoaded) => {
|
||||||
@ -267,24 +278,28 @@ onMounted(async () => {
|
|||||||
:size="iconSize"
|
:size="iconSize"
|
||||||
class="cursor-pointer anticon"
|
class="cursor-pointer anticon"
|
||||||
:color="iconColor"
|
:color="iconColor"
|
||||||
|
@click="doSocialLogin('github')"
|
||||||
/>
|
/>
|
||||||
<Icon
|
<Icon
|
||||||
icon="ant-design:wechat-filled"
|
icon="ant-design:wechat-filled"
|
||||||
:size="iconSize"
|
:size="iconSize"
|
||||||
class="cursor-pointer anticon"
|
class="cursor-pointer anticon"
|
||||||
:color="iconColor"
|
:color="iconColor"
|
||||||
|
@click="doSocialLogin('wechat')"
|
||||||
/>
|
/>
|
||||||
<Icon
|
<Icon
|
||||||
icon="ant-design:alipay-circle-filled"
|
icon="ant-design:alipay-circle-filled"
|
||||||
:size="iconSize"
|
:size="iconSize"
|
||||||
:color="iconColor"
|
:color="iconColor"
|
||||||
class="cursor-pointer anticon"
|
class="cursor-pointer anticon"
|
||||||
|
@click="doSocialLogin('alipay')"
|
||||||
/>
|
/>
|
||||||
<Icon
|
<Icon
|
||||||
icon="ant-design:dingtalk-circle-filled"
|
icon="ant-design:dingtalk-circle-filled"
|
||||||
:size="iconSize"
|
:size="iconSize"
|
||||||
:color="iconColor"
|
:color="iconColor"
|
||||||
class="cursor-pointer anticon"
|
class="cursor-pointer anticon"
|
||||||
|
@click="doSocialLogin('dingtalk')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
Loading…
Reference in New Issue
Block a user