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 RenderSlider from '@/components/RenderSlider/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'
import RenderCropper from '@/components/RenderCropper/index.vue'
import BackButton from '@/components/BackButton/backButton.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
import * as echarts from 'echarts'

// 引入标题，提示框，直角坐标系，数据集，内置数据转换器组件，组件后缀都为 Component
import {
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent
} from 'echarts/components'
// 标签自动布局、全局过渡动画等特性
import { LabelLayout, UniversalTransition } from 'echarts/features'
// 引入 Canvas 渲染器，注意引入 CanvasRenderer 或者 SVGRenderer 是必须的一步
import { CanvasRenderer } from 'echarts/renderers'

// 注册必须的组件
echarts.use([
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent,
  // LineChart,
  LabelLayout,
  UniversalTransition,
  CanvasRenderer
])

Vue.prototype.$echarts = echarts
// set ElementUI lang to EN
Vue.use(ElementUI, { locale })
//二次封装的el-table
Vue.component('RTable', RenderTable)
Vue.component('BackButton', BackButton)
Vue.component('RCropper', RenderCropper)
Vue.component('RDialog', RenderDialog)
Vue.component('RSwiper', RenderSwiper)
Vue.component('RMinerU', RenderMinerU)
// 富文本编辑器
Vue.component('VEditor', VueEditor)
// 富文本编辑器 可视化代码
Vue.component('MEditor', MavonEditor)
Vue.component('RSlider', RenderSlider)
Vue.prototype.$messageBox = function(isOk, message, type, title) {
  this.$confirm(
    message ? message : '是否确认删除当前数据',
    title ? title : '提示',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: type ? type : 'error',
      confirmButtonClass: 'render-button',
      cancelButtonClass: 'render-button'
    }
  ).then(() => {
    isOk('ok')
  })
}

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