import App from "./App.vue";

import { setupStore } from "@/stores";
// ui
import Vant, { Lazyload } from "vant";
import "vant/lib/index.css";
//

// 字体
import "@/assets/font/font.css";
import { i18n } from "@/i18n/index.js";

// 引入组件
import "virtual:svg-icons-register";
import SvgIcon from "@/components/Svg-icon/SvgIcon.vue";

// windows 挂载 & 注入
import { initCapacitor } from "./plugins";
import { setup } from "./plugins/storage";

import { SafeArea } from "capacitor-plugin-safe-area";

import VConsole from "vconsole";

// if (process.env.NODE_ENV === "development") {
//   // 引入 vconsole
//   new VConsole();
// }
new VConsole();

async function appInit() {
  const app = createApp(App);
  await setupStore(app);
  // 注入组件
  app.component("SvgIcon", SvgIcon);
  // 挂载状态管理
  // UI
  app.use(Vant);
  app.use(Lazyload);
  app.use(i18n);
  // windows 挂载
  setup();

  // setupPlugin(app)
  initCapacitor(app);
  app.mount("#app", true);
}

appInit().then(async () => {
  const { insets } = await SafeArea.getSafeAreaInsets();
  console.log("底部安全区域:", insets); // 直接获取底部间距
  document.documentElement.style.setProperty(
    "--safe-area-bottom",
    `${insets.bottom}px`
  );
});
