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";

// 导入 SVG 图标样式和注册逻辑
import "virtual:svg-icons-register";
import SvgIcon from "@/components/SvgIcon.vue"; // 导入SvgIcon组件

import Viewer from "v-viewer";
import "viewerjs/dist/viewer.css";

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.use(Viewer, {
    Options: {
      inline: true,
      button: true, //右上角按钮
      navbar: true, //底部缩略图
      title: true, //当前图片标题
      toolbar: true, //底部工具栏
      tooltip: true, //显示缩放百分比
      movable: true, //是否可以移动
      zoomable: true, //是否可以缩放
      rotatable: true, //是否可旋转
      scalable: true, //是否可翻转
      transition: true, //使用 CSS3 过度
      fullscreen: true, //播放时是否全屏
      keyboard: true, //是否支持键盘
      url: "data-source",
    },
  });

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