import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css'
import VueClipboard from 'vue-clipboard2'

import ElementUI from 'element-ui'
import Element, { Table, TableColumn } from 'element-ui'

import VueI18n from 'vue-i18n'
import locale from 'element-ui/lib/locale'
import enLocale from './i18n/en'
import zhCNLocale from './i18n/zh-CN'
const TableProps = Element.Table.props
const TableColumnProps = Element.TableColumn.props
TableProps.border = { type: Boolean, default: true } // 边框
TableProps.align = { type: String, default: 'center' } // 居中
TableProps.stripe = { type: Boolean, default: false } // 斑马纹
TableColumnProps.showOverflowTooltip = { type: Boolean, default: true } // 文本溢出
TableColumnProps.sortable = { type: Boolean, default: true } // 置默认的排序列和排序顺序
Vue.use(Table)
Vue.use(TableColumn)
Vue.use(ElementUI, { locale })
// 数据字典
import dict from './components/Dict'
import FileSaver from 'file-saver'
import XLSX from 'xlsx'
// 权限指令
import checkPer from '@/utils/permission'
import permission from './components/Permission'
import './assets/styles/element-variables.scss'

// global css
import './assets/styles/index.scss'

import App from './App'
import store from './store'
import router from './router/routers'

import './assets/icons' // icon
import './router/index' // permission control
Vue.use(VueClipboard)
Vue.use(checkPer)
Vue.use(permission)
Vue.use(dict)

Vue.use(VueI18n)

const messages = {
  en: enLocale,
  'zh': zhCNLocale
}
const storedLanguage = localStorage.getItem('lang') || 'zh'
const i18n = new VueI18n({
  locale: storedLanguage, // 设置默认语言
  messages
})

Vue.use(Element, {
  size: Cookies.get('size') || 'small' // set element-ui default size
})

locale.i18n((key, value) => i18n.t(key, value))
Vue.use(ElementUI, { i18n: (key, value) => i18n.t(key, value) })

Vue.prototype.$fileSaver = FileSaver
Vue.prototype.$xlsx = XLSX
Vue.config.productionTip = false

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