App.vue 1.56 KB
<!--
 * @Date: 2025-03-20 19:53:12
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2025-03-21 15:28:49
 * @FilePath: /mlaj/src/App.vue
 * @Description: 文件描述
-->
<script setup>
import { RouterView } from "vue-router";
import { provideAuth } from "@/contexts/auth";
import { provideCart } from "@/contexts/cart";
// 会根据配置判断是否显示调试控件
// eslint-disable-next-line no-unused-vars
import vConsole from "@/utils/vconsole";
// 初始化WX环境
import wx from "weixin-js-sdk";
import { wxJsAPI } from "@/api/wx/config";
import { apiList } from "@/api/wx/jsApiList.js";
import { wxInfo, getUrlParams, stringifyQuery } from "@/utils/tools";

// 提供认证和购物车上下文
provideAuth();
provideCart();
</script>

<template>
  <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>
</template>

<style>
#app {
  width: 100%;
  min-height: 100vh;
}
</style>