修复上游倍率探测导致账号列表整页刷新的问题
This commit is contained in:
Wesley Liddick authored and GitHub committed 2026-08-29 09:12:05 +08:00
commit ac18c588c8
8 files changed
+361 -39

No files matched your search

+41
View File
@@ -23,6 +23,7 @@ import type {
CheckMixedChannelResponse,
UpstreamBillingProbeResult,
UpstreamBillingProbeSettings,
UpstreamBillingRatesResponse,
OllamaCloudUsageSettings,
OllamaCloudUsageState
} from '@/types'
@@ -70,6 +71,45 @@ export interface AccountListWithEtagResult {
data: PaginatedResponse<Account> | null
}
export interface AccountUpstreamBillingRatesWithEtagResult {
notModified: boolean
etag: string | null
data: UpstreamBillingRatesResponse | null
}
export async function getUpstreamBillingRatesWithEtag(
page: number = 1,
pageSize: number = 20,
filters?: {
platform?: string
type?: string
status?: string
group?: string
search?: string
privacy_mode?: string
sort_by?: string
sort_order?: 'asc' | 'desc'
},
options?: {
signal?: AbortSignal
etag?: string | null
}
): Promise<AccountUpstreamBillingRatesWithEtagResult> {
const headers: Record<string, string> = {}
if (options?.etag) headers['If-None-Match'] = options.etag
const response = await apiClient.get<UpstreamBillingRatesResponse>('/admin/accounts/upstream-billing-rates', {
params: { page, page_size: pageSize, ...filters },
headers,
signal: options?.signal,
validateStatus: (status) => (status >= 200 && status < 300) || status === 304
})
const etagHeader = typeof response.headers?.etag === 'string' ? response.headers.etag : null
if (response.status === 304) return { notModified: true, etag: etagHeader, data: null }
return { notModified: false, etag: etagHeader, data: response.data }
}
export async function listWithEtag(
page: number = 1,
pageSize: number = 20,
@@ -1008,6 +1048,7 @@ export async function refreshOllamaCloudUsage(id: number): Promise<OllamaCloudUs
export const accountsAPI = {
list,
listWithEtag,
getUpstreamBillingRatesWithEtag,
getById,
create,
duplicate,