mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-10-17 04:57:15 +08:00
fix: 修复第三方登录错误
This commit is contained in:
@@ -44,33 +44,38 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import type { ModeItem } from '../type'
|
||||
import VerifyModel from '../components/VerifyModel.vue'
|
||||
import { listUserSocial, socialAuth, unbindSocialAccount } from '@/apis'
|
||||
import { useUserStore } from '@/stores'
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
const socialList = ref<any>([])
|
||||
const modeList = ref<ModeItem[]>([])
|
||||
modeList.value = [
|
||||
{
|
||||
title: '绑定 Gitee',
|
||||
icon: 'gitee',
|
||||
subtitle: `${socialList.value.includes('gitee') ? '' : '绑定后,'}可通过 Gitee 进行登录`,
|
||||
jumpMode: 'link',
|
||||
type: 'gitee',
|
||||
status: socialList.value.includes('gitee')
|
||||
},
|
||||
{
|
||||
title: '绑定 GitHub',
|
||||
icon: 'github',
|
||||
subtitle: `${socialList.value.includes('gitee') ? '' : '绑定后,'}可通过 GitHub 进行登录`,
|
||||
type: 'github',
|
||||
jumpMode: 'link',
|
||||
status: socialList.value.includes('github')
|
||||
}
|
||||
]
|
||||
|
||||
// 初始化数据
|
||||
const initData = () => {
|
||||
listUserSocial().then((res) => {
|
||||
socialList.value = res.data.map((el) => el.source)
|
||||
modeList.value = [
|
||||
{
|
||||
title: '绑定 Gitee',
|
||||
icon: 'gitee',
|
||||
subtitle: `${socialList.value.includes('GITEE') ? '' : '绑定后,'}可通过 Gitee 进行登录`,
|
||||
jumpMode: 'link',
|
||||
type: 'gitee',
|
||||
status: socialList.value.includes('GITEE')
|
||||
},
|
||||
{
|
||||
title: '绑定 GitHub',
|
||||
icon: 'github',
|
||||
subtitle: `${socialList.value.includes('GITHUB') ? '' : '绑定后,'}可通过 GitHub 进行登录`,
|
||||
type: 'github',
|
||||
jumpMode: 'link',
|
||||
status: socialList.value.includes('GITHUB')
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
// 绑定
|
||||
const onBinding = (type: string, status: boolean) => {
|
||||
@@ -79,10 +84,9 @@ const onBinding = (type: string, status: boolean) => {
|
||||
window.open(res.data.authorizeUrl, '_self')
|
||||
})
|
||||
} else {
|
||||
unbindSocialAccount(type).then((res) => {
|
||||
if (res.code === 200) {
|
||||
userStore.getInfo()
|
||||
}
|
||||
unbindSocialAccount(type).then(() => {
|
||||
initData()
|
||||
Message.success('解绑成功')
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -93,13 +97,6 @@ const onUpdate = (type: string) => {
|
||||
verifyModelRef.value?.open(type)
|
||||
}
|
||||
|
||||
// 初始化数据
|
||||
const initData = () => {
|
||||
listUserSocial().then((res) => {
|
||||
socialList.value = res.data.map((el) => el.source)
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
initData()
|
||||
})
|
||||
|
Reference in New Issue
Block a user