Commit e51873f6 by pangchong

feat: 消息置底

parent ad9e8127
...@@ -13,48 +13,42 @@ ...@@ -13,48 +13,42 @@
<a-col :span="12"> <a-col :span="12">
<div class="flex items-center p-1.5 leading-7"> <div class="flex items-center p-1.5 leading-7">
<global-icon :size="16" icon="user-group"></global-icon> <global-icon :size="16" icon="user-group"></global-icon>
<span class="text-xs ml-1 text-theme-text2">房间已有 {{ chatChannelState.currentChatters.length <span class="text-xs ml-1 text-theme-text2">房间已有 {{ chatChannelState.currentChatters.length }}</span>
}}</span>
</div> </div>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<div class="flex items-center p-1.5 leading-7"> <div class="flex items-center p-1.5 leading-7">
<global-icon :size="16" icon="mic"></global-icon> <global-icon :size="16" icon="mic"></global-icon>
<span class="text-xs ml-1 text-theme-text2">{{ <span class="text-xs ml-1 text-theme-text2">{{ webrtcStates.isMicroAttached ? '麦克风已开启' : '麦克风未开启' }}</span>
webrtcStates.isMicroAttached ? '麦克风已开启' : '麦克风未开启'
}}</span>
</div> </div>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<div class="flex items-center p-1.5 leading-7"> <div class="flex items-center p-1.5 leading-7">
<global-icon :size="16" icon="camera"></global-icon> <global-icon :size="16" icon="camera"></global-icon>
<span class="text-xs ml-1 text-theme-text2">{{ <span class="text-xs ml-1 text-theme-text2">{{ webrtcStates.isCameraAttached ? '摄像头已开启' : '摄像头未开启' }}</span>
webrtcStates.isCameraAttached ? '摄像头已开启' : '摄像头未开启'
}}</span>
</div> </div>
</a-col> </a-col>
</a-row> </a-row>
<div class="chat-list p-4 my-4 flex-auto overflow-y-auto mb-0"> <div class="chat-list p-4 my-4 flex-auto overflow-y-auto mb-0" ref="scrollContainer">
<chat-details v-for="q in mapChatMessageQueue" :key="q.record_id" :data="q.data" :is-self="q.isSelf" <chat-details v-for="q in mapChatMessageQueue" :key="q.record_id" :data="q.data" :is-self="q.isSelf" :type="q.type"></chat-details>
:type="q.type"></chat-details>
</div> </div>
<div class="px-4 py-2"> <div class="px-4 py-2">
<a-space size="medium"> <a-space size="medium">
<a-upload :custom-request="option => uploadMuFile(option, 'image')" :show-file-list="false" accept="image/*"> <a-upload :custom-request="(option) => uploadMuFile(option, 'image')" :show-file-list="false" accept="image/*">
<template #upload-button> <template #upload-button>
<div class="flex-center px-3 py-1 rounded cursor-pointer bg-fill-bg1"> <div class="flex-center px-3 py-1 rounded cursor-pointer bg-fill-bg1">
<global-icon :size="15" icon="image"></global-icon> <global-icon :size="15" icon="image"></global-icon>
</div> </div>
</template> </template>
</a-upload> </a-upload>
<a-upload :custom-request="option => uploadMuFile(option, 'file')" :show-file-list="false" accept=".pdf"> <a-upload :custom-request="(option) => uploadMuFile(option, 'file')" :show-file-list="false" accept=".pdf">
<template #upload-button> <template #upload-button>
<div class="flex-center px-3 py-1 rounded cursor-pointer bg-fill-bg1"> <div class="flex-center px-3 py-1 rounded cursor-pointer bg-fill-bg1">
<global-icon :size="15" icon="pdf"></global-icon> <global-icon :size="15" icon="pdf"></global-icon>
</div> </div>
</template> </template>
</a-upload> </a-upload>
<a-upload :custom-request="option => uploadMuFile(option, 'video')" :show-file-list="false" accept="video/*"> <a-upload :custom-request="(option) => uploadMuFile(option, 'video')" :show-file-list="false" accept="video/*">
<template #upload-button> <template #upload-button>
<div class="flex-center px-3 py-1 rounded cursor-pointer bg-fill-bg1"> <div class="flex-center px-3 py-1 rounded cursor-pointer bg-fill-bg1">
<global-icon :size="15" icon="video"></global-icon> <global-icon :size="15" icon="video"></global-icon>
...@@ -62,8 +56,7 @@ ...@@ -62,8 +56,7 @@
</template> </template>
</a-upload> </a-upload>
</a-space> </a-space>
<a-textarea v-model="textMessage" allow-clear class="h-16 mt-2" placeholder="请输入" <a-textarea v-model="textMessage" allow-clear class="h-16 mt-2" placeholder="请输入" @keydown.enter="sendMessageText" />
@keydown.enter="sendMessageText" />
</div> </div>
</div> </div>
</template> </template>
...@@ -124,12 +117,12 @@ const uploadMuFile = (option: any, type: string) => { ...@@ -124,12 +117,12 @@ const uploadMuFile = (option: any, type: string) => {
} }
}) })
.catch((error) => { .catch((error) => {
console.log('出现错误', error); console.log('出现错误', error)
onError(error) onError(error)
}) as any }) as any
} }
const mapChatMessageQueue = computed(function() { const mapChatMessageQueue = computed(function () {
return chatChannelState.value.messageQueue.map(function(a: any) { return chatChannelState.value.messageQueue.map(function (a: any) {
return { return {
isSelf: a.uid === userStates.value.currentUserId, isSelf: a.uid === userStates.value.currentUserId,
type: a.type, type: a.type,
...@@ -144,6 +137,21 @@ const mapChatMessageQueue = computed(function() { ...@@ -144,6 +137,21 @@ const mapChatMessageQueue = computed(function() {
} }
}) })
}) })
//消息置底
const scrollContainer = ref()
const scrollToBottom = () => {
if (scrollContainer.value) {
scrollContainer.value.scrollTop = scrollContainer.value?.scrollHeight
}
}
watch(
mapChatMessageQueue,
() => {
scrollToBottom()
},
{ deep: true }
)
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.chat-list { .chat-list {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment