2025-07-09 00:34:00 +08:00

35 lines
975 B
Vue

<template>
<view class="container mx-auto min-h-screen bg-gray-100">
<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
if (!useUser.getLoginStatus()) {
uni.redirectTo({
url: '/pages/login'
})
}
})
</script>