diff --git a/src/components/UrgentTestDialog.vue b/src/components/UrgentTestDialog.vue index 76c0f2a..09dd223 100644 --- a/src/components/UrgentTestDialog.vue +++ b/src/components/UrgentTestDialog.vue @@ -681,7 +681,9 @@ export default { try { this.persistentNotifications = this.persistentNotifications.filter(n => n.id !== id) - await dataProvider.saveData('notification-list', this.persistentNotifications) + // 当通知列表为空时,保存空对象 {} 而不是空数组 [],因为后端不接受空数组 + const dataToSave = this.persistentNotifications.length > 0 ? this.persistentNotifications : {} + await dataProvider.saveData('notification-list', dataToSave) this.$message?.success('已删除') } catch (e) { console.error('删除失败', e) diff --git a/src/pages/index.vue b/src/pages/index.vue index d555d5e..224818e 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -2066,7 +2066,9 @@ export default { }, async removePersistentNotification(id) { this.persistentNotifications = this.persistentNotifications.filter(n => n.id !== id); - await dataProvider.saveData('notification-list', this.persistentNotifications); + // 当通知列表为空时,保存空对象 {} 而不是空数组 [],因为后端不接受空数组 + const dataToSave = this.persistentNotifications.length > 0 ? this.persistentNotifications : {}; + await dataProvider.saveData('notification-list', dataToSave); this.notificationDetailDialog = false; }, },