App.vue
1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!--
* @Date: 2025-03-20 19:53:12
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-03-20 20:06:10
* @FilePath: /vue-vite/src/App.vue
* @Description: 文件描述
-->
<script setup>
import { RouterView } from "vue-router";
import { provideAuth } from '@/contexts/auth';
import { provideCart } from '@/contexts/cart';
// 提供认证和购物车上下文
provideAuth();
provideCart();
</script>
<template>
<div>
<router-view>
<template v-slot="{ Component }">
<Suspense>
<template #default>
<div>
<component :is="Component" />
</div>
</template>
<template #fallback>
<div
class="flex items-center justify-center h-screen bg-gradient-to-br from-green-50 via-teal-50 to-blue-50"
>
<div class="bg-white/20 backdrop-blur-md rounded-xl p-6 shadow-lg">
<div
class="animate-spin rounded-full h-12 w-12 border-b-2 border-green-500 mx-auto"
></div>
<p class="mt-4 text-gray-700">加载中...</p>
</div>
</div>
</template>
</Suspense>
</template>
</router-view>
</div>
</template>
<style>
#app {
width: 100%;
min-height: 100vh;
}
</style>