import Vue from 'vue'

import VueRouter from 'vue-router'
import Cookies from 'js-cookie'
import Element from 'element-ui'
import './assets/styles/element/element-variables.scss'
import '@/assets/styles/index.scss'
import '@/utils/browser_patch'
import App from './App'
import store from './store'
import router from './router'
import { parseTime,judgmentNetworkReturnAddress,accAdd,accSub,accDiv,accMul } from "@/utils/index";
import cal from '@/utils/calculation';
//全屏组件
import dataV from '@jiaminghi/data-view'
import './assets/icons'

// 引入echarts
import * as echarts from 'echarts'
import "echarts-gl";
Vue.prototype.$echarts = echarts


Vue.prototype.cal = cal
Vue.prototype.parseTime = parseTime
Vue.prototype.judgmentNetworkReturnAddress = judgmentNetworkReturnAddress
Vue.prototype.accAdd = accAdd
Vue.prototype.accSub = accSub
Vue.prototype.accDiv = accDiv
Vue.prototype.accMul = accMul
Vue.prototype.msgSuccess = function (msg) {
  this.$message({ showClose: true, message: msg, type: "success", offset:100 });
}

Vue.prototype.msgError = function (msg) {
  this.$message({ showClose: true, message: msg, type: "error", offset:100 });
}

Vue.prototype.msgInfo = function (msg) {
  this.$message.info(msg);
}

//全屏组件
Vue.use(dataV)

/**
 * 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! ! !
 */

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

Vue.config.productionTip = false

// 避免路由冗余导航
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const originalReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace(location) {
  return originalReplace.call(this, location).catch(err => err)
}
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
