This commit is contained in:
2025-10-23 20:25:29 +08:00
parent f7ccd807a1
commit b808feb1fd

View File

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