// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'

import 'normalize.css'
import ElementUI from 'element-ui'
import elementUIVerify from 'element-ui-verify'

import ECharts from 'vue-echarts/components/ECharts.vue'
import 'echarts/lib/chart/bar'
import 'echarts/lib/chart/line'
import 'echarts/lib/chart/pie'
import 'echarts/lib/chart/heatmap'
import 'echarts/lib/component/tooltip'
import 'echarts/lib/component/polar'
import 'echarts/lib/component/geo'
import 'echarts/lib/component/legend'
import 'echarts/lib/component/legendScroll'
import 'echarts/lib/component/title'
import 'echarts/lib/component/visualMap'
import 'echarts/lib/component/dataset'

// import Viser from 'viser-vue'

import VueBus from 'vue-bus'

import '@/assets/css/index-new.css'
import '@/styles/index.scss'
import Tip from '@/components/Tip'
import VueIconFont from 'vue-icon-font'

import i18n from './lang'
import '@/assets/font/iconfont.css'
import '@/icons'
import '@/permission'
import './mock'

import { totalRowClassName } from '@/utils'
import App from './App'
import router from './router'
import * as filters from './filters' // global filters
import store from './store'
Vue.config.devtools = true

Vue.use(ElementUI, {
  size: 'mini'
})
Vue.use(elementUIVerify)
Vue.use(VueIconFont)
Vue.use(VueBus)

// Vue.use(Viser)
Vue.component('Tip', Tip)
Vue.component('v-chart', ECharts)

// register global utility filters.
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

Vue.mixin({
  data () {
    return {
      project: '',
      pageTitle: '线上分销系统'
    }
  },
  mounted () {
    this.project = (this.$route && this.$route.query.project) || localStorage.project || ''

    if (this.project) {
      const titleMap = {
        // cleartv: '徽黄科技'
        cleartv: ''
      }
      this.pageTitle = (titleMap[this.project] || '') + '线上分销系统'

      localStorage.project = this.project
    }
  },
  computed: {
    pagePermission () {
      return this.$route && this.$route.meta && this.$route.meta.permissionList ? this.$route.meta.permissionList : []
    }
  },
  methods: {
    totalRowClassName,
    checkPermission (type) {
      return this.pagePermission.indexOf(type) !== -1 || this.pagePermission.indexOf('all') !== -1
    }
  }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  i18n,
  components: { App },
  template: '<App/>'
})
