diff --git a/src/component/Common/AnnouncementDialog.tsx b/src/component/Common/AnnouncementDialog.tsx index 1cb5fbd..a138fda 100644 --- a/src/component/Common/AnnouncementDialog.tsx +++ b/src/component/Common/AnnouncementDialog.tsx @@ -27,7 +27,22 @@ const AnnouncementDialog = () => { dispatch(getAnnouncement()); }, [dispatch]); + // 保存上次显示的公告内容,用于检测公告是否更新 + const [lastAnnouncement, setLastAnnouncement] = useState(""); + useEffect(() => { + // 检查公告是否更新,如果更新了则清除"不再显示"状态 + const hasAnnouncementChanged = announcement !== lastAnnouncement && lastAnnouncement !== ""; + if (hasAnnouncementChanged) { + // 使用set方法将其设置为null来清除不再显示状态 + SessionManager.set("announcement_dismissed", null); + } + + // 更新上次显示的公告内容 + if (announcement) { + setLastAnnouncement(announcement); + } + // 检查是否应该显示公告 const shouldShow = announcementEnabled && @@ -40,7 +55,7 @@ const AnnouncementDialog = () => { const timer = setTimeout(() => setOpen(true), 1000); return () => clearTimeout(timer); } - }, [announcement, announcementEnabled]); + }, [announcement, announcementEnabled, lastAnnouncement]); const handleClose = () => { if (dontShowAgain) {