import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import '@/styles/index.scss' // global css
import App from './App'
import store from './store'
import router from './router'
import '@/icons' // icon
import '@/permission' // permission control
import VideoPlayer from 'vue-video-player'
import 'video.js/dist/video-js.css'
import 'vue-video-player/src/custom-theme.css'

// 导入批量注册的组件
import plugins from './components'
import '@/utils/globalFunctions'

// 注册导入的插件
Vue.use(plugins)

Vue.use(ElementUI)
Vue.use(VideoPlayer)
Vue.config.productionTip = false


// 自定义指令，防止用户多次提交，点击一次后禁用，持续两秒
Vue.directive('preventReClick', {
  inserted(el, binding) {
    el.addEventListener('click', () => {
      if (!el.disabled) {
        el.disabled = true
        setTimeout(() => {
          el.disabled = false
        }, binding.value || 2000)
      }
    })
  }
});


new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
