1
0
mirror of https://github.com/ZeroCatDev/Classworks.git synced 2025-12-07 21:13:11 +00:00

Merge pull request #22 from ZeroCatDev/copilot/fix-notification-bug

Fix notification deletion: save {} instead of [] when list is empty
This commit is contained in:
Sunwuyuan 2025-12-01 18:28:43 +08:00 committed by GitHub
commit a5cd6bcd08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -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)

View File

@ -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;
},
},