
import Vue from 'vue'
import Router from 'vue-router'
import Element from 'element-ui'
import App from '@/App'
import i18n from '@/i18n'
import store from '@/store'
import store_v3 from '@/store_v3'
import router from '@/router'
import '@/icons'
import '@/element-ui/theme/index.css'
import '@/assets/scss/aui.scss'
import http from '@/utils/request'
import service from '@/utils/service'
import service2 from '@/utils/service2'
import renRadioGroup from '@/components/ren-radio-group'
import renSelect from '@/components/ren-select'
import renProcessMultiple from '@/components/ren-process-multiple'
import renProcessStart from '@/components/ren-process-start'
import renProcessRunning from '@/components/ren-process-running'
import renProcessDetail from '@/components/ren-process-detail'
import renDeptTree from '@/components/ren-dept-tree'
import renOrgTree from '@/components/ren-org-tree'
import renGridTree from '@/components/ren-grid-tree'
import deptSchoolSelect from '@/components/dept-school-select'
import renRegionTree from '@/components/ren-region-tree'
import { hasPermission, getDictLabel } from '@/utils'
import cloneDeep from 'lodash/cloneDeep'
// import VideoPlayer from 'vue-video-player'
// import 'vue-video-player/src/custom-theme.css'
// import 'video.js/dist/video-js.css'
import { emitter } from '@/utils/emitter';

import plugins from './plugins' // plugins
Vue.use(plugins)

import directive from './directive' // directive
directive(Vue)

import { download } from '@/utils/request2'
import { useDict } from '@/utils/dict'
import { getConfigKey, updateConfigByKey } from "@/api/system/config";
import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi'
Vue.prototype.useDict = useDict
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.updateConfigByKey = updateConfigByKey
Vue.prototype.download = download
Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
Vue.prototype.handleTree = handleTree
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.emitter = emitter

// 导入富文本
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
// import './utils/rem'
import '@/assets/scss/font/font.css'
import '@/assets/iconfont/iconfont.css'
import '@/utils/flexible.js'
import '@/assets/scss/wms/index.scss' // global css

Vue.config.productionTip = false
Vue.config.silent = true
Vue.use(Element, {
  size: 'default',
  i18n: (key, value) => i18n.t(key, value)
})
Vue.use(renRadioGroup)
Vue.use(renSelect)
Vue.use(renDeptTree)
Vue.use(renOrgTree)
Vue.use(renGridTree)
Vue.use(renRegionTree)
Vue.use(renProcessMultiple)
Vue.use(renProcessStart)
Vue.use(renProcessRunning)
Vue.use(renProcessDetail)
Vue.use(deptSchoolSelect)
Vue.use(Router)
Vue.use(store_v3)

Vue.use(VueQuillEditor)
// 挂载全局
Vue.prototype.$http = http
Vue.prototype.$service = service
Vue.prototype.$service2 = service2
Vue.prototype.$hasPermission = hasPermission
Vue.prototype.$getDictLabel = getDictLabel

const originalPush = Router.prototype.push
const originalReplace = Router.prototype.replace
// push
Router.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}
// replace
Router.prototype.replace = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalReplace.call(this, location, onResolve, onReject)
  return originalReplace.call(this, location).catch(err => err)
}
// 保存整站vuex本地储存初始状态
window.SITE_CONFIG['storeState'] = cloneDeep(store.state)

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

export default vue
