// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import 'babel-polyfill'
import './permission'// 路由守卫

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import vueBus from '@assets/js/utils/vueBus'
import { imageIsExist } from '@assets/js/utils/imgs'
Vue.prototype.$axios = axios
Vue.use(vueBus)

import i18n from './lang'// 国际化
import Element from './Element/init.js'
import '@assets/style/theme/index.css'
import '@assets/style/index.less'// 全局样式
import '@assets/style/fonts/index.css'// fonts
import VueApexCharts from 'vue-apexcharts'// apxechars 组件
import * as echarts from 'echarts'
import { Base64 } from 'js-base64'// Base64加密
import JSEncrypt from '@/assets/js/jsencrypt.js' // jsencrypt非对称加密
import Moment from 'moment'// 日期格式化
Vue.use(Element, {
  size: 'small',
  i18n: (key, value) => i18n.t(key, value)
})
Vue.component('apexchart', VueApexCharts)
Vue.prototype.$echarts = echarts
Vue.prototype.$Base64 = Base64
Vue.prototype.$Moment = Moment
Vue.prototype.$Encrypt = new JSEncrypt()
// jquery
// import $ from 'jquery'
// Vue.prototype.$ = $

// axios
// Vue.use(DynamicTable)
// Vue.component('DynamicTable', DynamicTable)
// 自定义指令
Vue.directive('real-img', async function(el, binding) {
  const imgURL = binding.value // 获取图片地址
  const defaultURL = el.getAttribute('default-img') // 获取默认图片地址
  if (imgURL) {
    const exist = await imageIsExist(imgURL)
    if (exist) {
      el.setAttribute('src', imgURL)
    } else {
      if (defaultURL) {
        el.setAttribute('src', defaultURL)
      }
    }
  }
})
import useMixin from './mixins/useMixin'// Mixin声明全局
import componentsUse from './components/componentsUse'// 组件声明全局
Vue.use(useMixin)
Vue.use(componentsUse)

Vue.config.productionTip = false// 阻止启动生产消息

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

