66 lines
1.3 KiB
Vue
66 lines
1.3 KiB
Vue
<template>
|
|
<a-config-provider :locale="zhCN">
|
|
<div v-if="appStore.state.initialized" class="app-container">
|
|
<component :is="layout">
|
|
<router-view />
|
|
</component>
|
|
</div>
|
|
<div v-else class="app-loading">
|
|
<a-spin size="large" />
|
|
<p>正在初始化应用...</p>
|
|
</div>
|
|
</a-config-provider>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed, onMounted } from 'vue'
|
|
import { useRoute } from 'vue-router'
|
|
import { useAppStore } from '@/stores/app'
|
|
import MainLayout from '@/layouts/MainLayout.vue'
|
|
import zhCN from 'ant-design-vue/es/locale/zh_CN'
|
|
|
|
const route = useRoute()
|
|
const appStore = useAppStore()
|
|
|
|
// 根据路由元信息确定使用的布局
|
|
const layout = computed(() => {
|
|
const layoutName = route.meta?.layout || 'default'
|
|
|
|
if (layoutName === 'main') {
|
|
return MainLayout
|
|
}
|
|
|
|
// 默认布局(如登录页)
|
|
return 'div'
|
|
})
|
|
|
|
// 初始化应用
|
|
onMounted(async () => {
|
|
await appStore.initialize()
|
|
})
|
|
|
|
// 开发环境调试信息
|
|
if (import.meta.env.DEV) {
|
|
console.log('🎯 应用组件挂载完成')
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
#app {
|
|
min-height: 100vh;
|
|
background-color: #f5f5f5;
|
|
}
|
|
|
|
.app-loading {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
height: 100vh;
|
|
}
|
|
|
|
.app-loading p {
|
|
margin-top: 16px;
|
|
color: #666;
|
|
}
|
|
</style> |