import { createApp } from "vue";
import App from "./App.vue";
import 'amfe-flexible'
import router from "./router";
// import store from "./store";
import 'vant/lib/index.css';
import "./assets/less/index.less"; // 你的全局样式
import "./assets/h5-reset.css";

// 引入 i18n 和 加载函数
import i18n, { loadLanguageAsync } from './locales/index'

import {
  Button,
  Popup,
  Form,
  Field,
  NavBar,
  Picker,
  Icon,
  Toast
} from 'vant';

import api from "./utils/api.js";

const savedLang = localStorage.getItem('app-lang') || 'zh-CN';

// 等待语言包加载完成后再渲染
loadLanguageAsync(savedLang).then(() => {
  const app = createApp(App);

  app.use(Button).use(Popup).use(Form).use(Field).use(NavBar).use(Picker).use(Icon).use(Toast);
  // app.use(store);
  app.use(router);
  app.use(i18n);

  app.config.globalProperties.$api = api;

  app.mount("#app");
});