From 834067f6792cc3ec7114dcdb82d43d2ccc9373d3 Mon Sep 17 00:00:00 2001 From: zdl <3489966805@qq.com> Date: Fri, 21 Nov 2025 14:38:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=20GlobalComponents.js?= =?UTF-8?q?=EF=BC=88=E7=BC=93=E5=AD=98=20config=EF=BC=89=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=97=B6=E4=B8=8D=E4=BC=9A=E8=A7=A6=E5=8F=91=20BytedeskWidget?= =?UTF-8?q?=20=E9=87=8D=E6=96=B0=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/GlobalComponents.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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在线客服 - 使用缓存的配置对象 */}