提交 f78a0066 编写于 作者: View Design's avatar View Design

sign

上级 80b20543
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
color="gray" color="gray"
size="md" size="md"
@click="handleGetSignUrl('gitcode')" @click="handleGetSignUrl('gitcode')"
disabled
> >
<img src="~/assets/svg/logo-gitcode.svg" /> <img src="~/assets/svg/logo-gitcode.svg" />
使用 GitCode 登录 使用 GitCode 登录
...@@ -25,6 +26,7 @@ ...@@ -25,6 +26,7 @@
label="使用 Google 登录" label="使用 Google 登录"
color="gray" color="gray"
size="md" size="md"
disabled
/> />
<UButton <UButton
block block
...@@ -32,6 +34,7 @@ ...@@ -32,6 +34,7 @@
label="使用 GitHub 登录" label="使用 GitHub 登录"
color="gray" color="gray"
size="md" size="md"
@click="handleGetSignUrl('github')"
/> />
<UDivider label="或" /> <UDivider label="或" />
<UInput <UInput
...@@ -58,9 +61,9 @@ function handleClose () { ...@@ -58,9 +61,9 @@ function handleClose () {
function handleSign () { function handleSign () {
emits('signIn') emits('signIn')
} }
async function handleGetSignUrl (type) { async function handleGetSignUrl (source) {
let url let url
if (type === 'gitcode') { if (source === 'github') {
const { data } = await useRequest('/v1/user/github/authorize_url') const { data } = await useRequest('/v1/user/github/authorize_url')
url = data.value.data.url url = data.value.data.url
} }
......
...@@ -23,7 +23,7 @@ const request = async (url, options = {}) => { ...@@ -23,7 +23,7 @@ const request = async (url, options = {}) => {
} }
} }
return await useFetch(fullUrl, config) return await useFetch(fullUrl, Object.assign(config, options))
} }
export default request export default request
...@@ -5,4 +5,17 @@ ...@@ -5,4 +5,17 @@
definePageMeta({ definePageMeta({
layout: 'empty' layout: 'empty'
}) })
const route = useRoute()
const state = reactive({
source: route.query.source || '',
code: route.query.code || ''
})
const { data } = await useRequest('/v1/user/github/login', {
query: { code: state.code },
server: false
})
console.log(data.value)
</script> </script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册