<template>
  <view class="container mx-auto min-h-screen">
    <Loading v-if="auth.loading" />
    <NetworkError v-else-if="auth.hasError" />
    <view v-else>
      <slot></slot>
    </view>
  </view>
</template>

<script setup lang="ts">
import { useWeAppAuthStore } from '@/common'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { getCurrentInstance } from 'vue'
import Loading from './Loading.vue'
import NetworkError from './NetworkError.vue'
import useUser from '@/common/libraries/userUserLogin'
const auth = useWeAppAuthStore()

onLoad(async () => {
  console.log('cc-root-view onLoad 1', auth?.loading, auth?.hasError)
  await getCurrentInstance()?.appContext.config.globalProperties.$onLaunched
  console.log('cc-root-view onLoad 2')
})

onShow(async () => {
  await getCurrentInstance()?.appContext.config.globalProperties.$onLaunched
})
</script>
