<template>
  <component :is="Component" v-if="Component" />
</template>

<script lang="ts" setup>
import { computed } from 'vue'
import { loaded, error, initialStore } from '@/store'
import { loadComponent, loadPack } from '@/utils'

loadPack(initialStore)

const Main = loadComponent(() => import('@/layout/main.vue'))
const Err = loadComponent(() => import('@/components/error/index.vue'))

const Component = computed(() => {
  if (loaded.value) {
    return error.value ? Err : Main
  }
})
</script>