feat: v0.3.8–v0.3.14 工作区汇总(依赖升级、整理来源、手动入库、原地入库等)

生产 v0.3.8~v0.3.13 均由 8013196 加工作区修改构建部署,此前未提交;本提交补齐源码,
并含未部署的 v0.3.14 原地入库。中间各版本源码状态未保存,无法逐版拆分,详见
docs/plan/17-full-upgrade.md 与 docs/plan/18-organize-release.md。

- v0.3.8 全面升级:Deno workspace 依赖、Router 8 / Vite 8、camofox 1.18.0 / Node 24、
  PostgreSQL 18.6、备份客户端 18.6、演示 qB 5.2.4
- v0.3.9 媒体整理:分类规则、整理来源与目录快照(0059)、文件管理整理入口
- v0.3.10 手动下载与入库:独立手动下载、详情页资源下载、TMDB / Local 元数据兜底
  (metadata.resolve_organize)、正常多版本 / 一次性洗版(0060)
- v0.3.11 搜索详情与桌面黑边修复
- v0.3.12 列表分页、搜索历史、首页概况
- v0.3.13 统一整理弹窗与队列
- v0.3.14 原地入库(0061,未部署)

同批审计修复:
- 刮削入队:确认原记录存在后才删重放产生的新记录;写回 run 关联失败时保持 queued,
  由处理器补关联(对齐 MP 先登记、只在入队失败时记失败)
- 识别升级链只在结果更确定时采用,不再用 no_match 顶替原有歧义候选
- bluray_dir 资产以原盘目录本身为刮削根(MP 同做法)
- metadata.resolve_organize 登记到入库排障 Skill 与能力地图
- db/src/types.ts 按迁移重新生成;contracts 整理动作枚举顺序与数据库对齐
- 测试:原地入库用例改为直接查记录表;domain 测试模板补 version
- 前端:通知铃铛弹层与用户菜单统一样式;站点卡片共用卡头、底栏贴底、分页间距

依赖升级证据只提交摘要文件,registry-snapshot.json 移至 .local/(SHA-256 记于文档)。

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-10-02 15:47:17 +08:00
1 parent 8013196e3f
commit ceb66f8c77
265 files changed
+17751 -2483

No files matched your search

+2 -1
View File
@@ -17,7 +17,7 @@ export function DirPicker({
onChange: (ref: FileRef) => void;
className?: string;
}) {
const writable = roots.filter((r) => r.writable && r.health !== "offline");
const writable = roots.filter((r) => r.kind === "library" && r.writable && r.health !== "offline");
return (
<div className={cn("overflow-y-auto rounded-xl border border-border p-1.5", className)}>
{writable.length ? (
@@ -25,6 +25,7 @@ export function DirPicker({
roots={writable}
current={value}
pickOnly
paginate
defaultOpen={value ? [value.root] : writable.slice(0, 1).map((r) => r.id)}
onSelect={onChange}
/>
+28 -2
View File
@@ -1,6 +1,8 @@
import { ChevronRight, Download, Folder, FolderOpen, HardDrive, LoaderCircle, TriangleAlert } from "lucide-react";
import { useEffect, useState } from "react";
import { type FileRoot, useDirChildren } from "~/api/files.ts";
import { useListPagination } from "~/components/console/use-list-pagination.ts";
import { Pagination } from "~/components/ui/pagination.tsx";
import { healthLabel } from "~/lib/labels.ts";
import { cn } from "~/lib/utils.ts";
import { groupRoots, joinRel, segments } from "./model.ts";
@@ -21,6 +23,7 @@ export function DirTree({
onSelect,
onDropTo,
pickOnly = false,
paginate = false,
defaultOpen = [],
className,
}: {
@@ -29,6 +32,8 @@ export function DirTree({
onSelect: (loc: Loc) => void;
onDropTo?: DropHandler;
pickOnly?: boolean;
/** 目录选择小窗按页展示子目录;主文件树保持懒展开。 */
paginate?: boolean;
/** 初始展开的根 id(目标选择器里默认展开可写根) */
defaultOpen?: string[];
className?: string;
@@ -75,6 +80,7 @@ export function DirTree({
onSelect={onSelect}
onDropTo={onDropTo}
pickOnly={pickOnly}
paginate={paginate}
/>
))}
</div>
@@ -92,6 +98,7 @@ function RootNode({
onSelect,
onDropTo,
pickOnly,
paginate,
}: {
root: FileRoot;
current: Loc | null;
@@ -100,6 +107,7 @@ function RootNode({
onSelect: (loc: Loc) => void;
onDropTo?: DropHandler;
pickOnly: boolean;
paginate: boolean;
}) {
const k = nodeKey(root.id, "");
const offline = root.health === "offline";
@@ -162,6 +170,7 @@ function RootNode({
onSelect={onSelect}
onDropTo={onDropTo}
pickOnly={pickOnly}
paginate={paginate}
/>
) : null}
</div>
@@ -178,6 +187,7 @@ function Children({
onSelect,
onDropTo,
pickOnly,
paginate,
}: {
root: FileRoot;
path: string;
@@ -188,8 +198,23 @@ function Children({
onSelect: (loc: Loc) => void;
onDropTo?: DropHandler;
pickOnly: boolean;
paginate: boolean;
}) {
const q = useDirChildren(root.id, path, true);
const dirs = q.data?.dirs ?? [];
const paged = useListPagination(dirs, { resetKey: JSON.stringify({ root: root.id, path }) });
const selectedIndex =
current?.root === root.id
? dirs.findIndex((dir) => {
const childPath = dir.path || joinRel(path, dir.name);
return current.path === childPath || current.path.startsWith(`${childPath}/`);
})
: -1;
// biome-ignore lint/correctness/useExhaustiveDependencies: 选中目录改变时定位;手动翻页不改变已有选择
useEffect(() => {
if (paginate && selectedIndex >= 0)
paged.pagination.onPageChange(Math.floor(selectedIndex / paged.pagination.pageSize) + 1);
}, [paginate, root.id, path, selectedIndex, paged.pagination.pageSize]);
if (q.isPending)
return (
<div
@@ -205,7 +230,6 @@ function Children({
读取失败
</p>
);
const dirs = q.data?.dirs ?? [];
if (!dirs.length)
return (
<p className="py-1 text-meta text-muted-foreground" style={{ paddingLeft: depth * 14 + 28 }}>
@@ -214,7 +238,7 @@ function Children({
);
return (
<div>
{dirs.map((d) => {
{(paginate ? paged.items : dirs)?.map((d) => {
const p = d.path || joinRel(path, d.name);
const k = nodeKey(root.id, p);
const isOpen = open.has(k);
@@ -251,11 +275,13 @@ function Children({
onSelect={onSelect}
onDropTo={onDropTo}
pickOnly={pickOnly}
paginate={paginate}
/>
) : null}
</div>
);
})}
{paginate && dirs.length > 0 ? <Pagination {...paged.pagination} /> : null}
{q.data?.truncated ? (
<p className="py-1 text-meta text-muted-foreground" style={{ paddingLeft: depth * 14 + 28 }}>
子目录过多,只列出一部分
@@ -0,0 +1,13 @@
import { describe, expect, it } from "vitest";
import { directorySelectionAllowed } from "./directory-dialog.tsx";
describe("目录选择根保护", () => {
it("配置来源与目标默认允许根目录,手动整理只允许子目录", () => {
const root = { root: "dl:instance:0", path: "" };
expect(directorySelectionAllowed(root)).toBe(true);
expect(directorySelectionAllowed(root, false)).toBe(false);
expect(directorySelectionAllowed({ ...root, path: "completed/movie" }, false)).toBe(true);
expect(directorySelectionAllowed(null)).toBe(false);
expect(directorySelectionAllowed({ root: "", path: "movie" })).toBe(false);
});
});
@@ -0,0 +1,138 @@
import { ArrowUp, File, Folder } from "lucide-react";
import { useState } from "react";
import { type FileRef, filesErrorText, useFileList, useFileRoots } from "~/api/files.ts";
import { useListPagination } from "~/components/console/use-list-pagination.ts";
import { Button } from "~/components/ui/button.tsx";
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "~/components/ui/dialog.tsx";
import { Pagination } from "~/components/ui/pagination.tsx";
import { DirTree } from "./dir-tree.tsx";
export const directorySelectionAllowed = (ref: FileRef | null, allowRoot = true): boolean =>
!!ref?.root && (allowRoot || ref.path !== "");
/** Source selection intentionally permits readable download roots; targets only permit writable libraries. */
export function DirectoryDialog({
mode,
value,
onSelect,
onClose,
allowRoot = true,
}: {
mode: "source" | "target";
value?: FileRef | null;
allowRoot?: boolean;
onSelect: (value: FileRef) => void;
onClose: () => void;
}) {
const roots = useFileRoots();
const [selected, setSelected] = useState<FileRef | null>(value ?? null);
const available = (roots.data ?? []).filter(
(r) => r.health !== "offline" && (mode === "source" || (r.kind === "library" && r.writable)),
);
const root = available.find((r) => r.id === selected?.root);
const listing = useFileList(root && selected ? { root: selected.root, path: selected.path } : null);
const entries = listing.data?.pages.flatMap((p) => p.entries) ?? [];
const paged = useListPagination(entries, {
hasMore: listing.hasNextPage,
onLoadMore: () => listing.fetchNextPage(),
loadingMore: listing.isFetchingNextPage,
error: listing.error,
resetKey: JSON.stringify(selected),
});
return (
<Dialog open onOpenChange={(open) => !open && onClose()}>
<DialogContent className="sm:max-w-3xl">
<DialogHeader>
<DialogTitle>{mode === "source" ? "选择来源目录" : "选择媒体库目标目录"}</DialogTitle>
<DialogDescription>展开登记目录,选择一个目录后确认。</DialogDescription>
</DialogHeader>
<div className="grid gap-3 sm:grid-cols-2">
<div className="max-h-80 overflow-auto rounded-xl border p-2">
<DirTree
roots={available}
current={selected}
onSelect={setSelected}
pickOnly={mode === "target"}
paginate
/>
{roots.isPending ? (
<p>读取目录中…</p>
) : !available.length ? (
<p className="text-caption text-muted-foreground">没有可用的登记目录。</p>
) : null}
</div>
<section className="max-h-80 space-y-1 overflow-auto rounded-xl border p-2" aria-label="当前目录内容">
{selected?.path ? (
<Button
variant="ghost"
size="sm"
onClick={() =>
setSelected({ root: selected.root, path: selected.path.split("/").slice(0, -1).join("/") })
}
>
<ArrowUp />
上一级
</Button>
) : null}
{!selected ? (
<p className="text-caption text-muted-foreground">在左侧选择登记目录,查看内容。</p>
) : listing.isPending ? (
<p className="text-caption">读取目录中…</p>
) : listing.error ? (
<p role="alert" className="text-caption text-destructive">
{filesErrorText(listing.error, "目录不可读取")}
</p>
) : !entries.length ? (
<p className="text-caption text-muted-foreground">目录为空。</p>
) : (
paged.items?.map((entry) =>
entry.type === "dir" ? (
<Button
key={entry.path}
variant="ghost"
className="w-full justify-start"
disabled={entry.escape}
onClick={() => setSelected({ root: selected.root, path: entry.path })}
>
<Folder />
<span className="truncate">{entry.name}</span>
</Button>
) : (
<p key={entry.path} className="flex items-center gap-2 px-3 py-2 text-caption text-muted-foreground">
<File className="h-4 w-4 shrink-0" />
<span className="truncate">{entry.name}</span>
</p>
),
)
)}
{entries.length > 0 || listing.hasNextPage ? <Pagination {...paged.pagination} /> : null}
</section>
</div>
{roots.error ? (
<p role="alert" className="text-destructive">
读取目录失败,请关闭后重试。
</p>
) : null}
<p className="break-all font-mono text-meta">
{root ? `${root.name} / ${selected?.path || "(根目录)"}` : "尚未选择"}
</p>
{!allowRoot && selected && !selected.path ? (
<p role="status" className="text-caption text-warning">
请选择子目录,或先新增来源配置,再整理根目录存量。
</p>
) : null}
<div className="flex justify-end gap-2">
<Button variant="outline" onClick={onClose}>
取消
</Button>
<Button
disabled={!root || !directorySelectionAllowed(selected, allowRoot) || listing.isPending || !!listing.error}
onClick={() => selected && directorySelectionAllowed(selected, allowRoot) && onSelect(selected)}
>
使用此目录
</Button>
</div>
</DialogContent>
</Dialog>
);
}
+12 -6
View File
@@ -854,7 +854,7 @@ function organize(body: {
season?: number;
episodes?: number[];
}[];
action: "copy" | "move";
action: "copy" | "move" | "in_place";
dryRun: boolean;
onExisting?: "skip" | "conflict" | "replace_with_verify";
naming?: "template" | "keep";
@@ -881,12 +881,15 @@ function organize(body: {
const e = it.episodes?.length ? `E${String(it.episodes[0]).padStart(2, "0")}` : "";
const orig = it.path.split("/").pop() ?? "";
const name = body.naming === "keep" ? orig : tv ? `${dirName} - ${s}${e}.${ext}` : `${dirName}.${ext}`;
const dst = tv
? `${libRoot}/${dirName}/Season ${String(it.season ?? 1).padStart(2, "0")}/${name}`
: `${libRoot}/${dirName}/${name}`;
const dst =
body.action === "in_place"
? `${state.roots.find((x) => x.id === it.root)?.hostPath}/${it.path}`
: tv
? `${libRoot}/${dirName}/Season ${String(it.season ?? 1).padStart(2, "0")}/${name}`
: `${libRoot}/${dirName}/${name}`;
const r = state.roots.find((x) => x.id === it.root);
const { node, parent } = find(it.root, it.path);
const exists = id === "e-dune";
const exists = body.action !== "in_place" && id === "e-dune";
if (exists && onExisting === "conflict") conflict = true;
const main = {
source: `${r?.hostPath}/${it.path}`,
@@ -915,7 +918,10 @@ function organize(body: {
.filter((c) => c !== node && !c.dir && c.name.startsWith(stem.slice(0, 16)) && /\.(srt|ass)$/.test(c.name))
.map((c) => ({
source: `${r?.hostPath}/${join(dirPath, c.name)}`,
target: dst.replace(/\.[^.]+$/, `.zh.${c.name.split(".").pop()}`),
target:
body.action === "in_place"
? `${r?.hostPath}/${join(dirPath, c.name)}`
: dst.replace(/\.[^.]+$/, `.zh.${c.name.split(".").pop()}`),
kind: "subtitle",
size: c.size,
action: "transfer" as const,