diff --git a/src/plugin/log/index.js b/src/plugin/log/index.js index 2be75be1..182a1456 100644 --- a/src/plugin/log/index.js +++ b/src/plugin/log/index.js @@ -7,7 +7,18 @@ export default { Vue.prototype.$log = { ...util.log, push (data) { - store.dispatch('d2admin/log/add', data) + if (typeof data === 'string') { + // 如果传递来的数据是字符串 + // 赋值给 message 字段 + // 为了方便使用 + // eg: this.$log.push('foo text') + store.dispatch('d2admin/log/add', { + message: data + }) + } else if (typeof data === 'object') { + // 如果传递来的数据是对象 + store.dispatch('d2admin/log/add', data) + } } } } diff --git a/src/views/demo/playground/log/log/index.vue b/src/views/demo/playground/log/log/index.vue index 614e9f18..eee1a6c8 100644 --- a/src/views/demo/playground/log/log/index.vue +++ b/src/views/demo/playground/log/log/index.vue @@ -16,14 +16,12 @@ export default { data () { return { filename: __filename, - text: 'D2Admin log info' + text: 'some text' } }, methods: { handleAdd () { - this.$log.push({ - message: this.text - }) + this.$log.push(this.text) } } } diff --git a/src/views/system/log/index.vue b/src/views/system/log/index.vue index 24b1b727..2600ef21 100644 --- a/src/views/system/log/index.vue +++ b/src/views/system/log/index.vue @@ -7,7 +7,7 @@ :loading="uploading" @click="handleUpload"> - Upload + Upload {{list.length}} log data
@@ -16,9 +16,6 @@ {{log.message}}

-