Browse Source

首页跳转优化

milestone-20250820-金币兑换Token
no99 2 days ago
parent
commit
5190be38d6
  1. 121
      src/views/homePage.vue

121
src/views/homePage.vue

@ -375,9 +375,9 @@ const chartInteractionTimer = ref(null); // 图表交互检测定时器
// //
const getCurrentScrollContainer = () => { const getCurrentScrollContainer = () => {
if (activeTab.value === 'AIchat') {
if (activeTab.value === "AIchat") {
return tabContentAIchat.value; return tabContentAIchat.value;
} else if (activeTab.value === 'AiEmotion') {
} else if (activeTab.value === "AiEmotion") {
return tabContentAiEmotion.value; return tabContentAiEmotion.value;
} }
return null; return null;
@ -408,7 +408,12 @@ const throttledSmoothScrollToBottom = _.throttle(smoothScrollToBottom, 300, {
// AiEmotion // AiEmotion
const debouncedAiEmotionScrollToBottom = _.debounce(() => { const debouncedAiEmotionScrollToBottom = _.debounce(() => {
if (activeTab.value === 'AiEmotion' && isAiEmotionAutoScrollEnabled.value && !isAiEmotionUserScrolling.value && !isChartInteracting.value) {
if (
activeTab.value === "AiEmotion" &&
isAiEmotionAutoScrollEnabled.value &&
!isAiEmotionUserScrolling.value &&
!isChartInteracting.value
) {
const container = tabContentAiEmotion.value; const container = tabContentAiEmotion.value;
if (container) { if (container) {
container.scrollTop = container.scrollHeight - container.offsetHeight; container.scrollTop = container.scrollHeight - container.offsetHeight;
@ -420,21 +425,25 @@ const debouncedAiEmotionScrollToBottom = _.debounce(() => {
const startAiEmotionHeightObserver = () => { const startAiEmotionHeightObserver = () => {
// //
stopAiEmotionHeightObserver(); stopAiEmotionHeightObserver();
isAiEmotionAutoScrollEnabled.value = true; isAiEmotionAutoScrollEnabled.value = true;
// ResizeObserver // ResizeObserver
aiEmotionHeightObserver.value = new ResizeObserver((entries) => { aiEmotionHeightObserver.value = new ResizeObserver((entries) => {
if (isAiEmotionAutoScrollEnabled.value && activeTab.value === 'AiEmotion' && !isChartInteracting.value) {
if (
isAiEmotionAutoScrollEnabled.value &&
activeTab.value === "AiEmotion" &&
!isChartInteracting.value
) {
debouncedAiEmotionScrollToBottom(); debouncedAiEmotionScrollToBottom();
} }
}); });
// document.body // document.body
if (document.body) { if (document.body) {
aiEmotionHeightObserver.value.observe(document.body); aiEmotionHeightObserver.value.observe(document.body);
} }
// MutationObserverDOM // MutationObserverDOM
const mutationObserver = new MutationObserver((mutations) => { const mutationObserver = new MutationObserver((mutations) => {
let shouldScroll = false; let shouldScroll = false;
@ -455,12 +464,17 @@ const startAiEmotionHeightObserver = () => {
} }
} }
}); });
if (shouldScroll && isAiEmotionAutoScrollEnabled.value && activeTab.value === 'AiEmotion' && !isChartInteracting.value) {
if (
shouldScroll &&
isAiEmotionAutoScrollEnabled.value &&
activeTab.value === "AiEmotion" &&
!isChartInteracting.value
) {
debouncedAiEmotionScrollToBottom(); debouncedAiEmotionScrollToBottom();
} }
}); });
// AiEmotionDOM // AiEmotionDOM
const aiEmotionContainer = tabContentAiEmotion.value; const aiEmotionContainer = tabContentAiEmotion.value;
if (aiEmotionContainer) { if (aiEmotionContainer) {
@ -471,17 +485,19 @@ const startAiEmotionHeightObserver = () => {
characterData: true, characterData: true,
}); });
} }
// mutationObserver便 // mutationObserver便
aiEmotionHeightObserver.value.mutationObserver = mutationObserver; aiEmotionHeightObserver.value.mutationObserver = mutationObserver;
// AiEmotion // AiEmotion
if (aiEmotionContainer) { if (aiEmotionContainer) {
aiEmotionContainer.addEventListener('scroll', handleAiEmotionUserScroll, { passive: true });
aiEmotionContainer.addEventListener("scroll", handleAiEmotionUserScroll, {
passive: true,
});
// 便 // 便
aiEmotionHeightObserver.value.scrollListener = handleAiEmotionUserScroll; aiEmotionHeightObserver.value.scrollListener = handleAiEmotionUserScroll;
} }
console.log("AiEmotion页面高度监听器已启动"); console.log("AiEmotion页面高度监听器已启动");
}; };
@ -489,12 +505,12 @@ const startAiEmotionHeightObserver = () => {
const handleAiEmotionUserScroll = () => { const handleAiEmotionUserScroll = () => {
// //
isAiEmotionUserScrolling.value = true; isAiEmotionUserScrolling.value = true;
// //
if (aiEmotionScrollTimer.value) { if (aiEmotionScrollTimer.value) {
clearTimeout(aiEmotionScrollTimer.value); clearTimeout(aiEmotionScrollTimer.value);
} }
// 2 // 2
// aiEmotionScrollTimer.value = setTimeout(() => { // aiEmotionScrollTimer.value = setTimeout(() => {
// isAiEmotionUserScrolling.value = false; // isAiEmotionUserScrolling.value = false;
@ -506,7 +522,7 @@ const handleAiEmotionUserScroll = () => {
const handleChartInteractionStart = () => { const handleChartInteractionStart = () => {
console.log("图表交互开始,临时禁用自动滚动"); console.log("图表交互开始,临时禁用自动滚动");
isChartInteracting.value = true; isChartInteracting.value = true;
// //
if (chartInteractionTimer.value) { if (chartInteractionTimer.value) {
clearTimeout(chartInteractionTimer.value); clearTimeout(chartInteractionTimer.value);
@ -518,7 +534,7 @@ const handleChartInteractionEnd = () => {
if (chartInteractionTimer.value) { if (chartInteractionTimer.value) {
clearTimeout(chartInteractionTimer.value); clearTimeout(chartInteractionTimer.value);
} }
// 1 // 1
chartInteractionTimer.value = setTimeout(() => { chartInteractionTimer.value = setTimeout(() => {
isChartInteracting.value = false; isChartInteracting.value = false;
@ -532,7 +548,7 @@ window.handleChartInteractionEnd = handleChartInteractionEnd;
// AiEmotion // AiEmotion
const handleAiEmotionScrollToBottom = () => { const handleAiEmotionScrollToBottom = () => {
if (activeTab.value === 'AiEmotion') {
if (activeTab.value === "AiEmotion") {
const container = tabContentAiEmotion.value; const container = tabContentAiEmotion.value;
if (container) { if (container) {
// 使nextTickDOM // 使nextTickDOM
@ -548,32 +564,38 @@ const handleAiEmotionScrollToBottom = () => {
const stopAiEmotionHeightObserver = () => { const stopAiEmotionHeightObserver = () => {
isAiEmotionAutoScrollEnabled.value = false; isAiEmotionAutoScrollEnabled.value = false;
isAiEmotionUserScrolling.value = false; isAiEmotionUserScrolling.value = false;
// //
if (aiEmotionScrollTimer.value) { if (aiEmotionScrollTimer.value) {
clearTimeout(aiEmotionScrollTimer.value); clearTimeout(aiEmotionScrollTimer.value);
aiEmotionScrollTimer.value = null; aiEmotionScrollTimer.value = null;
} }
if (aiEmotionHeightObserver.value) { if (aiEmotionHeightObserver.value) {
// ResizeObserver // ResizeObserver
aiEmotionHeightObserver.value.disconnect(); aiEmotionHeightObserver.value.disconnect();
// MutationObserver // MutationObserver
if (aiEmotionHeightObserver.value.mutationObserver) { if (aiEmotionHeightObserver.value.mutationObserver) {
aiEmotionHeightObserver.value.mutationObserver.disconnect(); aiEmotionHeightObserver.value.mutationObserver.disconnect();
aiEmotionHeightObserver.value.mutationObserver = null; 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.scrollListener = null;
} }
aiEmotionHeightObserver.value = null; aiEmotionHeightObserver.value = null;
} }
console.log("AiEmotion页面高度监听器已停止"); console.log("AiEmotion页面高度监听器已停止");
}; };
@ -685,7 +707,7 @@ setTimeout(() => {
const heightListener = () => { const heightListener = () => {
const tabContainer = getCurrentScrollContainer(); const tabContainer = getCurrentScrollContainer();
if (!tabContainer) return; if (!tabContainer) return;
let befortop = 0; let befortop = 0;
const scrollHandler = () => { const scrollHandler = () => {
@ -837,7 +859,8 @@ const touchmoveHandler = (e) => {
} }
// //
const currentContainer = getCurrentScrollContainer(); const currentContainer = getCurrentScrollContainer();
const isScrollableArea = currentContainer && currentContainer.contains(e.target);
const isScrollableArea =
currentContainer && currentContainer.contains(e.target);
// //
if (!isScrollableArea) { if (!isScrollableArea) {
@ -905,12 +928,14 @@ const backToHome = () => {
if (env == "development" || env == "test") { if (env == "development" || env == "test") {
window.parent.location.href = window.parent.location.href =
"http://121.89.234.155:8807/hljw/homepage?menu=999999991"; "http://121.89.234.155:8807/hljw/homepage?menu=999999991";
} else if (env == "product") {
window.parent.location.href =
"https://web.homilychart.com/product/hljw/homepage?menu=999999991";
} else if (env == "production") {
window.parent.location.href =
"https://web.homilychart.com/hljw/homepage?menu=999999991";
} else {
window.parent.postMessage(
{
type: "NAVIGATE_TO_HOMEPAGE",
menu: "999999991",
},
"*"
);
} }
// window.parent.location.href = window.parent.document.referrer // window.parent.location.href = window.parent.document.referrer
} }
@ -983,7 +1008,6 @@ const goChange = () => {
setTimeout(() => { setTimeout(() => {
changeSuccessDialogVisible.value = false; changeSuccessDialogVisible.value = false;
}, 3000); }, 3000);
}; };
// 8.18Token end // 8.18Token end
@ -1031,17 +1055,17 @@ onUnmounted(() => {
} }
// AiEmotion // AiEmotion
stopAiEmotionHeightObserver(); stopAiEmotionHeightObserver();
// //
if (chartInteractionTimer.value) {
clearTimeout(chartInteractionTimer.value);
}
if (window.handleChartInteractionStart) {
delete window.handleChartInteractionStart;
}
if (window.handleChartInteractionEnd) {
delete window.handleChartInteractionEnd;
}
if (chartInteractionTimer.value) {
clearTimeout(chartInteractionTimer.value);
}
if (window.handleChartInteractionStart) {
delete window.handleChartInteractionStart;
}
if (window.handleChartInteractionEnd) {
delete window.handleChartInteractionEnd;
}
}); });
</script> </script>
@ -1142,7 +1166,6 @@ onUnmounted(() => {
<div class="pc-count-number">{{ UserCount }}</div> <div class="pc-count-number">{{ UserCount }}</div>
</div> </div>
<div class="pc-clickGetCount">点击获取Token</div> <div class="pc-clickGetCount">点击获取Token</div>
</div> </div>
<div class="pc-backToHomeBtn" @click="backToHome()"> <div class="pc-backToHomeBtn" @click="backToHome()">
<img <img
@ -1174,7 +1197,7 @@ onUnmounted(() => {
@enableInput="enableInput" @enableInput="enableInput"
/> />
</div> </div>
<!-- AiEmotion页面的独立滚动容器 --> <!-- AiEmotion页面的独立滚动容器 -->
<div <div
v-show="activeTab === 'AiEmotion'" v-show="activeTab === 'AiEmotion'"

Loading…
Cancel
Save