import { createApp } from "vue";
import "./style.css";
import App from "./App.vue";

import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import zhCn from "element-plus/es/locale/lang/zh-cn";

import router from "./router";

import { createPinia } from "pinia";
import { useCounterStore } from "@/stores/index";

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

const addRouter = async () => {
  const store = useCounterStore();
  await store.ROLEAdd();
};
async function call() {
  const app = createApp(App);

  app.use(ElementPlus, {
    locale: zhCn,
  });

  app.component("SvgIcon", SvgIcon); // 全局注册SvgIcon组件

  app.use(createPinia());
  await addRouter();// 动态添加路由的时候刷新页面会重新调用，防止刷新页面空白
  app.use(router);

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