perf: use server search for large option lists

This commit is contained in:
biss committed 2026-10-26 07:32:01 +08:00
1 parent 64b86d2a68
commit acbe64df00
4 files changed
+67 -34

No files matched your search

-19
View File
@@ -1,19 +0,0 @@
import http from './http'
export async function fetchAllPagedItems<T = any>(
url: string,
params: Record<string, unknown> = {},
pageSize = 100,
): Promise<T[]> {
const items: T[] = []
let page = 1
for (;;) {
const response = await http.get(url, { params: { ...params, page, pageSize } })
const batch = (response.data?.items ?? []) as T[]
items.push(...batch)
const total = Number(response.data?.total ?? items.length)
if (batch.length === 0 || items.length >= total) return items
page++
}
}