Newer
Older
sensorHubPlusFront / src / main.ts
liyaguang 1 day ago 2 KB 设备配置
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import axios from 'axios'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import dayjs from 'dayjs'
import App from './App.vue'
import pinia from './store'
import router from './router'
import useSettingsStore from './store/modules/settings'
import request from '@/api/index'
// 自定义指令
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'
import buttonPerm from '@/utils/buttonPerm'
// 引入打印插件
if (useSettingsStore().app.iconifyOfflineUse) {
  downloadAndInstall()
}
const app = createApp(App)
axios.get('./config/config.json').then((result) => {
  console.log(result, 'result')
  window.localStorage.setItem('baseURL-lot-platform', result.data.baseUrl)
  request.defaults.baseURL = result.data.baseUrl // 设置默认请求网址
  app.config.globalProperties.config = result.data
  app.config.globalProperties.hasPerm = hasPermission
  app.config.globalProperties.buttonPerm = buttonPerm
  app.config.globalProperties.dayjs = dayjs
  // 支持下发配置的设备类型
  app.config.globalProperties.support = result.data.support
  // 支持配置参数-重传次数的设备类型
  app.config.globalProperties.retryTimes = result.data.retryTimes
  // 支持配置参数-最大尝试次数的设备类型
  app.config.globalProperties.attemptsMax = result.data.attemptsMax
  // 支持配置参数-采集间隔的设备类型
  app.config.globalProperties.collectInterval = result.data.collectInterval
  // 支持配置参数-上传周期的设备类型
  app.config.globalProperties.uploadPeriod = result.data.uploadPeriod
  // 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')
})