import Vue from 'vue'
import GlobalComponents from '@/components/GlobalComponents'
import { Alert, Button, Breadcrumb, Card, Col, Checkbox, DatePicker, Icon, Input,
  InputNumber, Form, ConfigProvider, Modal, Menu, Popconfirm, Select, Steps, Spin,
  Switch, Table, Tag, Tooltip, TimePicker, Row, Radio, Upload, message, TreeSelect, Tabs, Divider, Slider, Popover, FormModel, Badge, Descriptions, Rate } from 'ant-design-vue'
import { ColorPicker } from 'element-ui'
// import 'vue2-animate/dist/vue2-animate.min.css'
import Clipboard from 'v-clipboard'
import './styles/ant-theme.less'

import '@/assets/css/index.css'
import '@/styles/index.scss'
import '@/styles/theme.scss'
import '@/icons'

import 'moment/locale/zh-cn'

import App from './App.vue'
import router from '@/router'
import store from '@/store/index.js'

// 权限管理
import '@/permission'
// mock数据
// import '@/mock'
// import 'froala-editor/js/froala_editor.pkgd.min'
// import 'froala-editor/js/languages/zh_cn'

// import 'froala-editor/css/froala_editor.pkgd.min.css'
// import 'font-awesome/css/font-awesome.css'
// import 'froala-editor/css/froala_style.min.css'
// import '@/assets/css/green.css' // 修改编辑器默认主题

import * as filters from '@/filters'
// import VueFroala from 'vue-froala-wysiwyg'
import BASE_URL from '@/config/env'

import wysiwyg from '@/components/Editor'
import VueCropper from 'vue-cropper'

Vue.use(GlobalComponents)
Vue.use(VueCropper)
Vue.use(Clipboard)
Vue.use(wysiwyg, {
  image: {
    uploadURL: BASE_URL().uploadUrl,
    dropzoneOptions: {}
  }
})

Vue.config.productionTip = false

Vue.use(ColorPicker)

// Vue.use(VueFroala)
// Vue.use(Antd)
Vue.use(Alert)
Vue.use(Badge)
Vue.use(Button)
Vue.use(Breadcrumb)
Vue.use(Checkbox)
Vue.use(Card)
Vue.use(Col)
Vue.use(Descriptions)
Vue.use(Icon)
Vue.use(Input)
Vue.use(InputNumber)
Vue.use(Form)
Vue.use(FormModel)
Vue.use(ConfigProvider)
Vue.use(Modal)
Vue.use(Menu)
Vue.use(Popconfirm)
Vue.use(Steps)
Vue.use(Spin)
Vue.use(Select)
Vue.use(Switch)
Vue.use(TimePicker)
Vue.use(Table)
Vue.use(Tag)
Vue.use(Tooltip)
Vue.use(Row)
Vue.use(Radio)
Vue.use(Upload)
Vue.use(DatePicker)
Vue.use(TreeSelect)
Vue.use(Tabs)
Vue.use(Divider)
Vue.use(Slider)
Vue.use(Popover)
Vue.use(Rate)

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

Vue.prototype.$message = message
Vue.prototype.$confirm = Modal.confirm

Vue.mixin({
  data () {
    return {
      pageTitle: '自营销售系统',
      project: '',
      uploadUrl: BASE_URL().uploadUrl
    }
  },
  mounted () {
    this.project = this.$route && this.$route.query.project || localStorage.mgt_project || ''

    if (this.project) {
      const titleMap = {
        cleartv: '徽黄科技'
      }

      this.pageTitle = (titleMap[this.project] || '') + '自营销售系统'

      localStorage.mgt_project = this.project
    }
  }
})

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