控制台导航最多两层(侧栏一项 = 一页,页内最多一层页签 / 分段);从列表打开的
记录改成列表页上的右侧抽屉,打开的记录写在 ?open=,刷新、分享、前进后退都能还原,
后退就是关抽屉。标准写在 docs/design/console-ia.md §9,ui-controls.md 引用。
- DetailSheet 加 xl 宽度、标题下操作行;抽屉里再开的 DetailSheet 在同一抽屉里换成子视图(返回 / Esc)
- record-sheet.tsx:useRecordSheet / RecordLink / useOpenRecord / recordPath / taskPath
- 整理记录、订阅、站点(含页签)、下载、日志任务改成抽屉;旧业务任务 / 下载任务 id 在任务抽屉里换算
- 回收站并进文件管理右侧视图(?view=trash);设置左栏只列分区
- 规则组、策略版本、媒体库未识别 / 外部身份、设置实例编辑走 ?open=
- 旧地址 /console/{organize,subscriptions,sites,downloads}/:id、/tasks/:id、/files/trash 跳到列表页抽屉
- 站内链接、铃铛、命令面板、任务时间线改拼新地址;冒烟按 ?open= 检查抽屉
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
258 lines
8.2 KiB
TypeScript
258 lines
8.2 KiB
TypeScript
import type {
|
|
ExternalIdentity,
|
|
IdentityCandidateReason,
|
|
IdentityCandidateStatus,
|
|
IdentityPoolItem,
|
|
IdentityStatus,
|
|
} from "@umt/contracts";
|
|
import { Fingerprint, Lock, SearchX } from "lucide-react";
|
|
import { useEffect, useState } from "react";
|
|
import { useExternalIdentities, useIdentityPool } from "~/api/identity.ts";
|
|
import { type DataColumn, DataTable } from "~/components/console/data-table.tsx";
|
|
import { FilterBar, FilterSelect } from "~/components/console/filter-bar.tsx";
|
|
import { useRecordSheet } from "~/components/console/record-sheet.tsx";
|
|
import { ExternalIdentitySheet, identityRef } from "~/components/library/identity-external-sheet.tsx";
|
|
import { PoolSheet, querySummary } from "~/components/library/identity-pool-sheet.tsx";
|
|
import {
|
|
EVIDENCE_LEVEL,
|
|
IDENTITY_STATUS,
|
|
opts,
|
|
POOL_REASON,
|
|
POOL_STATUS,
|
|
VERIFY_STATUS,
|
|
} from "~/components/library/labels.ts";
|
|
import { relTime, Tone } from "~/components/library/parts.tsx";
|
|
|
|
// 媒体概览的身份视图(原"身份与元数据"页,IA-3 并入 /console/library):待识别资源、外部身份。
|
|
// 未识别资源:点开详情选候选、手动指定或忽略(2026-10-06 起待处理中心取消,不再转去待处理)。
|
|
|
|
function useDebounced(v: string, ms = 250) {
|
|
const [d, setD] = useState(v);
|
|
useEffect(() => {
|
|
const t = setTimeout(() => setD(v), ms);
|
|
return () => clearTimeout(t);
|
|
}, [v, ms]);
|
|
return d;
|
|
}
|
|
|
|
export function PoolTab() {
|
|
const [q, setQ] = useState("");
|
|
const [status, setStatus] = useState("pending");
|
|
const [reason, setReason] = useState("");
|
|
const dq = useDebounced(q.trim());
|
|
const pool = useIdentityPool({
|
|
q: dq || undefined,
|
|
status: (status || undefined) as IdentityCandidateStatus | undefined,
|
|
reason: (reason || undefined) as IdentityCandidateReason | undefined,
|
|
});
|
|
// 记录抽屉(console-ia.md §9):?open=<id>
|
|
const sheet = useRecordSheet();
|
|
const openId = sheet.id;
|
|
const rows = pool.data?.pages.flatMap((p) => p.items);
|
|
const open = rows?.find((r) => r.id === openId) ?? null;
|
|
|
|
const columns: DataColumn<IdentityPoolItem>[] = [
|
|
{
|
|
key: "title",
|
|
header: "原始标题",
|
|
className: "max-w-0 w-full",
|
|
cell: (r) => (
|
|
<div className="min-w-0">
|
|
<p className="font-mono text-caption break-all text-foreground">{r.release.title}</p>
|
|
<p className="mt-0.5 truncate text-meta text-muted-foreground">
|
|
{r.release.subtitle ? `${r.release.subtitle} · ` : ""}解析:{querySummary(r.query)}
|
|
</p>
|
|
</div>
|
|
),
|
|
},
|
|
{
|
|
key: "reason",
|
|
header: "原因",
|
|
cell: (r) => (
|
|
<div className="flex flex-col items-start gap-1">
|
|
<Tone v={POOL_REASON[r.reason]} />
|
|
</div>
|
|
),
|
|
},
|
|
{
|
|
key: "cands",
|
|
header: "候选作品",
|
|
hideBelow: "sm",
|
|
align: "right",
|
|
cell: (r) => <span className="tabular-nums">{r.candidates.length}</span>,
|
|
},
|
|
{
|
|
key: "attempts",
|
|
header: "尝试",
|
|
hideBelow: "md",
|
|
cell: (r) => (
|
|
<span className="text-meta whitespace-nowrap text-muted-foreground">
|
|
{r.attempts} 次 · {relTime(r.lastAttemptAt)}
|
|
</span>
|
|
),
|
|
},
|
|
{
|
|
key: "next",
|
|
header: "下次复查",
|
|
hideBelow: "lg",
|
|
cell: (r) => (
|
|
<span className="text-meta whitespace-nowrap text-muted-foreground">
|
|
{r.status === "pending" ? (
|
|
r.nextReviewAt ? (
|
|
relTime(r.nextReviewAt)
|
|
) : (
|
|
"不自动复查"
|
|
)
|
|
) : (
|
|
<Tone v={POOL_STATUS[r.status]} />
|
|
)}
|
|
</span>
|
|
),
|
|
},
|
|
];
|
|
|
|
const filtered = !!q || status !== "pending" || !!reason;
|
|
return (
|
|
<>
|
|
<FilterBar
|
|
search={{ value: q, onChange: setQ, placeholder: "按原始标题 / 解析标题检索" }}
|
|
onReset={
|
|
filtered
|
|
? () => {
|
|
setQ("");
|
|
setStatus("pending");
|
|
setReason("");
|
|
}
|
|
: undefined
|
|
}
|
|
>
|
|
<FilterSelect label="状态" value={status} onChange={setStatus} options={opts(POOL_STATUS)} />
|
|
<FilterSelect label="原因" value={reason} onChange={setReason} options={opts(POOL_REASON)} />
|
|
</FilterBar>
|
|
<DataTable
|
|
paginationKey={JSON.stringify({ q: dq, status, reason })}
|
|
columns={columns}
|
|
rows={rows}
|
|
rowKey={(r) => r.id}
|
|
loading={pool.isPending}
|
|
error={pool.error}
|
|
onRetry={() => pool.refetch()}
|
|
onRowClick={(r) => sheet.open(r.id)}
|
|
selectedKey={openId}
|
|
empty={{
|
|
icon: SearchX,
|
|
title: filtered ? "没有符合条件的未识别资源" : "没有未识别资源",
|
|
description: "未命中订阅、证据不足或有冲突的资源。新增相近别名时会自动重试,也可以手动指定。",
|
|
}}
|
|
hasMore={pool.hasNextPage}
|
|
onLoadMore={() => pool.fetchNextPage()}
|
|
loadingMore={pool.isFetchingNextPage}
|
|
/>
|
|
<PoolSheet key={open?.id ?? "none"} item={open} onClose={sheet.close} />
|
|
</>
|
|
);
|
|
}
|
|
|
|
export function ExternalTab() {
|
|
const [provider, setProvider] = useState("");
|
|
const [status, setStatus] = useState("");
|
|
const list = useExternalIdentities({
|
|
provider: provider || undefined,
|
|
status: (status || undefined) as IdentityStatus | undefined,
|
|
});
|
|
// 记录抽屉(console-ia.md §9):?open=<id>
|
|
const sheet = useRecordSheet();
|
|
const openId = sheet.id;
|
|
const rows = list.data?.pages.flatMap((p) => p.items);
|
|
const open = rows?.find((r) => r.id === openId) ?? null;
|
|
|
|
const columns: DataColumn<ExternalIdentity>[] = [
|
|
{
|
|
key: "ref",
|
|
header: "外部身份",
|
|
cell: (r) => (
|
|
<span className="inline-flex items-center gap-1.5 font-mono text-caption break-all text-foreground">
|
|
{r.locked ? <Lock className="h-3 w-3 shrink-0 text-muted-foreground" aria-label="已锁定" /> : null}
|
|
{identityRef(r)}
|
|
</span>
|
|
),
|
|
},
|
|
{
|
|
key: "entity",
|
|
header: "作品",
|
|
hideBelow: "sm",
|
|
cell: (r) => (
|
|
<span className="line-clamp-1 text-caption text-foreground">
|
|
{r.mediaEntityTitle ?? <span className="text-muted-foreground">未关联</span>}
|
|
</span>
|
|
),
|
|
},
|
|
{ key: "status", header: "状态", cell: (r) => <Tone v={IDENTITY_STATUS[r.status]} /> },
|
|
{
|
|
key: "level",
|
|
header: "证据",
|
|
hideBelow: "sm",
|
|
cell: (r) => <span className="text-meta whitespace-nowrap">{EVIDENCE_LEVEL[r.evidenceLevel]}</span>,
|
|
},
|
|
{ key: "verify", header: "外部校验", hideBelow: "md", cell: (r) => <Tone v={VERIFY_STATUS[r.verifyStatus]} /> },
|
|
{
|
|
key: "rev",
|
|
header: "修订",
|
|
hideBelow: "lg",
|
|
align: "right",
|
|
cell: (r) => (
|
|
<span className="text-meta whitespace-nowrap text-muted-foreground tabular-nums">
|
|
r{r.revision} · {relTime(r.updatedAt)}
|
|
</span>
|
|
),
|
|
},
|
|
];
|
|
const filtered = !!provider || !!status;
|
|
return (
|
|
<>
|
|
<FilterBar
|
|
onReset={
|
|
filtered
|
|
? () => {
|
|
setProvider("");
|
|
setStatus("");
|
|
}
|
|
: undefined
|
|
}
|
|
>
|
|
<FilterSelect
|
|
label="来源"
|
|
value={provider}
|
|
onChange={setProvider}
|
|
options={[
|
|
{ value: "tmdb", label: "TMDB" },
|
|
{ value: "imdb", label: "IMDb" },
|
|
{ value: "tvdb", label: "TVDB" },
|
|
]}
|
|
/>
|
|
<FilterSelect label="状态" value={status} onChange={setStatus} options={opts(IDENTITY_STATUS)} />
|
|
</FilterBar>
|
|
<DataTable
|
|
paginationKey={JSON.stringify({ provider, status })}
|
|
columns={columns}
|
|
rows={rows}
|
|
rowKey={(r) => r.id}
|
|
loading={list.isPending}
|
|
error={list.error}
|
|
onRetry={() => list.refetch()}
|
|
onRowClick={(r) => sheet.open(r.id)}
|
|
selectedKey={openId}
|
|
empty={{
|
|
icon: Fingerprint,
|
|
title: "没有外部身份",
|
|
description: "没有外部编号的作品也能整理。",
|
|
}}
|
|
hasMore={list.hasNextPage}
|
|
onLoadMore={() => list.fetchNextPage()}
|
|
loadingMore={list.isFetchingNextPage}
|
|
/>
|
|
<ExternalIdentitySheet item={open} onClose={sheet.close} />
|
|
</>
|
|
);
|
|
}
|