Merge branch 'meta2'

Co-Authored-By: Claude Fable 5.1 <[email protected]>

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
root committed 2026-09-30 18:40:42 +08:00
commit 6f5371be2d
23 files changed
+2615 -323

No files matched your search

+61 -1
View File
@@ -1,6 +1,9 @@
import { DEFAULT_SETTINGS } from "@umt/contracts";
import { toast } from "sonner";
import { useClearImageCache, useClearTmdbCache, useImageCache, useTmdbCache } from "~/api/cache.ts";
import { useEnrichStats } from "~/api/identity.ts";
import { DataTable } from "~/components/console/data-table.tsx";
import { ENRICH_SOURCE_KIND } from "~/components/library/labels.ts";
import { Button } from "~/components/ui/button.tsx";
import { errorMessage } from "~/lib/api.ts";
import { secretPatch } from "~/lib/secret.ts";
@@ -221,7 +224,14 @@ const IDENTITY_CARD: CardSpec = {
name: "identity.enrichDomains",
label: "补全可读取的网站",
kind: "textarea",
hint: "每行一个域名,含子域名;只放平台和百科类网站。已登记站点的域名一律不读",
hint: "每行一个域名,含子域名;只放平台和百科类网站。豆瓣只用搜索摘要,不读页面;robots.txt 不允许的页面不读。已登记站点的域名一律不读",
wide: true,
},
{
name: "identity.enrichSnippetAllSites",
label: "也用其它网站的搜索摘要",
kind: "switch",
hint: "短剧多半只有聚合站收录。打开后,白名单以外网站的搜索摘要也用来抽年份、集数、主演、简介(只看搜索引擎给的摘要,不打开这些网页)",
wide: true,
},
],
@@ -230,6 +240,7 @@ const IDENTITY_CARD: CardSpec = {
"identity.autoEnrich": s.identity.autoEnrich,
"identity.enrichDailyBudget": n(s.identity.enrichDailyBudget),
"identity.enrichDomains": s.identity.enrichDomains.join("\n"),
"identity.enrichSnippetAllSites": s.identity.enrichSnippetAllSites ?? true,
}),
toPatch: (v) => ({
identity: {
@@ -240,10 +251,59 @@ const IDENTITY_CARD: CardSpec = {
.split(/[\s,,]+/)
.map((d) => d.trim().toLowerCase())
.filter(Boolean),
enrichSnippetAllSites: v["identity.enrichSnippetAllSites"] === true,
},
}),
extra: () => <EnrichStatsTable />,
};
type StatRow = { kind: string; withResults: number; hits: number; rate: number | null };
/** 最近 30 天补全命中率(按来源类别,META-2) */
function EnrichStatsTable() {
const q = useEnrichStats(30);
const d = q.data;
return (
<div className="mb-3 space-y-2">
<p className="text-meta text-muted-foreground tabular-nums">
{d
? `最近 ${d.days} 天元数据补全 ${d.total} 次,出了建议 ${d.suggested} 次${d.tracked < d.total ? `;有来源明细的 ${d.tracked} 次` : ""}`
: "读取补全命中率…"}
</p>
{d && d.tracked > 0 ? (
<DataTable<StatRow>
rows={d.sources}
rowKey={(r) => r.kind}
empty={{ title: "还没有补全记录" }}
columns={[
{ key: "kind", header: "来源", cell: (r) => ENRICH_SOURCE_KIND[r.kind] ?? r.kind },
{
key: "withResults",
header: "有结果",
align: "right",
cell: (r) => <span className="tabular-nums">{r.withResults}</span>,
},
{
key: "hits",
header: "命中",
align: "right",
cell: (r) => <span className="tabular-nums">{r.hits}</span>,
},
{
key: "rate",
header: "命中率",
align: "right",
cell: (r) => (
<span className="tabular-nums">{r.rate === null ? "—" : `${Math.round(r.rate * 100)}%`}</span>
),
},
]}
/>
) : null}
</div>
);
}
export function MetadataSection() {
return (
<SettingsGate>