快速打印log插件和记录log插件
Former-commit-id: c60fd22146486b9ae40a017f54eac22861d63cfe [formerly c60fd22146486b9ae40a017f54eac22861d63cfe [formerly c60fd22146486b9ae40a017f54eac22861d63cfe [formerly c60fd22146486b9ae40a017f54eac22861d63cfe [formerly b19f1dba3b8716c4ec0693a83882bf9f0c10ee3e [formerly 163a31502dcf1a0e10a73b65e29e7260d36afcc9]]]]] Former-commit-id: e5b3780565f7a1645b4fe207c41035513515ca0b Former-commit-id: ef544bb7604fc43b2b88c3890e4b3cc799df7845 Former-commit-id: 915e4dc616ce563853356e5839acd156fd4fd69f [formerly e920289a8782940d1b5c3f498afd483c364462a0] Former-commit-id: 0085d6c633ce61d78083afdfbff15a2a77d5db42 Former-commit-id: 1eea98ae975cb2f3d79a81eaf39e7b3865264f82 Former-commit-id: 1cf7126ab22e15afbf99c7bbb1e250e6dfcae5e9 Former-commit-id: a680edf65c0ce825cc494e085e9f0e90f2775127 Former-commit-id: c400c163f351492944c53fbd1a59e27c4bb25fa5
This commit is contained in:
@@ -17,6 +17,7 @@ import '@/assets/svg-icons'
|
||||
import '@/components'
|
||||
import '@/mock/register'
|
||||
import '@/plugin/axios'
|
||||
import pluginLog from '@/plugin/log'
|
||||
import pluginError from '@/plugin/error'
|
||||
import pluginImport from '@/plugin/import'
|
||||
import pluginExport from '@/plugin/export'
|
||||
@@ -30,6 +31,7 @@ import { frameInRoutes } from '@/router/routes'
|
||||
Vue.use(ElementUI)
|
||||
Vue.use(VCharts)
|
||||
Vue.use(contentmenu)
|
||||
Vue.use(pluginLog)
|
||||
Vue.use(pluginError)
|
||||
Vue.use(pluginImport)
|
||||
Vue.use(pluginExport)
|
||||
|
||||
@@ -50,6 +50,7 @@ export default {
|
||||
title: '日志',
|
||||
icon: 'bullseye',
|
||||
children: [
|
||||
{ path: `${pre}log/log`, title: '日志记录', icon: 'sticky-note-o' },
|
||||
{ path: `${pre}log/error`, title: '错误捕捉', icon: 'bug' }
|
||||
]
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<d2-container>
|
||||
<template slot="header">错误信息</template>
|
||||
<template slot="header">捕获错误信息</template>
|
||||
<p class="d2-mt-0">请打开浏览器控制台,然后点击下面的按钮</p>
|
||||
<el-button type="danger" @click="handleNewError">触发一个错误</el-button>
|
||||
</d2-container>
|
||||
|
||||
27
src/pages/demo/playground/log/log/index.vue
Normal file
27
src/pages/demo/playground/log/log/index.vue
Normal file
@@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<d2-container>
|
||||
<template slot="header">记录日志内容</template>
|
||||
<p class="d2-mt-0">在下方输入你要记录的日志,然后点击记录按钮</p>
|
||||
<el-input
|
||||
v-model="text"
|
||||
placeholder="日志内容"
|
||||
class="d2-mr-10"
|
||||
style="width: 200px;"/>
|
||||
<el-button type="primary" @click="handleAdd">记录</el-button>
|
||||
</d2-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
text: 'D2Admin log info'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleAdd () {
|
||||
this.$logAdd(this.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -6,17 +6,20 @@ export default {
|
||||
Vue.config.errorHandler = function (err, vm, info) {
|
||||
Vue.nextTick(() => {
|
||||
store.commit('d2adminLogAdd', {
|
||||
type: 'error',
|
||||
err,
|
||||
vm,
|
||||
info
|
||||
})
|
||||
util.log.capsule('D2Admin', 'ErrorHandler', 'danger')
|
||||
util.log.danger('>>>>>> 错误对象 >>>>>>')
|
||||
console.log(err)
|
||||
util.log.danger('>>>>>> 报错 Vue 实例 >>>>>>')
|
||||
console.log(vm)
|
||||
util.log.danger('>>>>>> 错误信息 >>>>>>')
|
||||
console.log(info)
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
util.log.capsule('D2Admin', 'ErrorHandler', 'danger')
|
||||
util.log.danger('>>>>>> 错误对象 >>>>>>')
|
||||
console.log(err)
|
||||
util.log.danger('>>>>>> 报错 Vue 实例 >>>>>>')
|
||||
console.log(vm)
|
||||
util.log.danger('>>>>>> 错误信息 >>>>>>')
|
||||
console.log(info)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
16
src/plugin/log/index.js
Normal file
16
src/plugin/log/index.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import store from '@/store'
|
||||
import util from '@/libs/util'
|
||||
|
||||
export default {
|
||||
install (Vue, options) {
|
||||
// 快速打印 log
|
||||
Vue.prototype.$log = util.log
|
||||
// 快速记录日志
|
||||
Vue.prototype.$logAdd = function (info) {
|
||||
store.commit('d2adminLogAdd', {
|
||||
type: 'log',
|
||||
info
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
51f901f963b0802a69efe93ef5d40b60bcd1a2fd
|
||||
ba57c1878d7069d1c0d9ccfdee2c9497d1303b12
|
||||
@@ -1 +1 @@
|
||||
1325e2be4603dde2cf094397e4fca98a542e4ba5
|
||||
d581b883c6d0533c0ae662760c8c665af3a5eec7
|
||||
Reference in New Issue
Block a user