mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-06 08:06:19 +00:00
fix(frontend): refresh account data without table loading
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user