// ie polyfill
import '@babel/polyfill'
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store/'
import { VueAxios } from './utils/request'
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'

// mock
// import './mock'

import bootstrap from './core/bootstrap'
import './core/use'
import './permission' // permission control
import './utils/filter'

import VueCookies from 'vue-cookies'
import VideoPlayer from 'vue-video-player'
Vue.use(Viewer)
Viewer.setDefaults({
  Options: { 'inline': true, 'button': true, 'navbar': true, 'title': true, 'toolbar': true, 'tooltip': true, 'movable': true, 'zoomable': true, 'rotatable': true, 'scalable': true, 'transition': true, 'fullscreen': true, 'keyboard': true, 'url': 'data-source' }
}) // global filter

Vue.config.productionTip = false

// mount axios Vue.$http and this.$http
Vue.use(VueAxios)
Vue.use(VueCookies)
Vue.$cookies.config('7d')

// 视频播放插件
require('video.js/dist/video-js.css')
require('vue-video-player/src/custom-theme.css')
Vue.use(VideoPlayer)

//引入vuescroll自定义滚动条
import vuescroll from "vuescroll"
import "vuescroll/dist/vuescroll.css"
Vue.use(vuescroll)

/**
 * 权限检查
 */
Vue.prototype.$hasPermissions = function (value) {
  let isExist = false
  const roles = store.getters.roles
  const permissionList = roles.permissionList
  // console.log(permissionsStr,'permissionsStr')
  if (permissionList == undefined || permissionList == null) {
    return false
  }
  const has = permissionList.find(item => {
    return item == value
  })
  if (has) {
    isExist = true
  }
  return isExist
}

// 禁止输入框输入空格，换行符，<，>
Vue.prototype.$filterEmpty = function (e) {
  return e.target.value.replace(/\s|\r\n|\n|<|>/g, '')
}
new Vue({
  router,
  store,
  created: bootstrap,
  render: h => h(App)
}).$mount('#app')
