Commit a6b07f75 authored by 周远喜's avatar 周远喜

插件安装,log,error捕获

parent 92334c13
......@@ -26,6 +26,7 @@
<h1>总数:{{counter}}</h1>
<h2>admin,user{{this.$store.state.admin.user.counter}}</h2>
<Button @click="increment">+</Button>
<Button type="error" @click="log">log</Button>
</div>
</div>
</div>
......@@ -47,6 +48,13 @@ export default {
},methods: {
increment () {
this.$store.commit('increment')
},
log(){
this.$log.push("这是一个错误!")
this.$log.capsule('iView', 'Success', this);
if (process.env.NODE_ENV === 'development'){
alert(123)
}
}
}
}
......
......@@ -2,7 +2,10 @@ import Vue from 'vue'
import ViewUI from 'view-design'
import VueI18n from 'vue-i18n';
import Languages from '@/i18n/locale';
// import VueDND from 'awe-dnd'
// 插件
import util from '@/libs/util';
import VueDND from 'awe-dnd' //拖拽排序
// import iViewPro from '@/libs/iViewPro/iview-pro.min.js';
// import '@/libs/iViewPro/iview-pro.css';
import iViewPro from '../iview-pro/src/index.js';
......@@ -16,28 +19,69 @@ Vue.component("iLink", iLink)
//注入mock
require("../mock")
export default ({
app,
store
}) => {
Vue.use(VueI18n)
// Vue.use(VueDND)
app.i18n = new VueI18n({
locale: 'zh-CN',
messages: Languages
});
app.i18n.locale = "zh-CN"
Vue.use(ViewUI, {
// locale:'zh-CN',
i18n: (key, value) => app.i18n.t(key, value)
app,
store
}) => {
Vue.use(VueI18n)
Vue.use(VueDND)
app.i18n = new VueI18n({
locale: 'zh-CN',
messages: Languages
});
app.i18n.locale = "zh-CN"
Vue.use(ViewUI, {
// locale:'zh-CN',
i18n: (key, value) => app.i18n.t(key, value)
})
Vue.use(iViewPro);
Vue.prototype.$log = {
...util.log,
push(data) {
if (typeof data === 'string') {
// 如果传递来的数据是字符串
// 赋值给 message 字段
// 为了方便使用
// eg: this.$log.push('foo text')
store.dispatch('admin/log/push', {
message: data
});
} else if (typeof data === 'object') {
// 如果传递来的数据是对象
store.dispatch('admin/log/push', data);
}
}
}
Vue.config.errorHandler = function (error, instance, info) {
Vue.nextTick(() => {
// store 追加 log
store.dispatch('admin/log/push', {
message: `${info}: ${error.message}`,
type: 'error',
meta: {
error
// instance
}
});
// 只在开发模式下打印 log
if (process.env.NODE_ENV === 'development') {
util.log.capsule('iView Admin', 'ErrorHandler', 'error');
util.log.error('>>>>>> 错误信息 >>>>>>');
console.log(info);
util.log.error('>>>>>> Vue 实例 >>>>>>');
console.log(instance);
util.log.error('>>>>>> Error >>>>>>');
console.log(error)
}
})
Vue.use(iViewPro);
// Vue.directive('paste', {
// bind(el, binding, vnode) {
// el.addEventListener('paste', function (event) { //这里直接监听元素的粘贴事件
// binding.value(event)
// })
// }
// })
// console.warn("this:",app.i18n.locale,app)
}
\ No newline at end of file
}
// Vue.directive('paste', {
// bind(el, binding, vnode) {
// el.addEventListener('paste', function (event) { //这里直接监听元素的粘贴事件
// binding.value(event)
// })
// }
// })
// console.warn("this:",app.i18n.locale,app)
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment