|
|
@ -9,8 +9,10 @@ import { useAppBridge } from '../assets/js/useAppBridge.js' |
|
|
|
import { useDataStore } from '@/store/dataList.js' |
|
|
|
import { useChatStore } from '../store/chat' |
|
|
|
import { useAudioStore } from '../store/audio' |
|
|
|
import _ from "lodash"; |
|
|
|
// import { useUserStore } from "../store/userPessionCode.js"; |
|
|
|
const { getQueryVariable } = useDataStore() |
|
|
|
|
|
|
|
// 变量 |
|
|
|
// 音频管理 |
|
|
|
const audioStore = useAudioStore() |
|
|
@ -88,7 +90,7 @@ const message = ref(""); |
|
|
|
// 传输对象 |
|
|
|
const messages = ref([]); |
|
|
|
// 信息加载状态 |
|
|
|
const isLoading = ref(false); |
|
|
|
const isLoading = computed(() => { chatStore.isLoading }); |
|
|
|
|
|
|
|
// 添加用户消息 |
|
|
|
const updateMessage = (title) => { |
|
|
@ -100,7 +102,11 @@ const sendMessage = async () => { |
|
|
|
ensureAIchat(); |
|
|
|
|
|
|
|
if (!message.value) return; |
|
|
|
if (isLoading.value) return; |
|
|
|
if (chatStore.isLoading) return; |
|
|
|
console.log(chatStore.isLoading, 'isLoading.value1111'); |
|
|
|
chatStore.setLoading(true); |
|
|
|
|
|
|
|
console.log(chatStore.isLoading, 'isLoading.value2222'); |
|
|
|
|
|
|
|
// 发送消息时,设置 isLoading 为 true |
|
|
|
messages.value = [ |
|
|
@ -160,13 +166,14 @@ const smoothScrollToBottom = async () => { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const throttledSmoothScrollToBottom = _.throttle(smoothScrollToBottom, 500, { trailing: false }); |
|
|
|
|
|
|
|
const handleScroll = function () { |
|
|
|
const scrollContainer = tabContent.value |
|
|
|
const scrollTop = scrollContainer.scrollTop |
|
|
|
const scrollHeight = scrollContainer.scrollHeight |
|
|
|
const offsetHeight = scrollContainer.offsetHeight |
|
|
|
console.log(scrollTop, scrollHeight, offsetHeight, "scrollTop, scrollHeight, offsetHeight"); |
|
|
|
// console.log(scrollTop, scrollHeight, offsetHeight, "scrollTop, scrollHeight, offsetHeight"); |
|
|
|
if (scrollTop + offsetHeight < scrollHeight) { |
|
|
|
// 用户开始滚动并在最底部之上,取消保持在最底部的效果 |
|
|
|
isScrolling.value = true |
|
|
@ -174,14 +181,14 @@ const handleScroll = function () { |
|
|
|
// 用户停止滚动并滚动到最底部,开启保持到最底部的效果 |
|
|
|
isScrolling.value = false |
|
|
|
} |
|
|
|
console.log(isScrolling.value) |
|
|
|
// console.log(isScrolling.value) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
watch( |
|
|
|
() => chatStore.messages, |
|
|
|
() => { |
|
|
|
smoothScrollToBottom(); |
|
|
|
throttledSmoothScrollToBottom(); |
|
|
|
}, |
|
|
|
{ deep: true, immediate: true } |
|
|
|
); |
|
|
@ -190,7 +197,7 @@ watch( |
|
|
|
watch( |
|
|
|
activeTab, |
|
|
|
async (newVal) => { |
|
|
|
smoothScrollToBottom(); |
|
|
|
throttledSmoothScrollToBottom(); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -230,7 +237,7 @@ const fnGetToken = () => { |
|
|
|
onMounted(async () => { |
|
|
|
setHeight(document.getElementById("testId")); // 给父组件发送窗口高度 |
|
|
|
getUserCount(); |
|
|
|
smoothScrollToBottom(); |
|
|
|
throttledSmoothScrollToBottom(); |
|
|
|
// 监听滚动事件,判断用户滚动状态 |
|
|
|
tabContent.value.addEventListener('scroll', handleScroll) |
|
|
|
|
|
|
@ -288,7 +295,13 @@ onMounted(async () => { |
|
|
|
<img v-else src="src\assets\img\homePage\tail\voice-no-active.png" @click="toggleVoice" |
|
|
|
class="action-btn" /> |
|
|
|
</div> |
|
|
|
<img src="src\assets\img\homePage\tail\send.png" @click="sendMessage" class="action-btn send-btn" /> |
|
|
|
<img v-if="!chatStore.isLoading" src="src\assets\img\homePage\tail\send.png" @click="sendMessage" |
|
|
|
class="action-btn send-btn" /> |
|
|
|
<div v-else> |
|
|
|
<el-icon class="is-loading"> |
|
|
|
<Loading /> |
|
|
|
</el-icon> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 第二行输入框 --> |
|
|
|