feat: 消息列表的调整

This commit is contained in:
2025-07-27 18:01:38 +08:00
parent a796d06631
commit 48bc37701c
2 changed files with 13 additions and 15 deletions

View File

@@ -13,8 +13,8 @@
<!-- 消息列表可滚动区域 -->
<scroll-view
:scroll-top="scrollTop"
scroll-y
:scroll-into-view="lastMsgId"
:scroll-with-animation="true"
class="area-msg-list"
>
@@ -46,8 +46,6 @@
</template>
</view>
<!-- 底部锚点用于滚动到底部 -->
<view :id="lastMsgId" class="lastMsgId"></view>
</scroll-view>
<!-- 输入框区域 -->
@@ -106,8 +104,8 @@
const conversationId = ref('1931957498711957505')
const mainPageDataModel = ref({})
// 锚点ID(控制滚动位置)
const lastMsgId = ref('anchor-bottom');
//(控制滚动位置)
const scrollTop = ref(99999);
// 打开抽屉
@@ -138,12 +136,9 @@
}
const scrollToBottom = () => {
// 短暂指向最新消息的ID触发滚动
lastMsgId.value = `${chatMsgList.value[chatMsgList.value.length - 1].msgId}`;
// 等待DOM更新后切回底部锚点确保下次能继续滚动到底
nextTick(() => {
nextTick(() => {
lastMsgId.value = 'anchor-bottom';
scrollTop.value += 9999;
});
});
}
@@ -151,7 +146,9 @@
/// 发送普通消息
const handleReply = (text) => {
sendMessage(text)
scrollToBottom()
setTimeout(() => {
scrollToBottom()
}, 100)
};
/// 是发送指令
@@ -180,6 +177,7 @@
mainPageDataModel.value = res.data
agentId.value = res.data.agentId
initData()
scrollToBottom()
}
}