|
@@ -45,7 +45,8 @@
|
|
|
<img :src="assistantAvatar" alt="assistant">
|
|
|
</div>
|
|
|
<div class="content">
|
|
|
- <div class="typing">正在输入...</div>
|
|
|
+ <!-- <div class="typing">正在输入...</div> -->
|
|
|
+ <img class="loading-gif" src="@/assets/loading.gif" alt="loading">
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -184,8 +185,9 @@ const toggleKnowledge = (id) => {
|
|
|
const scrollToBottom = async () => {
|
|
|
await nextTick()
|
|
|
if (messagesRef.value) {
|
|
|
- console.log('messagesRef.value',messagesRef.value);
|
|
|
- messagesRef.value.scrollTop = messagesRef.value.scrollHeight
|
|
|
+ const scrollHeight = messagesRef.value.scrollHeight;
|
|
|
+ const extraSpace = 150; // 额外空间,确保内容不被输入框遮挡
|
|
|
+ messagesRef.value.scrollTop = scrollHeight + extraSpace;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -253,6 +255,9 @@ const simulateStreamResponse = async (question) => {
|
|
|
content: '',
|
|
|
time: new Date()
|
|
|
});
|
|
|
+
|
|
|
+ // 立即滚动到底部确保"正在输入"可见
|
|
|
+ await scrollToBottom();
|
|
|
|
|
|
const token = localStorage.getItem('token')
|
|
|
|
|
@@ -270,6 +275,13 @@ const simulateStreamResponse = async (question) => {
|
|
|
try {
|
|
|
const data = JSON.parse(event.data);
|
|
|
|
|
|
+ // 每次更新内容后都确保滚动到底部
|
|
|
+ if (data.data && data.data.answer) {
|
|
|
+ accumulatedText += data.data.answer;
|
|
|
+ messages.value[messageIndex].content = accumulatedText;
|
|
|
+ await scrollToBottom();
|
|
|
+ }
|
|
|
+
|
|
|
if (data.data === true) {
|
|
|
|
|
|
// 处理think标签
|
|
@@ -330,16 +342,6 @@ const simulateStreamResponse = async (question) => {
|
|
|
await scrollToBottom();
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- if (data.data && data.data.answer) {
|
|
|
- // console.log('data.data.answer',data.data.answer);
|
|
|
- // 累积接收到的文本
|
|
|
- accumulatedText += data.data.answer;
|
|
|
- // 临时显示文本
|
|
|
- messages.value[messageIndex].content = accumulatedText;
|
|
|
- await nextTick();
|
|
|
- await scrollToBottom();
|
|
|
- }
|
|
|
} catch (error) {
|
|
|
console.error('Parse error:', error);
|
|
|
}
|
|
@@ -625,7 +627,7 @@ onMounted(async () => {
|
|
|
transition: all 0.3s;
|
|
|
|
|
|
&.chat-active {
|
|
|
- padding-bottom: 100px;
|
|
|
+ padding-bottom: 150px;
|
|
|
}
|
|
|
|
|
|
.message {
|
|
@@ -664,6 +666,15 @@ onMounted(async () => {
|
|
|
.avatar{
|
|
|
margin-right: 10px;
|
|
|
}
|
|
|
+ .content{
|
|
|
+ .loading-gif{
|
|
|
+ position: relative;
|
|
|
+ top: 10px;
|
|
|
+ left: 10px;
|
|
|
+ width: 30px;
|
|
|
+ height: 30px;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
&.assistant .content .text {
|
|
|
// background: rgba(255, 255, 255, 0.9);
|
|
@@ -708,7 +719,7 @@ onMounted(async () => {
|
|
|
margin: 0 auto;
|
|
|
padding: 20px;
|
|
|
background: rgba(255, 255, 255, 0.9);
|
|
|
- box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
|
|
|
+ // box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
|
|
|
backdrop-filter: blur(10px);
|
|
|
border-radius: 20px;
|
|
|
min-width: 800px;
|
|
@@ -717,8 +728,9 @@ onMounted(async () => {
|
|
|
bottom: 0;
|
|
|
left: $sidebar-width;
|
|
|
right: 0;
|
|
|
- padding: 20px;
|
|
|
- box-shadow: none;
|
|
|
+ background: #fff;
|
|
|
+ z-index: 10; // 添加z-index确保在内容之上
|
|
|
+ // border-top: 1px solid #eee; // 可选:添加上边框
|
|
|
}
|
|
|
|
|
|
.input-container {
|