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 通知不存在" };
}
database.panelNotifications = database.panelNotifications.filter((item) =>
!(item.deviceId === deviceId && item.notificationId === notificationId)
);
if (exactMatch) {
database.panelNotifications = database.panelNotifications.filter((item) => item !== exactMatch);
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": {
+15 -2
View File
@@ -552,8 +552,12 @@ test("panel notifications and volume configuration stay isolated by device", asy
type: "ackPanelNotification", deviceId, notificationId: notification.notification.notificationId,
adminToken: "test-token"
});
assert.equal(duplicatedAck.success, false);
assert.equal(duplicatedAck.errMsg, "Panel 通知不存在");
assert.equal(duplicatedAck.success, true);
assert.equal(duplicatedAck.idempotent, true);
assert.equal(duplicatedAck.deleted, 0);
assert.equal((await post({
type: "getPendingPanelNotification", deviceId, adminToken: "test-token"
})).pending, false);
async function uploadResult(folderName, fileName, content) {
const result = await post({ type: "uploadDataFile", fileName, folder: `${deviceId}/${folderName}` });
@@ -567,6 +571,15 @@ test("panel notifications and volume configuration stay isolated by device", asy
});
assert.equal(volumeResult.notification.type, "volume_result_ready");
assert.ok(volumeResult.notification.fileID);
const fallbackAck = await post({
type: "ackPanelNotification",
deviceId: otherDeviceId,
notificationId: volumeResult.notification.notificationId,
adminToken: "test-token"
});
assert.equal(fallbackAck.success, true);
assert.equal(fallbackAck.idempotent, true);
assert.equal(fallbackAck.deleted, 1);
await post({
type: "ackPanelNotification", deviceId, notificationId: volumeResult.notification.notificationId,
adminToken: "test-token"