重构核心模块并同步更新项目配置与相关实现

This commit is contained in:
truewhile
2026-09-13 20:36:14 +08:00
parent 386fc358d1
commit 9a68ef701f
38 changed files with 1587 additions and 678 deletions
+7 -6
View File
@@ -33,8 +33,10 @@ export function LibrariesPage() {
if (targets.length === 0) return
targets.forEach((id) => fetchingRef.current.add(id))
let loaded = false
try {
const rows = await libraryAPI.listPreviews(targets, 10)
loaded = true
setLibraryData((prev) => {
const next = { ...prev }
for (const row of rows) {
@@ -49,7 +51,9 @@ export function LibrariesPage() {
// 容错
} finally {
targets.forEach((id) => {
fetchedLibIdsRef.current.add(id)
if (loaded) {
fetchedLibIdsRef.current.add(id)
}
fetchingRef.current.delete(id)
})
}
@@ -68,13 +72,10 @@ export function LibrariesPage() {
try {
const libs = await fetchLibraries()
setLibraries(libs)
// 优先拉取入口卡片网格当前页(前 20 个库)的预览
const topIds = libs.slice(0, 20).map((l) => l.id)
void fetchPreviews(topIds)
} finally {
setLoading(false)
}
}, [fetchPreviews])
}, [])
async function handleRepairRescrape() {
if (repairing) return
@@ -105,7 +106,7 @@ export function LibrariesPage() {
return {
library,
items: [],
total: data?.total ?? 0,
total: library.total ?? data?.total ?? 0,
cards: data?.cards ?? [],
}
})