fix(frontend): refresh account data without table loading

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Zyy
2026-08-14 01:07:12 +08:00
co-authored by Codex
parent 6074cff68c
commit 9d90dedb81
4 changed files with 14 additions and 7 deletions
+10 -6
View File
@@ -27,10 +27,12 @@ export function usePagedQuery<Result extends PageResult>(options: {
const error = shallowRef('')
let requestSequence = 0
async function execute() {
async function execute(execution: { silent?: boolean } = {}) {
const requestId = ++requestSequence
loading.value = true
error.value = ''
if (!execution.silent) {
loading.value = true
error.value = ''
}
try {
const result = await options.load({
@@ -42,7 +44,7 @@ export function usePagedQuery<Result extends PageResult>(options: {
if (result.items.length === 0 && result.page.total > 0 && result.page.page > 1) {
page.value = clamp(result.page.totalPages, 1, Number.POSITIVE_INFINITY)
return execute()
return execute(execution)
}
items.value = result.items
@@ -55,8 +57,10 @@ export function usePagedQuery<Result extends PageResult>(options: {
catch (cause: unknown) {
if (requestId !== requestSequence)
return false
error.value = errorMessage(cause, '加载失败')
options.onError?.(cause)
if (!execution.silent) {
error.value = errorMessage(cause, '加载失败')
options.onError?.(cause)
}
return false
}
finally {
@@ -45,6 +45,7 @@ const quotaWindows = computed(() => orderedPanelQuotaWindows(props.account.quota
variant="ghost"
size="sm"
title="刷新额度"
spin-icon-on-loading
:loading="refreshing"
:disabled="refreshing"
@click="emit('refreshQuota', account.id)"
@@ -141,6 +141,7 @@ export function useAccountsQuery() {
loading: query.loading,
accounts: query.items,
loadAccounts: query.execute,
refreshAccountsSilently: () => query.execute({ silent: true }),
searchQuery,
providerQuery,
statusQuery,
+2 -1
View File
@@ -37,6 +37,7 @@ const {
loading,
accounts,
loadAccounts,
refreshAccountsSilently,
searchQuery,
providerQuery,
statusQuery,
@@ -108,7 +109,7 @@ const {
openConnectionTest,
handleRefreshConnectionTestModels,
handleTestConnection,
} = useAccountConnectionTest({ reload: loadAccounts })
} = useAccountConnectionTest({ reload: refreshAccountsSilently })
const {
expandedAccountIds,