From f0d9674ed2ec2c3824ad609cf78c025904c57b39 Mon Sep 17 00:00:00 2001 From: liyang <1711467488@qq.com> Date: Wed, 20 Mar 2019 16:57:14 +0800 Subject: [PATCH] this.$log.push(this.text) Former-commit-id: 68835d0d14a26c911493667952e8920533176cda [formerly 68835d0d14a26c911493667952e8920533176cda [formerly 68835d0d14a26c911493667952e8920533176cda [formerly 68835d0d14a26c911493667952e8920533176cda [formerly 36698e25123732c5ebcef3b1be4f6689a77fcc60 [formerly 0fdad5bcf43969f757bbcccb132a5876e84cba80]]]]] Former-commit-id: 75abf1504b7ee705faefdbc909e48853a31804c5 Former-commit-id: 09a29410819b4a8a9206bf8f25983ced57acc210 Former-commit-id: c9ff463b6dccc21297940c5a029880b59c073bab [formerly 9b13330a75ac199ef4d634668f3daddc23faea93] Former-commit-id: dc9f756459eb8a702f3a33729cbda50ec8a70085 Former-commit-id: 6085d6e77abf5efe9976a8414abec6524e621ac0 Former-commit-id: 2f1a97adf665f917721b92b3e8e8b7845d090e85 Former-commit-id: b739a8f5f768a0f5a864944b433f9ac6be47fe12 Former-commit-id: 139d6f73cc2c44d700276143280c56b7f34fef86 --- src/plugin/log/index.js | 13 ++++++++++++- src/views/demo/playground/log/log/index.vue | 6 ++---- src/views/system/log/index.vue | 5 +---- 3 files changed, 15 insertions(+), 9 deletions(-) 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}}

-