From 23e52ecd6eaca919d1b6c050eda5f20f545355ed Mon Sep 17 00:00:00 2001 From: pwh-pwh Date: Thu, 25 Jul 2024 21:37:39 +0800 Subject: [PATCH] /clear cmd impl --- frontend/src/components/Chat.vue | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frontend/src/components/Chat.vue b/frontend/src/components/Chat.vue index c068b72..ace28e0 100644 --- a/frontend/src/components/Chat.vue +++ b/frontend/src/components/Chat.vue @@ -12,11 +12,23 @@ const msgList = reactive([{content: 'hello', userType: 'user', id: '1 const inputMsg = ref('') const isShrink = ref(false) const doChat = () => { + if (!dispatchMsg(inputMsg.value)) { + return + } //生成id const id = Date.now().toString(16) msgList.push({content: inputMsg.value, userType: 'user', id: id}) inputMsg.value = '' } + +const dispatchMsg = (msg: string):boolean => { + if (msg === '/clear') { + msgList.length = 0 + return false + } + return true +} + const scrollPanelRef = ref() const scrollToBottom = () => { nextTick(() => {