diff --git a/src/components/NotificationContainer/index.js b/src/components/NotificationContainer/index.js index 5deca5c5..4bb338d4 100644 --- a/src/components/NotificationContainer/index.js +++ b/src/components/NotificationContainer/index.js @@ -346,6 +346,11 @@ const NotificationItem = React.memo(({ notification, onClose, isNewest = false } `${typeConfig.colorScheme}.200`, `${typeConfig.colorScheme}.700` ); + // 最新通知的 borderTopColor(避免在条件语句中调用 Hook) + const newestBorderTopColor = useColorModeValue( + `${typeConfig.colorScheme}.100`, + `${typeConfig.colorScheme}.700` + ); // 使用 useMemo 缓存颜色对象(避免不必要的重新创建) const colors = useMemo(() => ({ @@ -357,7 +362,8 @@ const NotificationItem = React.memo(({ notification, onClose, isNewest = false } metaText: metaTextColor, hoverBg: hoverBgColor, closeButtonHoverBg: closeButtonHoverBgColor, - }), [priorityBgColor, borderColor, iconColor, textColor, subTextColor, metaTextColor, hoverBgColor, closeButtonHoverBgColor]); + newestBorderTop: newestBorderTopColor, + }), [priorityBgColor, borderColor, iconColor, textColor, subTextColor, metaTextColor, hoverBgColor, closeButtonHoverBgColor, newestBorderTopColor]); // 点击处理(只有真正可点击时才执行)- 使用 useCallback 优化 const handleClick = useCallback(() => { @@ -430,7 +436,7 @@ const NotificationItem = React.memo(({ notification, onClose, isNewest = false } borderRight: '1px solid', borderRightColor: colors.border, borderTop: '1px solid', - borderTopColor: useColorModeValue(`${typeConfig.colorScheme}.100`, `${typeConfig.colorScheme}.700`), + borderTopColor: colors.newestBorderTop, })} > {/* 头部区域:标题 + 可选标识 */}