Skip to content

Commit

Permalink
/clear cmd impl
Browse files Browse the repository at this point in the history
  • Loading branch information
pwh-pwh committed Jul 25, 2024
1 parent 2b36988 commit 23e52ec
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions frontend/src/components/Chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,23 @@ const msgList = reactive<Message[]>([{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(() => {
Expand Down

0 comments on commit 23e52ec

Please sign in to comment.