feat(web): 刮削设置分区、作品详情刮削状态与文件管理「刮削」(SCR-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
f38eca419e
commit
df033130f5
10 files changed
+313
-23
No files matched your search
@@ -7,9 +7,11 @@ import {
|
||||
LibraryItem,
|
||||
type LibraryListQuery,
|
||||
LibraryRoot,
|
||||
LibraryScrapeResult,
|
||||
MediaEntity,
|
||||
MediaEntityDetail,
|
||||
type MediaKind,
|
||||
type ScrapeMode,
|
||||
type UnitMetadataField,
|
||||
} from "@umt/contracts";
|
||||
import type { z } from "zod";
|
||||
@@ -72,6 +74,21 @@ export function useLibraryDetail(id: string | undefined) {
|
||||
queryKey: libraryKeys.detail(id ?? ""),
|
||||
enabled: !!id,
|
||||
queryFn: ({ signal }) => getParsed(LibraryDetail, `/library/${id}`, undefined, signal),
|
||||
// 刮削排队 / 进行中时每 3 秒取一次,拿到结果就停
|
||||
refetchInterval: (q) => {
|
||||
const s = q.state.data?.scrape?.status;
|
||||
return s === "queued" || s === "running" ? 3_000 : false;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/** SCR-1 刮削:写 NFO 与图片到媒体库目录(后台任务);mode 缺省按设置 */
|
||||
export function useScrapeEntity(id: string) {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (v: { mode?: ScrapeMode } = {}) =>
|
||||
parseOrThrow(LibraryScrapeResult, await api.post<unknown>(`/library/${id}/scrape`, v), "/library/{id}/scrape"),
|
||||
onSuccess: () => void qc.invalidateQueries({ queryKey: libraryKeys.detail(id) }),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user