<template>
  <div class="flex flex-col items-start gap-4 p-4">
    <div class="flex w-full justify-between">
      <ILogo/>
      <UButton
        color="gray"
        variant="ghost"
        leading-icon="i-heroicons-x-mark-20-solid"
        @click="handleClose"
      />
    </div>
    <div>登录以继续使用</div>
    <UButton
      block
      color="gray"
      size="md"
      @click="handleGetSignUrl('csdn')"
    >
      <img src="~/assets/svg/logo-csdn.svg">
      使用 CSDN 登录
    </UButton>
    <UButton
      block
      color="gray"
      size="md"
      @click="handleGetSignUrl('gitcode')"
    >
      <img src="~/assets/svg/logo-gitcode.svg">
      使用 GitCode 登录
    </UButton>
    <UButton
      block
      leading-icon="i-simple-icons-github"
      label="使用 GitHub 登录"
      color="gray"
      size="md"
      @click="handleGetSignUrl('github')"
    />
<!--    <UButton-->
<!--      block-->
<!--      leading-icon="i-simple-icons-google"-->
<!--      label="使用 Google 登录"-->
<!--      color="gray"-->
<!--      size="md"-->
<!--      disabled-->
<!--    />-->
    <!--        <UDivider label="或" />-->
    <!--        <UInput-->
    <!--            class="w-full"-->
    <!--            v-model="email"-->
    <!--            placeholder="输入邮箱地址..."-->
    <!--            size="md"-->
    <!--        />-->
    <!--        <UButton-->
    <!--            block-->
    <!--            leading-icon="i-heroicons-envelope-20-solid"-->
    <!--            label="邮箱登录"-->
    <!--            size="md"-->
    <!--            @click="handleSign"-->
    <!--        />-->
  </div>
</template>
<script setup>
const emits = defineEmits([ 'close', 'signIn' ])
// const email = ref('')
function handleClose () {
  emits('close')
}
// function handleSign () {
//   emits('signIn')
// }
async function handleGetSignUrl (source) {
  let url
  if (source === 'github') {
    const { data } = await useRequest('/v1/user/github/authorize_url')
    url = data.value.data.url
  } else if (source === 'gitcode') {
    const { data } = await useRequest('/v1/user/gitcode/authorize_url')
    url = data.value.data.url
  } else if (source === 'csdn') {

  }
  window.location.href = url
}
</script>
