diff --git a/src/views/deepNine.vue b/src/views/deepNine.vue index e7c8202..8cbf9bc 100644 --- a/src/views/deepNine.vue +++ b/src/views/deepNine.vue @@ -41,6 +41,10 @@ import logo2 from "@/assets/img/AIchat/开启无限财富.png"; import getCountAll from "../assets/img/homePage/get-count-all.png"; import voice from "../assets/img/homePage/tail/voice.png"; import voiceNoActive from "../assets/img/homePage/tail/voice-no-active.png"; + +import { useChatStore } from "../store/chat"; +const homepageChatStore = useChatStore(); + const chatStore = useDeepNineStore(); const audioStore = useDeepNineAudioStore(); const dataStore = useDataStore(); @@ -718,7 +722,7 @@ const createTypingEffect = (message, content, speed) => { } } if (message.end) { - chatStore.getUserCount(); + homepageChatStore.getUserCount(); chatStore.isLoading = false; console.log("打印完毕,接触输入框禁用状态"); chatStore.chatInput = false; @@ -1118,7 +1122,7 @@ watch( console.log(AIcontent, "AIcontent"); if (result.code == 406) { - AIcontent.value = `

尊敬的用户,目前您的token余额为0,系统将无法处理您的搜索请求,您可以补充token后再进行搜索。token兑换的入口在右上角“获取token次数”,点击即可操作哦~

`; + AIcontent.value = `

尊敬的用户您好,您当前的“深度九大模型专属Token”数量为0,无法进行股票查询,可联系客服团队进行充值,感谢您的理解与支持

`; } const aiMsg = { @@ -1316,7 +1320,7 @@ watch( audioQueue.value.length ); } - + // 添加第二个音频(link)到队列 if (audioPreloadStatus.two.url) { chatStore.messages[chatStore.inputUserIndex].audioArray.push( @@ -1515,7 +1519,10 @@ watch( audioPreloadStatus.three.url ); if (chatStore.currentUserIndex == chatStore.inputUserIndex) { - addToAudioQueue(audioPreloadStatus.three.url, "API2-第一个"); + addToAudioQueue( + audioPreloadStatus.three.url, + "API2-第一个" + ); } else { chatStore.messages[ chatStore.inputUserIndex @@ -1526,7 +1533,7 @@ watch( audioQueue.value.length ); } - + if (audioPreloadStatus.four.url) { chatStore.messages[chatStore.inputUserIndex].audioArray.push( audioPreloadStatus.four.url @@ -1557,23 +1564,25 @@ watch( "", 50 ); - const ac31 = result22.data.DXTSC; - const ac32 = result22.data.DXTSC2; - const ac33 = result22.data.ZJQSSC1; + const ac31 = `

【资金异动信号】

`; + const ac32 = result22.data.DXTSC; + const ac33 = result22.data.DXTSC2; + const ac34 = `

【资金趋势导航】

`; + const ac35 = result22.data.ZJQSSC1; const ac3 = `

${result23.data.DXTSC}

${result23.data.DXTSC2}

${result23.data.ZJQSSC1}

`; - const ac3Arr=[]; - if(ac31!=""){ - ac3Arr.push("") - ac3Arr.push(`

${ac31}

`); - } - if(ac32!=""){ - ac3Arr.push("") + const ac3Arr = []; + ac3Arr.push(ac31); + if (ac32 != "") { ac3Arr.push(`

${ac32}

`); } - if(ac33!=""){ - ac3Arr.push("") + if (ac33 != "") { + ac3Arr.push(""); ac3Arr.push(`

${ac33}

`); } + ac3Arr.push(ac34); + if (ac35 != "") { + ac3Arr.push(`

${ac35}

`); + } // 先推送初始消息 const aiMessage3 = reactive({ sender: "ai", @@ -1621,10 +1630,7 @@ watch( audioPreloadStatus.five.url ); if (chatStore.currentUserIndex == chatStore.inputUserIndex) { - addToAudioQueue( - audioPreloadStatus.five.url, - "API3-第一个" - ); + addToAudioQueue(audioPreloadStatus.five.url, "API3-第一个"); } else { chatStore.messages[ chatStore.inputUserIndex @@ -1760,7 +1766,7 @@ watch( } else { audioPreloadStatus.one.loaded = true; } - + if (result21?.data?.link) { await preloadAudio(result21.data.link.trim(), "two"); } else { @@ -1797,7 +1803,7 @@ watch( } else { audioPreloadStatus.three.loaded = true; } - + if (result22?.data?.link1) { await preloadAudio(result22.data.link1.trim(), "four"); } else { @@ -1868,15 +1874,9 @@ watch( console.error("请求失败:", e); chatStore.firstAPICall = false; hasValidData.value = false; // 请求失败时设置数据无效 - // chatStore.messages.pop(); - // chatStore.messages.push({ - // sender: "ai", - // content: "AI思考失败,请稍后再试... ", - // }); - // chatStore.setLoading(false); } finally { // chatStore.setLoading(false); - await chatStore.getUserCount(); + await homepageChatStore.getUserCount(); } } } @@ -2293,7 +2293,7 @@ function KlineCanvsEcharts(containerId) { formatter: `${item[1]}`, textStyle: { color: "green", - fontSize: window.innerWidth > 769 ? 12 : 9, + fontSize: window.innerWidth > 769 ? 18 : 15, textBorderColor: "#FFFFFF", textBorderWidth: 2, fontWeight: "bold", @@ -2317,7 +2317,7 @@ function KlineCanvsEcharts(containerId) { formatter: `${item[1]}`, textStyle: { color: "green", - fontSize: window.innerWidth > 769 ? 18 : 15, + fontSize: window.innerWidth > 769 ? 12 : 9, textBorderColor: "#FFFFFF", textBorderWidth: 2, fontWeight: "bold", @@ -3165,17 +3165,7 @@ watch( ); const scrollToTop = () => { - // 滚动到顶部锚点 - const topAnchor = document.getElementById("deepNine-top-anchor"); - if (topAnchor) { - topAnchor.scrollIntoView({ behavior: "smooth" }); - } else { - // 保留原有逻辑作为备用 - chatStore.dbqbScrollToTop = !chatStore.dbqbScrollToTop; - } - - // 通知父组件滚动到顶部 - emit('scrollToBottom'); + homepageChatStore.dbqbScrollToTop = !homepageChatStore.dbqbScrollToTop; }; // 添加渲染所有K线图的方法 diff --git a/src/views/homePage.vue b/src/views/homePage.vue index 8d4a4de..668e6dd 100644 --- a/src/views/homePage.vue +++ b/src/views/homePage.vue @@ -61,6 +61,7 @@ const historyRecordRef = ref(null); const { getQueryVariable, setActiveTabIndex, getUserInfo } = useDataStore(); const dataStore = useDataStore(); const chatStore = useChatStore(); +const deepNineStore = useDeepNineStore(); // 变量 // 音频管理 const emotionAudioStore = useEmotionAudioStore(); @@ -105,21 +106,24 @@ const isDropdownOpen = ref(false); // 模型选项数据 const modelOptions = [ - { - label: "夺宝奇兵大模型", - value: "AIchat", - image: "https://d31zlh4on95l9h.cloudfront.net/images/0389f08c458c20b715be7acebf7a8eb2.png" + { + label: "夺宝奇兵大模型", + value: "AIchat", + image: + "https://d31zlh4on95l9h.cloudfront.net/images/0389f08c458c20b715be7acebf7a8eb2.png", + }, + { + label: "AI情绪大模型", + value: "AiEmotion", + image: + "https://d31zlh4on95l9h.cloudfront.net/images/aed3597ea187c5af6c88d5a5c67fc9c1.png", }, - { - label: "AI情绪大模型", - value: "AiEmotion", - image: "https://d31zlh4on95l9h.cloudfront.net/images/aed3597ea187c5af6c88d5a5c67fc9c1.png" + { + label: "深度九大模型", + value: "deepNine", + image: + "https://d31zlh4on95l9h.cloudfront.net/images/35bf808538183be0062e4647570a9abd.png", }, - { - label: "深度九大模型", - value: "deepNine", - image: "https://d31zlh4on95l9h.cloudfront.net/images/35bf808538183be0062e4647570a9abd.png" - } ]; // 监听activeTab变化,同步到activeTabMobile @@ -136,31 +140,35 @@ const toggleDropdown = () => { const selectOption = (value) => { activeTabMobile.value = value; isDropdownOpen.value = false; - + const tabIndexMap = { - "AIchat": 0, - "AiEmotion": 1, - "deepNine": 2 + AIchat: 0, + AiEmotion: 1, + deepNine: 2, }; setActiveTab(value, tabIndexMap[value]); }; // 获取当前选中选项的标签 const getSelectedOptionLabel = () => { - const option = modelOptions.find(opt => opt.value === activeTabMobile.value); + const option = modelOptions.find( + (opt) => opt.value === activeTabMobile.value + ); return option ? option.label : "请选择模型"; }; // 获取当前选中选项的图片 const getSelectedOptionImage = () => { - const option = modelOptions.find(opt => opt.value === activeTabMobile.value); + const option = modelOptions.find( + (opt) => opt.value === activeTabMobile.value + ); return option ? option.image : ""; }; // 点击外部关闭下拉菜单 onMounted(() => { - document.addEventListener('click', (e) => { - const container = document.querySelector('.custom-select-container'); + document.addEventListener("click", (e) => { + const container = document.querySelector(".custom-select-container"); if (container && !container.contains(e.target) && isDropdownOpen.value) { isDropdownOpen.value = false; } @@ -170,9 +178,9 @@ onMounted(() => { // 手机端选择器变化处理(保留原函数以兼容其他地方可能的调用) const handleMobileTabChange = (value) => { const tabIndexMap = { - "AIchat": 0, - "AiEmotion": 1, - "deepNine": 2 + AIchat: 0, + AiEmotion: 1, + deepNine: 2, }; setActiveTab(value, tabIndexMap[value]); }; @@ -388,7 +396,6 @@ const sendMessage = async () => { // 获取深度九大模型的 store const deepNineStore = useDeepNineStore(); - // 添加消息到深度九大模型的 store 中 const messageContent = message.value; message.value = ""; // 清空输入框 @@ -582,21 +589,13 @@ const getCurrentScrollContainer = () => { }; const smoothScrollToBottom = async () => { - // console.log("调用滚动到底部的方法"); - // await nextTick(); const container = getCurrentScrollContainer(); - // console.log(container, 'container') - // console.log(isScrolling.value, 'isScrolling.value') if (!container) return; await nextTick(); // 确保在DOM更新后执行 if (!isScrolling.value) { container.scrollTop = container.scrollHeight - container.offsetHeight; - // container.scrollTop = container.scrollHeight; - // container.scrollTop = container.offsetHeight; - // container.scrollTop = container.scrollHeight + container.offsetHeight; - // console.log(container.scrollHeight, container.offsetHeight, container.scrollHeight - container.offsetHeight, container.scrollTop, "总长度", "可视长度", "位置") } }; @@ -805,7 +804,18 @@ watch( if (activeTab.value === "AIchat" || activeTab.value === "deepNine") { throttledSmoothScrollToBottom(); } - // setTimeout(throttledSmoothScrollToBottom, 100); + }, + { deep: false, immediate: true } +); + +watch( + () => deepNineStore.messages.length, + () => { + // console.log('messages变化了') + // 只有在AIchat页面时才执行自动滚动 + if (activeTab.value === "AIchat" || activeTab.value === "deepNine") { + throttledSmoothScrollToBottom(); + } }, { deep: false, immediate: true } ); @@ -846,8 +856,8 @@ watch( activeTab.value == "AIchat" ? 1 : activeTab.value == "AiEmotion" - ? 2 - : 3; + ? 2 + : 3; const result = historyRecordRef.value.getHistoryList({ model: model, token: localStorage.getItem("localToken"), @@ -870,8 +880,6 @@ watch( // 其他页面时停止AiEmotion页面的高度监听器 stopAiEmotionHeightObserver(); } - // AiEmotion页面不执行自动滚动,避免刷新后滚动到底部 - // setTimeout(throttledSmoothScrollToBottom, 100); }, { deep: true, immediate: true } ); @@ -1409,37 +1417,72 @@ onUnmounted(() => {