mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-10 15:26:38 +08:00
bug处理
This commit is contained in:
@@ -80,11 +80,11 @@ export function HomePage() {
|
|||||||
const sortedLibraries = useMemo(() => sortByPinnedIds(libraries, pinnedIds), [libraries, pinnedIds])
|
const sortedLibraries = useMemo(() => sortByPinnedIds(libraries, pinnedIds), [libraries, pinnedIds])
|
||||||
|
|
||||||
// 按需拉取卡片预览管理
|
// 按需拉取卡片预览管理
|
||||||
const [fetchedLibIds, setFetchedLibIds] = useState<Set<string>>(new Set())
|
const fetchedLibIdsRef = useRef<Set<string>>(new Set())
|
||||||
const fetchingRef = useRef<Set<string>>(new Set())
|
const fetchingRef = useRef<Set<string>>(new Set())
|
||||||
|
|
||||||
const fetchPreviews = useCallback(async (ids: string[]) => {
|
const fetchPreviews = useCallback(async (ids: string[]) => {
|
||||||
const targets = ids.filter((id) => !fetchedLibIds.has(id) && !fetchingRef.current.has(id))
|
const targets = ids.filter((id) => !fetchedLibIdsRef.current.has(id) && !fetchingRef.current.has(id))
|
||||||
if (targets.length === 0) return
|
if (targets.length === 0) return
|
||||||
targets.forEach((id) => fetchingRef.current.add(id))
|
targets.forEach((id) => fetchingRef.current.add(id))
|
||||||
|
|
||||||
@@ -104,16 +104,12 @@ export function HomePage() {
|
|||||||
} catch {
|
} catch {
|
||||||
// 容错
|
// 容错
|
||||||
} finally {
|
} finally {
|
||||||
setFetchedLibIds((prev) => {
|
targets.forEach((id) => {
|
||||||
const next = new Set(prev)
|
fetchedLibIdsRef.current.add(id)
|
||||||
targets.forEach((id) => {
|
fetchingRef.current.delete(id)
|
||||||
next.add(id)
|
|
||||||
fetchingRef.current.delete(id)
|
|
||||||
})
|
|
||||||
return next
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, [fetchedLibIds])
|
}, [])
|
||||||
|
|
||||||
// 3. 首屏优先加载:轮播图库 + 媒体库卡片区前 20 个库 + 首屏前 3 个内容行
|
// 3. 首屏优先加载:轮播图库 + 媒体库卡片区前 20 个库 + 首屏前 3 个内容行
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ export function LibrariesPage() {
|
|||||||
const [repairEpisodeArtwork, setRepairEpisodeArtwork] = useState(false)
|
const [repairEpisodeArtwork, setRepairEpisodeArtwork] = useState(false)
|
||||||
const [repairMsg, setRepairMsg] = useState('')
|
const [repairMsg, setRepairMsg] = useState('')
|
||||||
|
|
||||||
const [fetchedLibIds, setFetchedLibIds] = useState<Set<string>>(new Set())
|
const fetchedLibIdsRef = useRef<Set<string>>(new Set())
|
||||||
const fetchingRef = useRef<Set<string>>(new Set())
|
const fetchingRef = useRef<Set<string>>(new Set())
|
||||||
|
|
||||||
const fetchPreviews = useCallback(async (ids: string[]) => {
|
const fetchPreviews = useCallback(async (ids: string[]) => {
|
||||||
const targets = ids.filter((id) => !fetchedLibIds.has(id) && !fetchingRef.current.has(id))
|
const targets = ids.filter((id) => !fetchedLibIdsRef.current.has(id) && !fetchingRef.current.has(id))
|
||||||
if (targets.length === 0) return
|
if (targets.length === 0) return
|
||||||
targets.forEach((id) => fetchingRef.current.add(id))
|
targets.forEach((id) => fetchingRef.current.add(id))
|
||||||
|
|
||||||
@@ -46,16 +46,12 @@ export function LibrariesPage() {
|
|||||||
} catch {
|
} catch {
|
||||||
// 容错
|
// 容错
|
||||||
} finally {
|
} finally {
|
||||||
setFetchedLibIds((prev) => {
|
targets.forEach((id) => {
|
||||||
const next = new Set(prev)
|
fetchedLibIdsRef.current.add(id)
|
||||||
targets.forEach((id) => {
|
fetchingRef.current.delete(id)
|
||||||
next.add(id)
|
|
||||||
fetchingRef.current.delete(id)
|
|
||||||
})
|
|
||||||
return next
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, [fetchedLibIds])
|
}, [])
|
||||||
|
|
||||||
const loadLibraries = useCallback(async () => {
|
const loadLibraries = useCallback(async () => {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|||||||
Reference in New Issue
Block a user