From 5b0c0353e2e40cfed232717a6418113a6b5cb27e Mon Sep 17 00:00:00 2001 From: no99 <17663930442@163.com> Date: Tue, 19 Aug 2025 10:02:45 +0800 Subject: [PATCH] =?UTF-8?q?chat=E9=A1=B5=E9=9D=A2data=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E7=8E=AF=E5=A2=83=E5=88=A4=E6=96=AD=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E3=80=82=20=E6=A0=B9=E6=8D=AEurl=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E4=B8=8A=E7=9A=84=E5=8F=82=E6=95=B0=E5=88=A4=E6=96=AD=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=85=85=E5=80=BC=E5=9B=9E=E5=BD=92=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E4=B8=94=E5=B1=95=E7=A4=BA=E5=BC=B9=E7=AA=97=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=BC=93=E5=AD=98rechargeFlag=E6=9D=A5=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E6=98=AF=E5=90=A6=E5=B1=95=E7=A4=BA=E8=BF=87=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/AIchat.vue | 5 +-- src/views/homePage.vue | 90 +++++++++++++++++++++++++++++--------------------- 2 files changed, 56 insertions(+), 39 deletions(-) diff --git a/src/views/AIchat.vue b/src/views/AIchat.vue index 3da2f90..bb809e3 100644 --- a/src/views/AIchat.vue +++ b/src/views/AIchat.vue @@ -1261,8 +1261,9 @@ watch( const env = import.meta.env.VITE_ENV; const result20 = await dataListAPI({ token: - // "8Csj5VVX1UbIb4C3oxrnbZi0+fEeMx8pywnIlrmTm45Cb/EllzWACLto9J9+fCFsfdgBOvKvyY94FvqlvM0", - "8nkj4QBV1RPIb4CzoRTnbZi0+fEeMx8pywnIlrmTxdwROKkuwWqAWu9orpkpeXVqL98DPfeonNYpHv+mucA", + env == "development" || env == "test" + ? "8Csj5VVX1UbIb4C3oxrnbZi0+fEeMx8pywnIlrmTm45Cb/EllzWACLto9J9+fCFsfdgBOvKvyY94FvqlvM0" + : "8nkj4QBV1RPIb4CzoRTnbZi0+fEeMx8pywnIlrmTxdwROKkuwWqAWu9orpkpeXVqL98DPfeonNYpHv+mucA", market: codeData.value.market, code: codeData.value.code, language: "cn", //t.value.suoxie, diff --git a/src/views/homePage.vue b/src/views/homePage.vue index 3b8e560..235ae4e 100644 --- a/src/views/homePage.vue +++ b/src/views/homePage.vue @@ -373,9 +373,9 @@ const aiEmotionScrollTimer = ref(null); // 滚动检测定时器 // 获取当前活动页面的滚动容器 const getCurrentScrollContainer = () => { - if (activeTab.value === 'AIchat') { + if (activeTab.value === "AIchat") { return tabContentAIchat.value; - } else if (activeTab.value === 'AiEmotion') { + } else if (activeTab.value === "AiEmotion") { return tabContentAiEmotion.value; } return null; @@ -406,7 +406,11 @@ const throttledSmoothScrollToBottom = _.throttle(smoothScrollToBottom, 300, { // AiEmotion页面自动滚动到底部的防抖函数 const debouncedAiEmotionScrollToBottom = _.debounce(() => { - if (activeTab.value === 'AiEmotion' && isAiEmotionAutoScrollEnabled.value && !isAiEmotionUserScrolling.value) { + if ( + activeTab.value === "AiEmotion" && + isAiEmotionAutoScrollEnabled.value && + !isAiEmotionUserScrolling.value + ) { const container = tabContentAiEmotion.value; if (container) { container.scrollTop = container.scrollHeight - container.offsetHeight; @@ -418,21 +422,21 @@ const debouncedAiEmotionScrollToBottom = _.debounce(() => { const startAiEmotionHeightObserver = () => { // 先停止之前的监听器 stopAiEmotionHeightObserver(); - + isAiEmotionAutoScrollEnabled.value = true; - + // 创建ResizeObserver监听页面内容变化 aiEmotionHeightObserver.value = new ResizeObserver((entries) => { - if (isAiEmotionAutoScrollEnabled.value && activeTab.value === 'AiEmotion') { + if (isAiEmotionAutoScrollEnabled.value && activeTab.value === "AiEmotion") { debouncedAiEmotionScrollToBottom(); } }); - + // 监听document.body的尺寸变化 if (document.body) { aiEmotionHeightObserver.value.observe(document.body); } - + // 创建MutationObserver监听DOM结构变化 const mutationObserver = new MutationObserver((mutations) => { let shouldScroll = false; @@ -453,12 +457,16 @@ const startAiEmotionHeightObserver = () => { } } }); - - if (shouldScroll && isAiEmotionAutoScrollEnabled.value && activeTab.value === 'AiEmotion') { + + if ( + shouldScroll && + isAiEmotionAutoScrollEnabled.value && + activeTab.value === "AiEmotion" + ) { debouncedAiEmotionScrollToBottom(); } }); - + // 监听AiEmotion页面的主要内容区域的DOM变化 const aiEmotionContainer = tabContentAiEmotion.value; if (aiEmotionContainer) { @@ -469,17 +477,19 @@ const startAiEmotionHeightObserver = () => { characterData: true, }); } - + // 保存mutationObserver引用以便清理 aiEmotionHeightObserver.value.mutationObserver = mutationObserver; - + // 为AiEmotion页面的滚动容器添加滚动事件监听器 if (aiEmotionContainer) { - aiEmotionContainer.addEventListener('scroll', handleAiEmotionUserScroll, { passive: true }); + aiEmotionContainer.addEventListener("scroll", handleAiEmotionUserScroll, { + passive: true, + }); // 保存滚动事件监听器引用以便清理 aiEmotionHeightObserver.value.scrollListener = handleAiEmotionUserScroll; } - + console.log("AiEmotion页面高度监听器已启动"); }; @@ -487,12 +497,12 @@ const startAiEmotionHeightObserver = () => { const handleAiEmotionUserScroll = () => { // 标记用户正在滚动 isAiEmotionUserScrolling.value = true; - + // 清除之前的定时器 if (aiEmotionScrollTimer.value) { clearTimeout(aiEmotionScrollTimer.value); } - + // 设置定时器,2秒后恢复自动滚动 // aiEmotionScrollTimer.value = setTimeout(() => { // isAiEmotionUserScrolling.value = false; @@ -502,7 +512,7 @@ const handleAiEmotionUserScroll = () => { // 处理AiEmotion页面的滚动请求 const handleAiEmotionScrollToBottom = () => { - if (activeTab.value === 'AiEmotion') { + if (activeTab.value === "AiEmotion") { const container = tabContentAiEmotion.value; if (container) { // 使用nextTick确保DOM已更新 @@ -518,32 +528,38 @@ const handleAiEmotionScrollToBottom = () => { const stopAiEmotionHeightObserver = () => { isAiEmotionAutoScrollEnabled.value = false; isAiEmotionUserScrolling.value = false; - + // 清理滚动检测定时器 if (aiEmotionScrollTimer.value) { clearTimeout(aiEmotionScrollTimer.value); aiEmotionScrollTimer.value = null; } - + if (aiEmotionHeightObserver.value) { // 清理ResizeObserver aiEmotionHeightObserver.value.disconnect(); - + // 清理MutationObserver if (aiEmotionHeightObserver.value.mutationObserver) { aiEmotionHeightObserver.value.mutationObserver.disconnect(); aiEmotionHeightObserver.value.mutationObserver = null; } - + // 清理滚动事件监听器 - if (aiEmotionHeightObserver.value.scrollListener && tabContentAiEmotion.value) { - tabContentAiEmotion.value.removeEventListener('scroll', aiEmotionHeightObserver.value.scrollListener); + if ( + aiEmotionHeightObserver.value.scrollListener && + tabContentAiEmotion.value + ) { + tabContentAiEmotion.value.removeEventListener( + "scroll", + aiEmotionHeightObserver.value.scrollListener + ); aiEmotionHeightObserver.value.scrollListener = null; } - + aiEmotionHeightObserver.value = null; } - + console.log("AiEmotion页面高度监听器已停止"); }; @@ -655,7 +671,7 @@ setTimeout(() => { const heightListener = () => { const tabContainer = getCurrentScrollContainer(); if (!tabContainer) return; - + let befortop = 0; const scrollHandler = () => { @@ -807,7 +823,8 @@ const touchmoveHandler = (e) => { } // 判断触摸目标是否在当前活动页面的可滚动区域内 const currentContainer = getCurrentScrollContainer(); - const isScrollableArea = currentContainer && currentContainer.contains(e.target); + const isScrollableArea = + currentContainer && currentContainer.contains(e.target); // 如果不在可滚动区域,则阻止滚动 if (!isScrollableArea) { @@ -925,6 +942,8 @@ const changeToken = () => { }; const goRecharge = () => { + sessionStorage.setItem("rechargeFlag", "1"); + if (isMobile.value) { console.log("用户是移动端"); } else { @@ -953,9 +972,7 @@ const goChange = () => { setTimeout(() => { changeSuccessDialogVisible.value = false; }, 3000); - }; - // 8.18金币兑换Token end onMounted(async () => { @@ -984,12 +1001,12 @@ onMounted(async () => { // 添加原生事件监听器 window.addEventListener("resize", throttledJudgeDevice); - if (getQueryVariable("successType") == "success") { + if ( + sessionStorage.getItem("rechargeFlag") == "1" && + getQueryVariable("successType") == "success" + ) { dialogVisible.value = true; - window.parent.location.href = window.parent.location.href.replace( - "successType=success", - "" - ); + sessionStorage.setItem("rechargeFlag", "0"); } }); @@ -1101,7 +1118,6 @@ onUnmounted(() => {