<template>
  <div class="boot">
    <el-button :loading="loading" v-if="loading">正在烧烤...</el-button>
    <el-button @click="initService" v-else>重新烧烤</el-button>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import { useRoute, useRouter } from 'vue-router'
import { initBaseData } from '@/business/common'

const route = useRoute(),
  router = useRouter(),
  loading = ref(false);

const initService = () => {
  loading.value = true;
  initBaseData(() => {
    const redirect = route.query.redirect;
    if (redirect) {
      router.replace(redirect.toString());
    } else {
      router.replace('/');
    }
  }).catch((err) => {
    ElMessage.error(err);
    loading.value = false;
  })
}

initService()
</script>

<style lang="less" scoped>
@import './index.less';
</style>