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 locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n
import App from './App'
import store from './store'
import router from './router'
import Filters from './filters'
import RenderTable from './components/RenderTable'
import RenderSwiper from './components/RenderSwiper'
import VueEditor from './components/VueEditor'
import MavonEditor from './components/MavonEditor'
import RenderMinerU from '@/components/RenderMinerU/index.vue'
import utils from '@/assets/js/common'
// 生成的数据交互api
import generatedFormat from '@/assets/js/generatedFormat'
import generatedComponents from './generatedComponents'
import RenderDialog from '@/components/RenderDialog/index.vue'
Vue.prototype.$generatedFormat = generatedFormat
Vue.prototype.$utils = utils
Vue.prototype.$generatedDictList = generatedFormat.formatList
// 注册过滤器
Object.keys(Filters).forEach(k => Vue.filter(k, Filters[k]))
for (let item in generatedComponents) {
  Vue.component(item, generatedComponents[item])
}
import '@/icons' // icon
import '@/assets/js/utils/permission' // permission control
// set ElementUI lang to EN
Vue.use(ElementUI, { locale })
//二次封装的el-table
Vue.component('RTable', RenderTable)
Vue.component('RDialog', RenderDialog)
Vue.component('RSwiper', RenderSwiper)
Vue.component('RMinerU', RenderMinerU)
// 富文本编辑器
Vue.component('VEditor', VueEditor)
// 富文本编辑器 可视化代码
Vue.component('MEditor', MavonEditor)
Vue.prototype.$messageBox = function(isOk, message, type, title) {
  this.$confirm(message ? message : '是否确认删除当前数据', title ? title : '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: type ? type : 'error'
  }).then(() => {
    isOk('ok')
  })
}

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