mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
perf: Pool 账号删除后改用乐观更新替代全量重载
- PoolAccountBatchDialog: 批量删除全部成功时直接从本地列表移除,其余操作保留原重载逻辑 - PoolManagement: 单个删除后本地移除条目并更新 total,当前页为空时自动跳转前一页
This commit is contained in:
@@ -704,18 +704,20 @@ async function executeAction(): Promise<void> {
|
||||
if (failedCount > 0) warning(lastResultMessage.value)
|
||||
else success(lastResultMessage.value)
|
||||
|
||||
const shouldClearSelection = selectedAction.value === 'delete'
|
||||
const previousSelection = new Set(selectedKeyIds.value)
|
||||
actionPhaseMs = performance.now() - actionStartedAt
|
||||
const reloadStartedAt = performance.now()
|
||||
await loadAllKeys()
|
||||
reloadPhaseMs = performance.now() - reloadStartedAt
|
||||
if (shouldClearSelection) {
|
||||
if (selectedAction.value === 'delete' && successCount > 0 && failedCount === 0) {
|
||||
// 全部删除成功:直接从本地列表移除,不做全量重载
|
||||
const deletedIds = new Set(selectedKeys.map((key) => key.key_id))
|
||||
allKeys.value = allKeys.value.filter((key) => !deletedIds.has(key.key_id))
|
||||
selectedKeyIds.value = []
|
||||
} else {
|
||||
const previousSelection = new Set(selectedKeyIds.value)
|
||||
await loadAllKeys()
|
||||
const existingIds = new Set(allKeys.value.map((key) => key.key_id))
|
||||
selectedKeyIds.value = [...previousSelection].filter((id) => existingIds.has(id))
|
||||
}
|
||||
reloadPhaseMs = performance.now() - reloadStartedAt
|
||||
emit('changed')
|
||||
} catch (err) {
|
||||
showError(parseApiError(err, '批量操作失败'))
|
||||
|
||||
Reference in New Issue
Block a user