fix notice display

This commit is contained in:
2026-08-03 18:20:23 +08:00
parent 8c3df90a87
commit 1f9c096d05
2 changed files with 34 additions and 9 deletions
+19 -7
View File
@@ -966,16 +966,28 @@ function createApp({
const notificationId = String(event.notificationId || "");
if (!notificationId) return { success: false, errMsg: "缺少 notificationId" };
return store.update((database) => {
const exists = database.panelNotifications.some((item) =>
const exactMatch = database.panelNotifications.find((item) =>
item.deviceId === deviceId && item.notificationId === notificationId
);
if (!exists) {
return { success: false, errMsg: "Panel 通知不存在" };
if (exactMatch) {
database.panelNotifications = database.panelNotifications.filter((item) => item !== exactMatch);
return { success: true, notificationId, deleted: 1 };
}
database.panelNotifications = database.panelNotifications.filter((item) =>
!(item.deviceId === deviceId && item.notificationId === notificationId)
);
return { success: true, notificationId, deleted: 1 };
// 兼容:客户端 deviceId 切换或重连后,允许仅凭 notificationId 完成幂等关闭。
const fallbackMatch = database.panelNotifications.find((item) => item.notificationId === notificationId);
if (fallbackMatch) {
database.panelNotifications = database.panelNotifications.filter((item) => item !== fallbackMatch);
return {
success: true,
notificationId,
deleted: 1,
idempotent: true,
reassignedDeviceId: fallbackMatch.deviceId
};
}
return { success: true, notificationId, deleted: 0, idempotent: true };
});
}
case "ackPanelFile": {