import Vue from 'vue'
import axios from './router/axios'
import VueAxios from 'vue-axios'
import App from './App'
import router from './router/router'
import './permission' // 权限
import './error' // 日志
import './cache' // 页面缓冲
import store from './store'
import { loadStyle } from './util/util'
import * as urls from '@/config/env'
import Element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import AVUE from '@smallwei/avue'
import '@smallwei/avue/lib/index.css'
import { iconfontUrl, iconfontVersion } from '@/config/env'
import i18n from './lang' // Internationalization
import './styles/common.scss'
import Viewer from 'v-viewer'
import './assets/iconfont/iconfont.css' // 淘宝图标

import basicBlock from './components/basic-block/main'
import basicContainer from './components/basic-container/main'
import dayjs from 'dayjs'
import website from '@/const/website.js'

import './plugins/v-charts' // 按需引入v-charts图表
import './plugins/v-viewer' // 图片预览
import './plugins/video-player' // 视频播放
import './plugins/echarts' // echarts图表
Element.Dialog.props.closeOnClickModal.default = false // 全局关闭点遮罩关闭弹框
Vue.prototype.appUrl = process.env.VUE_APP_PATH // 请求ip

Vue.prototype.$dayjs = dayjs
Vue.prototype.website = website
Vue.config.productionTip = false
Vue.use(VueAxios, axios)
Vue.use(Viewer, {
  defaultOptions: {
    zIndex: 99999
  }
})
Vue.use(Element, {
  i18n: (key, value) => i18n.t(key, value),
  size: 'small',
  zIndex: 1000
})
Vue.use(AVUE, {
  // i18n: (key, value) => i18n.t(key, value),
  size: 'small',
  menuType: 'text'
})
// 注册全局容器
Vue.component('basicContainer', basicContainer)
Vue.component('basicBlock', basicBlock)
// 加载相关url地址
Object.keys(urls).forEach((key) => {
  Vue.prototype[key] = urls[key]
})
// 动态加载阿里云字体库
iconfontVersion.forEach((ele) => {
  loadStyle(iconfontUrl.replace('$key', ele))
})

// 全局赋值
new Vue({
  router,
  store,
  i18n,
  render: (h) => h(App)
}).$mount('#app')
