2017-08-21 07:55:46 +00:00
|
|
|
import Vue from 'vue'
|
2017-12-13 05:52:14 +00:00
|
|
|
import store from './store'
|
2017-08-21 07:55:46 +00:00
|
|
|
|
2017-12-12 10:14:31 +00:00
|
|
|
// you can set only in production env show the error-log
|
2018-08-29 03:12:15 +00:00
|
|
|
if (process.env.NODE_ENV === 'production') {
|
|
|
|
Vue.config.errorHandler = function(err, vm, info, a) {
|
2017-12-29 08:07:42 +00:00
|
|
|
// Don't ask me why I use Vue.nextTick, it just a hack.
|
|
|
|
// detail see https://forum.vuejs.org/t/dispatch-in-vue-config-errorhandler-has-some-problem/23500
|
2018-08-29 03:12:15 +00:00
|
|
|
Vue.nextTick(() => {
|
|
|
|
store.dispatch('addErrorLog', {
|
|
|
|
err,
|
|
|
|
vm,
|
|
|
|
info,
|
|
|
|
url: window.location.href
|
|
|
|
})
|
|
|
|
console.error(err, info)
|
2017-12-13 05:52:14 +00:00
|
|
|
})
|
2018-08-29 03:12:15 +00:00
|
|
|
}
|
2017-08-21 07:55:46 +00:00
|
|
|
}
|