diff --git a/src/components/GlobalComponents.js b/src/components/GlobalComponents.js index 8ca4e954..59b4afd8 100644 --- a/src/components/GlobalComponents.js +++ b/src/components/GlobalComponents.js @@ -1,7 +1,7 @@ // src/components/GlobalComponents.js // 集中管理应用的全局组件 -import React from 'react'; +import React, { useMemo } from 'react'; import { useLocation } from 'react-router-dom'; import { useNotification } from '../contexts/NotificationContext'; import { logger } from '../utils/logger'; @@ -75,6 +75,9 @@ function ConnectionStatusBarWrapper() { export function GlobalComponents() { const location = useLocation(); + // ✅ 缓存 Bytedesk 配置对象,避免每次渲染都创建新引用导致重新加载 + const bytedeskConfigMemo = useMemo(() => getBytedeskConfig(), []); + return ( <> {/* Socket 连接状态条 */} @@ -89,9 +92,9 @@ export function GlobalComponents() { {/* 通知容器 */} - {/* Bytedesk在线客服 - 根据路径条件性显示 */} + {/* Bytedesk在线客服 - 使用缓存的配置对象 */}