<script setup>
import { Loading } from '@element-plus/icons-vue'
import { user } from '~/store/index'

const router = useRouter()

const token = router.currentRoute.value?.query?.token
if (token)
  login()

async function login() {
  const { code, data } = await request({ baseURL: window.GLOBAL_CONFIG.uc, url: '/user/main/login', data: { token } })
  if (code === '1') {
    user.value = data
    router.replace('/home')
  }
}
</script>

<template>
  <div class="h-full flex items-center justify-center">
    <el-icon size="20">
      <Loading />
    </el-icon>
    微信授权中...
  </div>
</template>

<style>
</style>
