mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-07 01:46:42 +08:00
feat(ai-call):优化AI对话组件初始化逻辑
- 添加组件准备就绪状态标识 - 确保组件挂载完成后再执行自动滚动 -重置对话时正确处理组件状态 - 避免未初始化完成时的滚动操作
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<div id="app" style="width: 100vw">
|
||||
<keep-alive :include="['case']">
|
||||
<router-view />
|
||||
12312
|
||||
|
||||
@@ -484,9 +484,17 @@ export default {
|
||||
}
|
||||
],
|
||||
suggestions:[],
|
||||
isAutoScroll: true // 是否自动滚动
|
||||
isAutoScroll: true, // 是否自动滚动
|
||||
// 添加一个标志位,用于标识组件是否已经初始化完成
|
||||
isComponentReady: false
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 组件挂载完成后,标记为已准备就绪
|
||||
this.$nextTick(() => {
|
||||
this.isComponentReady = true;
|
||||
});
|
||||
},
|
||||
watch: {
|
||||
dialogVisible: {
|
||||
handler(newVal) {
|
||||
@@ -533,9 +541,12 @@ export default {
|
||||
},
|
||||
messageList: {
|
||||
handler() {
|
||||
this.$nextTick(() => {
|
||||
this.scrollToBottom();
|
||||
});
|
||||
// 只有在组件准备就绪后才执行滚动操作
|
||||
if (this.isComponentReady) {
|
||||
this.$nextTick(() => {
|
||||
this.scrollToBottom();
|
||||
});
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
@@ -605,6 +616,9 @@ closeMinimizedWindow() {
|
||||
},500)
|
||||
},
|
||||
startNewConversation() {
|
||||
// 重置对话时,先标记组件为未准备就绪状态
|
||||
this.isComponentReady = false;
|
||||
|
||||
this.messageList = [
|
||||
{
|
||||
isBot: true,
|
||||
@@ -616,6 +630,11 @@ closeMinimizedWindow() {
|
||||
];
|
||||
this.AIContent = '';
|
||||
this.isLoading = false;
|
||||
|
||||
// 在下一个 tick 中重新标记为准备就绪
|
||||
this.$nextTick(() => {
|
||||
this.isComponentReady = true;
|
||||
});
|
||||
},
|
||||
|
||||
// 处理滚动事件
|
||||
|
||||
Reference in New Issue
Block a user