refactor: add chunked execution mechanism for notification batch deletions (#7634)

#### What type of PR is this?

/area ui
/kind improvement
/milestone 2.21.x

#### What this PR does / why we need it:

Use `Promise.all` to execute part of the batch deletion logic of the notification in chunks to optimize the execution performance.

#### Which issue(s) this PR fixes:

Fixes #

#### Does this PR introduce a user-facing change?

```release-note
优化通知批量删除的执行性能
```
pull/7640/head
Ryan Wang 2025-07-22 20:48:18 +08:00 committed by GitHub
parent 5bb7b2826e
commit 471195d6b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 6 deletions

View File

@ -16,6 +16,7 @@ import {
} from "@halo-dev/components";
import { useQuery, useQueryClient } from "@tanstack/vue-query";
import { useRouteQuery } from "@vueuse/router";
import { chunk } from "lodash-es";
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
@ -78,12 +79,16 @@ function handleDeleteNotifications() {
throw new Error("Current user is not found");
}
for (const notification of notifications.value.items) {
await ucApiClient.notification.notification.deleteSpecifiedNotification(
{
const notificationChunks = chunk(notifications.value.items, 5);
for (const chunk of notificationChunks) {
await Promise.all(
chunk.map((notification) =>
ucApiClient.notification.notification.deleteSpecifiedNotification({
username: currentUser.metadata.name,
name: notification.metadata.name,
}
})
)
);
}