import 'babel-polyfill'
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' // 中文
import './assets/font/iconfont.css'
import '@/styles/element-variables.scss'
import moment from 'moment'
import echarts from 'echarts'
import './utils/rem'

import '@/styles/index.scss' // global css
// import { lazyAMapApiLoaderInstance } from 'vue-amap'
import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control
import util from '@/common/js/utils'
import * as utils from './utils/index'
import { parseTime } from '@/utils/index.js'

import hevueImgPreview from 'hevue-img-preview'
Vue.use(hevueImgPreview)

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 *
 */
// import { mockXHR } from '../mock'
// if (process.env.NODE_ENV === 'production') {
//   mockXHR()
// }
Vue.prototype.$echarts = echarts
Vue.prototype.$moment = moment
// set ElementUI lang to EN
Vue.use(ElementUI, { locale })
// 工具类
Vue.prototype.$util = util
Vue.prototype.$utils = utils
Vue.component('paper-swiper', () => import ('@/components/PaperSwiper'))
Vue.component('paper', () => import ('@/components/Paper'))
Vue.component('CommonTitle', () => import ('@/components/CommonTitle'))
Vue.component('IframePdf', () => import ('@/components/IframePdf/iframePdf'))
Vue.filter('datetime', function(value) {
  if (!value) return ''
  return parseTime(value, '{yyyy}-{mm}-{dd} {hh}:{ii}:{ss}')
})
Vue.config.productionTip = false

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

const confirm = Vue.prototype.$confirm
Vue.prototype.$confirm = function(message, title, options = {}) {
  return confirm(message, title, {
    type: 'info',
    ...options
  })
}
// 离开删除
window.onbeforeunload = function() {
  sessionStorage.removeItem('ssoToken')
}
