From 1cbaed41270a0b7240fa5a2ba6f35e5f0d63f790 Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 12 Jun 2019 19:20:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=85=8D=E7=BD=AE=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/Room/TextMessage.vue | 35 +++++++- frontend/src/views/Room/index.vue | 109 ++++++++++++++++++------ main.py | 2 +- views/chat.py | 25 +++++- 4 files changed, 138 insertions(+), 33 deletions(-) diff --git a/frontend/src/views/Room/TextMessage.vue b/frontend/src/views/Room/TextMessage.vue index cd5669e..33060d4 100644 --- a/frontend/src/views/Room/TextMessage.vue +++ b/frontend/src/views/Room/TextMessage.vue @@ -5,6 +5,9 @@ {{time}} {{authorName}} {{content}} + @@ -16,6 +19,8 @@ const AUTHOR_TYPE_TO_TEXT = [ 'moderator', // 房管 'owner' // 主播 ] +const REPEATED_MARK_COLOR_START = [0x21, 0x96, 0xF3] +const REPEATED_MARK_COLOR_END = [0xFF, 0x57, 0x22] export default { name: 'TextMessage', @@ -24,12 +29,40 @@ export default { time: String, authorName: String, authorType: Number, - content: String + content: String, + repeated: Number }, computed: { authorTypeText() { return AUTHOR_TYPE_TO_TEXT[this.authorType] + }, + repeatedMarkColor() { + let color + if (this.repeated <= 2) { + color = REPEATED_MARK_COLOR_START + } else if (this.repeated >= 10) { + color = REPEATED_MARK_COLOR_END + } else { + color = [0, 0, 0] + let t = (this.repeated - 2) / (10 - 2) + for (let i = 0; i < 3; i++) { + color[i] = REPEATED_MARK_COLOR_START[i] + (REPEATED_MARK_COLOR_END[i] - REPEATED_MARK_COLOR_START[i]) * t + } + } + return `rgb(${color.join(', ')})` } } } + + diff --git a/frontend/src/views/Room/index.vue b/frontend/src/views/Room/index.vue index 64cf2a2..ec5f68e 100644 --- a/frontend/src/views/Room/index.vue +++ b/frontend/src/views/Room/index.vue @@ -18,7 +18,7 @@