import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import axios from 'axios'
// import print from 'vue3-print-nb'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import App from './App.vue'
import pinia from './store'
import router from './router'
import request from '@/api/index'
// import useSettingsStore from './store/modules/settings'

// 自定义指令
import directive from '@/utils/directive'
// 加载 svg 图标
import 'virtual:svg-icons-register'
// 全局样式
import '@/assets/styles/globals.scss'
// 加载 iconify 图标（element plus）
import { downloadAndInstall } from '@/iconify-ep'
// import { hasPermission } from '@/utils/composables/permission'
// 引入打印插件
// if (useSettingsStore().app.iconifyOfflineUse) {
downloadAndInstall()
// }
axios.get(`./config/config.json?ts=${new Date().getTime()}`).then((res) => {
  // console.log(res.data, 'json文件')
  window.localStorage.setItem('IntegratedFront', res.data.baseUrl)
  window.localStorage.setItem('playerType', res.data.playerType)
  request.defaults.baseURL = res.data.baseUrl // 设置默认请求网址
  const app = createApp(App)
  // app.config.globalProperties.hasPerm = hasPermission
  // app.use(print)
  app.use(ElementPlus)
  app.use(pinia)
  app.use(router)
  for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }
  directive(app)
  app.mount('#app')
})

