diff --git a/src/components/NotificationTestTool/index.js b/src/components/NotificationTestTool/index.js index ab8c89ec..51f09b64 100644 --- a/src/components/NotificationTestTool/index.js +++ b/src/components/NotificationTestTool/index.js @@ -30,6 +30,11 @@ import { SOCKET_TYPE } from '../../services/socket'; import { NOTIFICATION_TYPES, PRIORITY_LEVELS } from '../../constants/notificationTypes'; const NotificationTestTool = () => { + // 只在开发环境显示 - 必须在所有 Hooks 调用之前检查 + if (process.env.NODE_ENV !== 'development') { + return null; + } + const { isOpen, onToggle } = useDisclosure(); const { addNotification, soundEnabled, toggleSound, isConnected, clearAllNotifications, notifications, browserPermission, requestBrowserPermission } = useNotification(); const [testCount, setTestCount] = useState(0); @@ -122,11 +127,6 @@ const NotificationTestTool = () => { await requestBrowserPermission(); }; - // 只在开发环境显示 - if (process.env.NODE_ENV !== 'development') { - return null; - } - // 公告通知测试数据 const testAnnouncement = () => { addNotification({