From 077f8d91200fc12619487a03d35131844fa69cc1 Mon Sep 17 00:00:00 2001 From: zzlgreat Date: Sat, 22 Nov 2025 06:54:16 +0800 Subject: [PATCH] update pay function --- src/views/AgentChat/index.js | 180 +++++++++++++++++++++-------------- 1 file changed, 106 insertions(+), 74 deletions(-) diff --git a/src/views/AgentChat/index.js b/src/views/AgentChat/index.js index b7c9fc29..b35ed975 100644 --- a/src/views/AgentChat/index.js +++ b/src/views/AgentChat/index.js @@ -63,6 +63,7 @@ import { StepResultCard } from '@components/ChatBot/StepResultCard'; import { MarkdownWithCharts } from '@components/ChatBot/MarkdownWithCharts'; import { logger } from '@utils/logger'; import axios from 'axios'; +import HomeNavbar from '@components/Navbars/HomeNavbar'; /** * Agent消息类型 @@ -174,6 +175,18 @@ const AgentChatV4 = () => { const { user } = useAuth(); const toast = useToast(); + // 确保组件总是返回有效的 React 元素 + if (!user) { + return ( + + + + 正在加载... + + + ); + } + // 会话相关状态 const [sessions, setSessions] = useState([]); const [currentSessionId, setCurrentSessionId] = useState(null); @@ -333,18 +346,47 @@ const AgentChatV4 = () => { // 在 AgentChat 页面隐藏 Bytedesk 客服插件(避免遮挡页面) useEffect(() => { - // 隐藏 Bytedesk - const bytedeskElements = document.querySelectorAll('[class*="bytedesk"], [id*="bytedesk"], [class*="BytedeskWeb"]'); - bytedeskElements.forEach(el => { - if (el) el.style.display = 'none'; - }); + // 隐藏 Bytedesk - 更安全的方式 + const hideBytedeskElements = () => { + try { + // 查找所有 Bytedesk 相关元素 + const bytedeskElements = document.querySelectorAll( + '[class*="bytedesk"], [id*="bytedesk"], [class*="BytedeskWeb"], .bytedesk-widget' + ); + + // 保存原始 display 值 + const originalDisplays = new Map(); + + bytedeskElements.forEach(el => { + if (el && el.style) { + originalDisplays.set(el, el.style.display); + el.style.display = 'none'; + } + }); + + // 返回清理函数 + return () => { + bytedeskElements.forEach(el => { + if (el && el.style) { + const originalDisplay = originalDisplays.get(el); + if (originalDisplay !== undefined) { + el.style.display = originalDisplay; + } else { + el.style.display = ''; + } + } + }); + }; + } catch (error) { + console.warn('Failed to hide Bytedesk elements:', error); + return () => {}; // 返回空清理函数 + } + }; + + const cleanup = hideBytedeskElements(); // 组件卸载时恢复显示 - return () => { - bytedeskElements.forEach(el => { - if (el) el.style.display = ''; - }); - }; + return cleanup; }, []); const addMessage = (message) => { @@ -716,26 +758,13 @@ const AgentChatV4 = () => { ); return ( - <> - {/* 全局样式:确保页面占满整个视口 */} + + {/* 顶部导航栏 */} + + + {/* 全局样式:确保页面正确显示 */} ); };