import Vue from 'vue'

import VueRouter from 'vue-router'
import Cookies from 'js-cookie'
import App from './App'
import store from './store'
import router from './router'


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);
}

/**
 * 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.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)
})
