Peach: Local-first video metadata scraper and media manager.
feat(feeds): 订阅源发现番号,建「未入库」的新作
longmeidaod3385eb50c6a
diff --git a/frontend/src/react/settings/configuration-page.tsx b/frontend/src/react/settings/configuration-page.tsxindex 04e18aa11..01b1ded19 100644--- a/frontend/src/react/settings/configuration-page.tsx+++ b/frontend/src/react/settings/configuration-page.tsx@@ -11,6 +11,7 @@ import { errorMessage } from '../../api';import type { ConfigurationGroupProps, ConfigurationProps } from '../bundle';import { Note } from '../components/note';import { CONFIGURATION_KEY, fetchConfiguration } from './configuration';+import { FeedSettings } from './feed-settings';import { GeneralSettings } from './general-settings';import { MaintenanceSettings } from './maintenance-settings';import { MediaSettings } from './media-settings';@@ -31,12 +32,13 @@ export function ConfigurationPage({ receipt, reopenTutorial }: ConfigurationProp);}const group: ConfigurationGroupProps = { data, receipt };- const general = Boolean(data.startup || data.entry_links);const network = Boolean(data.peach_proxy || data.access || data.tunnel);return (<div className="configpage">- {general ? <h2 className="configgroup">通用</h2> : null}- {general ? <GeneralSettings {...group} /> : null}+ {/* 「通用」这一组总有内容:订阅源不看这份配置快照,自己读 `/api/feeds`。它和上面那两节+ 装在同一个直接子节点里——遗留壳按 `.configgroup` 切它后面那一个兄弟节点。 */}+ <h2 className="configgroup">通用</h2>+ <div className="flex flex-col gap-6"><GeneralSettings {...group} /><FeedSettings /></div><h2 className="configgroup">媒体</h2><MediaSettings {...group} />{network ? <h2 className="configgroup">网络与访问</h2> : null}diff --git a/frontend/src/react/settings/feed-settings.tsx b/frontend/src/react/settings/feed-settings.tsxnew file mode 100644index 000000000..b1bca04b7--- /dev/null+++ b/frontend/src/react/settings/feed-settings.tsx@@ -0,0 +1,174 @@+/* 「订阅源」小节:增删、开关、上次拉取时间与错误(ADR-0042)。+ *+ * 数据不在 `/api/configuration` 那份快照里:订阅源有自己的写接口,增删开关之后要重取的+ * 只是这一节。自己收自己的状态,不进共用的 `QueryClient`——这一节是「通用」组里唯一+ * 不看配置快照的内容,而它的几个兄弟分区在用例里是脱离 Provider 单独挂的。+ *+ * 这一节只管「订阅什么、多久拉一次」。拉回来的新作在首页与人物页的「新作 · 未入库」里,+ * 不在设置里列——设置页列一遍就成了第二个入口,两处的已读状态会各说各话。 */+import { useCallback, useEffect, useState, type FormEvent } from 'react';+import { RiCloseLine } from '@remixicon/react';++import { SettingsRow } from '@/components/application/settings/settings-rows';+import { Button } from '@/components/base/buttons/button';+import { IconButton } from '@/components/base/buttons/icon-button';+import { Input } from '@/components/base/input/input';+import { Select, SelectItem } from '@/components/base/select/select';+import { Switch } from '@/components/base/switch/switch';++import { apiGet, apiSend, errorMessage } from '../../api';+import { Note } from '../components/note';+import { ErrorText, FieldLabel, Footer, Help, Rows, Section, Stack } from './section';+import { busyProps, useAction } from './use-action';++interface FeedSource {+ id: number;+ kind: string;+ kind_label: string;+ name: string;+ url: string;+ entity_name: string | null;+ enabled: boolean;+ interval_minutes: number;+ last_fetched_at: string | null;+ last_error: string | null;+ last_new_count: number;+ seen: number;+}++interface FeedsData {+ sources: FeedSource[];+ unread: number;+ kinds: { value: string; label: string }[];+ min_interval_minutes: number;+ max_interval_minutes: number;+}++/** 一行订阅源在名称下面那句话:上次什么时候拉的、拉到几条。没拉过就直说还没拉过。 */+function describe(source: FeedSource): string {+ const when = source.last_fetched_at+ ? `上次拉取 ${new Date(source.last_fetched_at).toLocaleString()}`+ : '还没拉过';+ const interval = source.interval_minutes >= 60+ ? `每 ${Math.round(source.interval_minutes / 60)} 小时一次`+ : `每 ${source.interval_minutes} 分钟一次`;+ return `${source.kind_label} · ${interval} · ${when} · 上次新增 ${source.last_new_count} 条`;+}++export function FeedSettings() {+ const [data, setData] = useState<FeedsData | null>(null);+ const [failure, setFailure] = useState('');+ /* 服务端是唯一真相:增删开关之后重取整份,不在前端按响应拼一份新的本地状态。+ 拉取间隔会被后端按上下限收窄,拼出来的那份和库里的从第一次保存起就不一样。 */+ const reload = useCallback(async (signal?: AbortSignal) => {+ try {+ const payload = await apiGet<FeedsData>('/api/feeds', signal);+ // 认不出的响应当没读到:没有 sources 的那份不是这一节的数据,画出来只会在+ // 第一次取长度时炸掉整页配置。+ if (Array.isArray(payload?.sources)) setData(payload);+ } catch (cause) {+ if (!signal?.aborted) setFailure(errorMessage(cause));+ }+ }, []);+ useEffect(() => {+ const controller = new AbortController();+ void reload(controller.signal);+ return () => controller.abort();+ }, [reload]);+ const kinds = data?.kinds ?? [];+ const [kind, setKind] = useState('');+ const [url, setUrl] = useState('');+ const [name, setName] = useState('');+ const [hours, setHours] = useState('6');+ const action = useAction();++ const add = (event: FormEvent<HTMLFormElement>) => {+ event.preventDefault();+ const minutes = Math.round(Number(hours) * 60);+ void action.run('add', (signal) => apiSend('/api/feeds/source', {+ action: 'add', kind: kind || kinds[0]?.value, url: url.trim(), name: name.trim(),+ interval_minutes: Number.isFinite(minutes) ? minutes : undefined,+ }, 'POST', signal), () => {+ setUrl('');+ setName('');+ void reload();+ });+ };++ const toggle = (source: FeedSource, enabled: boolean) => {+ void action.run(`enabled-${source.id}`, (signal) => apiSend('/api/feeds/source',+ { action: 'enabled', id: source.id, enabled }, 'POST', signal), () => void reload());+ };++ const remove = (source: FeedSource) => {+ void action.run(`remove-${source.id}`, (signal) => apiSend('/api/feeds/source',+ { action: 'remove', id: source.id }, 'POST', signal), () => void reload());+ };++ // 立即拉取走的是和定时同一条路,只是把到期判断换成「全部启用的源」。+ const check = () => {+ void action.run('check', (signal) => apiSend('/api/feeds/check', { all: true }, 'POST', signal),+ () => void reload());+ };++ if (!data) {+ return (+ <Section title="订阅源">+ <Stack>+ {failure+ ? <Note tone="error" title="打不开订阅源">{failure}</Note>+ : <Help>正在读订阅源。</Help>}+ </Stack>+ </Section>+ );+ }++ return (+ <Section title="订阅源" onSubmit={add}>+ {data.sources.length ? (+ <Rows>+ {data.sources.map((source) => (+ <SettingsRow key={source.id} label={source.name || source.url} description={describe(source)}>+ <div className="flex items-center gap-1">+ <Switch aria-label={`启用 ${source.name || source.url}`} isSelected={source.enabled}+ onChange={(enabled) => toggle(source, enabled)} />+ <IconButton icon={RiCloseLine} aria-label={`移除 ${source.name || source.url}`}+ onClick={() => remove(source)} {...busyProps(action.busy === `remove-${source.id}`)} />+ </div>+ </SettingsRow>+ ))}+ </Rows>+ ) : null}+ <Stack divided={data.sources.length > 0}>+ {/* 拉不动的源各自把原因摆在自己那一行下面:一条源坏掉不该让整节看起来都坏了。 */}+ {data.sources.filter((source) => source.last_error).map((source) => (+ <Note key={source.id} tone="error" title={`${source.name || source.url} 拉取失败`}>+ {source.last_error}+ </Note>+ ))}+ <div className="inline-grid grid-cols-1 gap-3 @lg:grid-cols-2">+ <div className="flex flex-col gap-1.5">+ <FieldLabel>来源类型</FieldLabel>+ <Select aria-label="来源类型" selectedKey={kind || kinds[0]?.value}+ onSelectionChange={(key) => { if (key !== null) setKind(String(key)); }}>+ {kinds.map((item) => (+ <SelectItem key={item.value} id={item.value} textValue={item.label}>{item.label}</SelectItem>+ ))}+ </Select>+ </div>+ <Input label="拉取间隔(小时)" inputMode="decimal" value={hours} onChange={setHours}+ hint={`最短 ${data.min_interval_minutes} 分钟。`} />+ </div>+ <Input label="订阅地址" placeholder="https://" value={url} onChange={setUrl}+ hint="RSS/Atom 的地址,或 JavDB 的演员页地址。只收 HTTPS。" />+ <Input label="名称" maxLength={80} placeholder="不填就用地址" value={name} onChange={setName} />+ {action.error ? <ErrorText>{action.error}</ErrorText> : null}+ <Help>订阅只发现番号、建一条「未入库」的新作,不下载任何文件。新作在首页和人物页里看。</Help>+ </Stack>+ <Footer status={data.unread ? `有 ${data.unread} 条新作还没看` : '新作都看过了'}>+ <Button onClick={check} {...busyProps(action.busy === 'check')}>立即拉取</Button>+ <Button type="submit" {...busyProps(action.busy === 'add')}>添加订阅</Button>+ </Footer>+ </Section>+ );+}diff --git a/frontend/src/react/settings/general-settings.tsx b/frontend/src/react/settings/general-settings.tsxindex cd428b51e..3408b39b2 100644--- a/frontend/src/react/settings/general-settings.tsx+++ b/frontend/src/react/settings/general-settings.tsx@@ -1,4 +1,5 @@-/* 「通用」分组:开机自启与桌面快捷方式,加上人物资料页那三枚外部入口。 */+/* 「通用」分组里看配置快照的那两节:开机自启与桌面快捷方式,人物资料页那三枚外部入口。+ * 同一组里还有「订阅源」,它读自己的端点,由 `configuration-page.tsx` 排在这两节后面。 */import { useState, type FormEvent } from 'react';import { SettingsRow } from '@/components/application/settings/settings-rows';diff --git a/frontend/test/react/configuration.test.tsx b/frontend/test/react/configuration.test.tsxindex d1ecf21e6..5448518ba 100644--- a/frontend/test/react/configuration.test.tsx+++ b/frontend/test/react/configuration.test.tsx@@ -65,9 +65,10 @@ it('四个分区各有小标题,标题和分区交替排在 `.configpage` 的.toEqual([true, false, true, false, true, false, true, false]);});+/* 「通用」不在这条规则里:那一组装着订阅源,而订阅源不看配置快照,哪份配置下它都有内容。 */it('没有内容的组连标题一起省略', async () => {const host = await open(data());- expect(groups(host)).toEqual(['媒体', '更新与维护']);+ expect(groups(host)).toEqual(['通用', '媒体', '更新与维护']);expect(host.textContent).not.toContain('开机自启');expect(host.textContent).not.toContain('Peach 代理');});diff --git a/migrations/0034_feed_discovery.sql b/migrations/0034_feed_discovery.sqlnew file mode 100644index 000000000..adaa24d3f--- /dev/null+++ b/migrations/0034_feed_discovery.sql@@ -0,0 +1,99 @@+--+-- 番号发现源:订阅、源内已见条目、未入库的番号壳(ADR-0042)。+--+-- 为什么这么改:「关注的女优出新片了」这件事现在只能靠人自己去外面看。刮削链是被动的,+-- 先有文件才有番号;关注那一套盯的是创作者的图文与视频帖,不认番号。Feed 补上的正是+-- 番号这一侧的「新作」概念,产物只有番号,不下载、不碰媒体文件。+--+-- 为什么不在 `asset` 上加一个「文件缺失」状态列:`asset` 的语义是「盘上有这个文件」,+-- 扫描按 `last_seen` 落后表达文件消失、资源同步现场 stat 并清掉真不在的行、整理按+-- `asset.path` 搬文件、抽帧按路径开 FFmpeg、馆藏统计数的是这张表的行数。塞一行没有文件+-- 的记录进去,等于要在这五处各加一个例外,而每处例外的判据都不一样。分成两张表之后,+-- 「不进整理、不进抽帧、不算馆藏」由表结构保证,不靠纪律。+--+-- `feed_discovery` 不登记进 `web_batch.ASSET_REFERENCE_TABLES`:那张名单是「物理删除资产时+-- 要清的引用」,而发现记录不引用 `asset`,两者只按番号在查询时对上。++-- 一条订阅。`kind` 决定怎么解析:`rss` 是原生 RSS/Atom,`javdb-actor` 是把 JavDB 演员页+-- 当伪 Feed 抓(取证见 `docs/SOURCING.md`「番号发现源(Feed)」)。+-- `entity_id` 只有按人绑定的源才有,它让演员页发现的新作直接落到那个人的页面上。+-- `etag` / `last_modified` 是整份文档那一层去重,**不能当作可依赖的东西**:sukebei 两个+-- 响应头一个都不给,那一层对它完全不生效。+CREATE TABLE feed_source (+ id INTEGER PRIMARY KEY,+ kind TEXT NOT NULL,+ name TEXT NOT NULL DEFAULT '',+ url TEXT NOT NULL,+ entity_id INTEGER REFERENCES entity(id) ON DELETE SET NULL,+ enabled INTEGER NOT NULL DEFAULT 1,+ interval_minutes INTEGER NOT NULL DEFAULT 360,+ etag TEXT,+ last_modified TEXT,+ next_fetch_at TEXT,+ last_fetched_at TEXT,+ last_error TEXT,+ last_seen_count INTEGER NOT NULL DEFAULT 0,+ last_new_count INTEGER NOT NULL DEFAULT 0,+ created_at TEXT NOT NULL,+ UNIQUE(url)+);++-- 到期扫描只看启用的源,部分索引因此只覆盖它们。+CREATE INDEX idx_feed_source_due ON feed_source(next_fetch_at) WHERE enabled=1;++-- 去重第一层:这个源的这一条见过没有。`item_key` 按 guid → link → title 回退。+-- 解不出番号的条目照样记一行(`code` 为空),否则每轮都会对同一个垃圾标题重试一遍。+CREATE TABLE feed_item (+ id INTEGER PRIMARY KEY,+ source_id INTEGER NOT NULL REFERENCES feed_source(id) ON DELETE CASCADE,+ item_key TEXT NOT NULL,+ code TEXT,+ title TEXT,+ link TEXT,+ published_at TEXT,+ first_seen TEXT NOT NULL,+ UNIQUE(source_id, item_key)+);++CREATE INDEX idx_feed_item_code ON feed_item(code) WHERE code IS NOT NULL;++-- 去重第二层:这个番号需不需要一个壳。`code` 全表唯一,建壳前还要先查 `asset`——+-- 已入库的番号不建。两个源同时报同一个番号只会有一个壳,但两条 `feed_item` 都留着,+-- 因为它们各自是各自源的去重真值。+--+-- `read_at` / `ignored_at` 彼此正交,也都不参与唯一约束:忽略保留去重关系,后续拉取+-- 不会重建,这正是忽略的意义;取消忽略只恢复可见性,不自动派刮削。+--+-- 标题、封面地址、发行日、厂牌与女优名是刮削后继写回来的展示值,不是真相字段:+-- 壳上的每个值都只是「某个来源这么说」,用户复核的时机是文件真的到手、建成 `asset` 之后。+CREATE TABLE feed_discovery (+ id INTEGER PRIMARY KEY,+ code TEXT NOT NULL,+ source_id INTEGER REFERENCES feed_source(id) ON DELETE SET NULL,+ title TEXT,+ link TEXT,+ cover_url TEXT,+ release_date TEXT,+ studio TEXT,+ performers TEXT,+ scraped_at TEXT,+ scrape_error TEXT,+ discovered_at TEXT NOT NULL,+ read_at TEXT,+ ignored_at TEXT,+ UNIQUE(code)+);++-- 首页那一块按发现时间倒序取未忽略的行。+CREATE INDEX idx_feed_discovery_recent ON feed_discovery(discovered_at) WHERE ignored_at IS NULL;++-- 壳与实体的关联:按人绑定的源直接带上,其余由刮削取到女优名之后匹配。+-- 人物页那一块按 `entity_id` 取,所以索引把它放在前面。+CREATE TABLE feed_discovery_entity (+ discovery_id INTEGER NOT NULL REFERENCES feed_discovery(id) ON DELETE CASCADE,+ entity_id INTEGER NOT NULL REFERENCES entity(id) ON DELETE CASCADE,+ PRIMARY KEY(discovery_id, entity_id)+);++CREATE INDEX idx_feed_discovery_entity_entity+ ON feed_discovery_entity(entity_id, discovery_id);diff --git a/scripts/test_runner.py b/scripts/test_runner.pyindex 7f45f6737..36ae9e9aa 100644--- a/scripts/test_runner.py+++ b/scripts/test_runner.py@@ -39,6 +39,7 @@ SCOPES: dict[str, tuple[str, ...]] = {"test_migrations.py","test_review_mirror.py", "test_rm_web.py","test_entity_link_install.py", "test_web_links.py", "test_entry_links.py",+ "test_feeds.py", "test_feeds_web.py","test_link_marks.py", "test_site_icons.py", "test_site_logos.py","test_avatar_face.py","test_brand_marks.py", "test_studio_icon_variants.py",@@ -213,6 +214,10 @@ AUTO_SCOPE_PREFIXES: tuple[tuple[str, str | tuple[str, ...]], ...] = (("scripts/vendor_web_dependencies.mjs", ("web", "tooling")),("scripts/audit_video_endcards.py", ("media", "tooling")),("scripts/setup_macos_port80.sh", ("sync", "tooling")),+ # 订阅源的解析与建壳验在 `test_feeds*.py`,两份都登记在 catalog:壳的边界是+ # 「它不是 asset」,看得住这条的是目录域那批测试。+ ("src/peach/feeds.py", "catalog"),+ ("src/peach/feed_followup.py", "catalog"),("src/peach/follow", "follow"),("src/peach/fanbox.py", "follow"),("src/peach/web_follow.py", "follow"),diff --git a/src/peach/api.py b/src/peach/api.pyindex c01922a03..b687163e8 100644--- a/src/peach/api.py+++ b/src/peach/api.py@@ -31,12 +31,12 @@ from fastapi.staticfiles import StaticFilesfrom starlette.exceptions import HTTPException as StarletteHTTPExceptionfrom starlette.middleware.gzip import DEFAULT_EXCLUDED_CONTENT_TYPES, GZipMiddleware-from . import __version__, tunnel, web_contract, web_follow+from . import __version__, feeds, tunnel, web_contract, web_feeds, web_followfrom . import routes_api, routes_auth, routes_configuration, routes_media, routes_pagesfrom .buildinfo import frozen_buildfrom .config import LOCATION_ROOT_DECLARATIONS, PeachSettingsfrom .ffmpeg import FFmpegResolver-from .follow_scheduler import FollowUpdateScheduler+from .follow_scheduler import FEED_JOB_ID, FollowScheduleConfig, FollowUpdateSchedulerfrom .follow_covers import FollowCoverServicefrom .follow_stream import FollowMediaResolverfrom .http import HttpxTransport@@ -228,6 +228,20 @@ def create_app(available=_writer(sync),)contract.follow_scheduler = follow_scheduler+ # 订阅源拉取(ADR-0042)用同一个调度实现,只换 job id、状态文件与默认间隔。+ # 默认 6 小时:两类可用来源一天更新几十条,比这更密只是把 JavDB 的配额花在+ # 一张没变的页面上。+ feed_scheduler = FollowUpdateScheduler(+ settings.follow_state_root,+ lambda: web_feeds.w_feed_check(contract, {"automatic": True}),+ available=_writer(sync),+ job_id=FEED_JOB_ID,+ filename="feed-schedule.json",+ default=FollowScheduleConfig(enabled=True,+ interval_minutes=feeds.DEFAULT_INTERVAL_MINUTES),+ unavailable_message="订阅源拉取只在写入端可用",+ )+ contract.feed_scheduler = feed_schedulercontract.header_repairs = header_repairscontract.transcode_service = transcode_service# 只读端不写任务中心:`task_run` 也在账本里,reader 往里写会造成无法自动合并的@@ -264,6 +278,7 @@ def create_app(# 不要在事件循环里卡住整条服务的启动。await asyncio.to_thread(_start_tunnel, settings, tunnel_manager)follow_scheduler.start()+ feed_scheduler.start()automatic_updates.start()push_discovery.start()warmup = asyncio.create_task(warm_startup_entries())@@ -278,6 +293,7 @@ def create_app(finally:warmup.cancel()follow_scheduler.stop()+ feed_scheduler.stop()automatic_updates.stop()push_discovery.stop()# 死链检查和资源对账的后台线程是 daemon,本来挡不住进程退出;这里显式收diff --git a/src/peach/feed_followup.py b/src/peach/feed_followup.pynew file mode 100644index 000000000..c139b15bf--- /dev/null+++ b/src/peach/feed_followup.py@@ -0,0 +1,131 @@+"""给 Feed 发现的番号取一份资料(ADR-0042 第六条)。++拉取只解出番号,壳上除了番号什么都没有——没有标题就没法在页面上认出这是哪一部。+这条后继把标题、女优、厂牌、发行日与封面地址取回来写进壳。++**不复用 `process_library`**:那条路以 `asset` 行为单位、要写候选 CSV、要按字段优先级链+结算到真相字段,而壳没有真相字段可写。壳上的每个值都只是「某个来源这么说」,用户复核+的时机是文件真的到手、建成 `asset` 之后。所以这里只借来源链本身+(`metadata_routes`)和发请求那一层(`library_processing.LibraryMetadataProvider`),+不借结算。++幂等(ADR-0040 第六条要求):重跑一次只是把同样的值再写一遍;壳已经不在了就当场返回。+"""+from __future__ import annotations++from . import feeds, metadata_routes+from .followups import Followup, FollowupType, register+from .metadata import extract_peach_fields++TASK_KEY = "feed-scrape"+TASK_LABEL = "取新作资料"++#: 一条资料够用就停。四个标量都拿到就不再问下一家——Feed 是后台跑的,+#: 多问一家换来的是配额,而壳上的值本来就不是真相字段。+WANTED = ("title", "performers", "studio", "release_date")+++def followup_key(code: str) -> str:+ return f"{TASK_KEY}:{code}"+++def parse_key(key: str) -> str:+ prefix, _, code = str(key).partition(":")+ if prefix != TASK_KEY or not code:+ raise ValueError(f"认不出这条取资料后继:{key}")+ return code+++def plan(codes) -> list[Followup]:+ """一批新发现的番号,一个一条后继。"""+ return [Followup(key=followup_key(code), task_key=TASK_KEY,+ label=f"{TASK_LABEL}:{code}") for code in codes]+++def _cover(payload: dict) -> str | None:+ for field in ("cover_url", "cover"):+ value = str(payload.get(field) or "").strip()+ if value:+ return value+ urls = payload.get("cover_urls")+ if isinstance(urls, list):+ for value in urls:+ text = str(value or "").strip()+ if text:+ return text+ return None+++def collect(provider, code: str) -> tuple[dict, str | None]:+ """按番号问来源链,返回 (字段, 封面地址)。++ 问哪几家由 `metadata_routes` 决定,与刮削链同一份判据;这里没有本机证据可给,+ 所以只传番号本身。一家都没给就抛——调用方把原因写进壳的 `scrape_error`,+ 页面上那一行因此能说清是「还没取」还是「取不到」。+ """+ chain = metadata_routes.route_for_code(code)+ found = provider.community(+ code, route=metadata_routes.community_route(code))+ fields: dict[str, object] = {}+ cover: str | None = None+ for _source, payload in found:+ if not isinstance(payload, dict):+ continue+ cover = cover or _cover(payload)+ for name, item in extract_peach_fields(payload).items():+ if name in WANTED and name not in fields:+ fields[name] = item.get("value")+ if all(name in fields for name in WANTED):+ break+ if not fields and cover is None:+ raise ValueError(f"来源链 {'、'.join(chain)} 上都没有这个番号的资料")+ return fields, cover+++def _performer_names(value: object) -> list[str]:+ if isinstance(value, list):+ return [str(item.get("name") or "") if isinstance(item, dict) else str(item)+ for item in value]+ return []+++def run(contract, key: str, handle) -> dict:+ """跑一条取资料后继。返回的摘要就是活动页上那一行。"""+ from .library_processing import LibraryMetadataProvider++ code = parse_key(key)+ with contract.database.read_connection() as connection:+ row = connection.execute(+ "SELECT id,title FROM feed_discovery WHERE code=?", (code,)).fetchone()+ if row is None:+ # 壳被删了,或者这个番号这中间已经入库。两种都不该再取一遍。+ return {"outcome": "这条新作已经不在了"}+ handle.progress(label=f"{TASK_LABEL}:{code}", throttle=0)+ provider = LibraryMetadataProvider(contract.follow_secrets_root)+ try:+ fields, cover = collect(provider, code)+ except Exception as error: # noqa: BLE001 - 原因要写到壳上给人看+ with contract.database.write_transaction() as connection:+ connection.execute(+ "UPDATE feed_discovery SET scrape_error=?,scraped_at=? WHERE id=?",+ (str(error), feeds.stamp(), int(row["id"])))+ return {"code": code, "outcome": "资料未取得", "error": str(error)}+ names = _performer_names(fields.get("performers"))+ with contract.database.write_transaction() as connection:+ connection.execute(+ "UPDATE feed_discovery SET title=COALESCE(?,title),cover_url=COALESCE(?,cover_url),"+ "studio=COALESCE(?,studio),release_date=COALESCE(?,release_date),"+ "performers=?,scrape_error=NULL,scraped_at=? WHERE id=?",+ (fields.get("title") or None, cover, fields.get("studio") or None,+ fields.get("release_date") or None, "、".join(name for name in names if name) or None,+ feeds.stamp(), int(row["id"])))+ for entity_id in feeds.match_performers(connection, names):+ feeds.link_entity(connection, int(row["id"]), entity_id)+ contract.cache_bust()+ return {"code": code, "outcome": "已取得", "performers": len(names),+ "cover": bool(cover)}+++#: 写账本:壳与实体关联都在 `ledger.db` 里,所以它走串行那条通道。+TYPE = register(FollowupType(task_key=TASK_KEY, label=TASK_LABEL,+ writes_ledger=True, run=run))diff --git a/src/peach/feeds.py b/src/peach/feeds.pynew file mode 100644index 000000000..576ce77f0--- /dev/null+++ b/src/peach/feeds.py@@ -0,0 +1,448 @@+"""番号发现源:订阅拉取、条目解析、未入库的番号壳(ADR-0042)。++Feed 只回答一个问题——最近出了哪些番号。一次拉取的全部产物是一条「这个源见过这个条目」+的记录和一条「这个番号还没入库」的记录;不下载种子、不下载 enclosure、不建目录、+不碰任何媒体文件。++解析用标准库 `xml.etree`,不为这件事引 feedparser:这里只需要 RSS 2.0 与 Atom 里的四个+字段,而多一个依赖要一直跟着升级和审计。代价是日期格式与命名空间得自己认,都在本模块里。++**解析只吃已下载的字节**,地址由调用方自己取(`peach.http` 的 transport 加主机限流)。+把地址交给一个会自己发 HTTP 的解析器,等于绕过项目的代理、限流、超时与预算闸门。+"""+from __future__ import annotations++import re+import sqlite3+from dataclasses import dataclass+from datetime import datetime, timedelta, timezone+from email.utils import parsedate_to_datetime+from urllib.parse import urljoin+from xml.etree import ElementTree++from .catalog_rules import normalise_code_key, release_code_from_text+from .entities import normalize_entity_name++#: 原生 RSS/Atom。+KIND_RSS = "rss"+#: JavDB 演员页当伪 Feed 抓。它按发行日排在前面,所以「还没发行的作品」会先出现。+KIND_JAVDB_ACTOR = "javdb-actor"+KINDS = (KIND_RSS, KIND_JAVDB_ACTOR)++KIND_LABELS = {KIND_RSS: "RSS / Atom", KIND_JAVDB_ACTOR: "JavDB 演员页"}++#: 拉取间隔的上下界。下界 30 分钟不是性能考虑:JavDB 按出口 IP 计配额,比这更密只会+#: 把配额花在一个一天才更新几条的页面上。+MIN_INTERVAL_MINUTES = 30+MAX_INTERVAL_MINUTES = 7 * 24 * 60+DEFAULT_INTERVAL_MINUTES = 360++#: 一次拉取最多解析多少条。源正常一页几十条,异常的那种(被替换成别的页面、+#: 被镜像站塞进整站索引)会给出几千条,那不该变成几千个壳。+MAX_ENTRIES = 200++#: 一轮拉取最多派多少条刮削后继。真正的上限由 `task_runs.MAX_FOLLOWUPS` 判,+#: 这里先截一刀是为了让第一次订阅不至于把整页历史都排成任务。+MAX_NEW_PER_POLL = 20++_ATOM = "{http://www.w3.org/2005/Atom}"++#: 切词元用的分隔符。标题里的番号被中文剧情简介夹着,整段丢给+#: `release_code_from_text` 认不出来(2026-09-22 实测 sukebei 75 条里只认出 3 条)。+_TOKEN = re.compile(r"[^\s\[\]()()【】{}、,,/|_+]+")++#: JavDB 演员页的一部作品:`/v/<id>` 是条目身份,`<strong>` 里是干净的番号,+#: `.meta` 是发行日。固件照抓回来的那份 HTML 写,不按记忆重画。+_JAVDB_BOX = re.compile(+ r'<a href="(?P<href>/v/[A-Za-z0-9]+)" class="box"'+ r'.*?<div class="video-title"><strong>(?P<code>[^<]*)</strong>(?P<title>.*?)</div>'+ r'.*?<div class="meta">\s*(?P<date>\d{4}-\d{2}-\d{2})',+ re.S)+_TAGS = re.compile(r"<[^>]+>")+++def stamp(moment: datetime | None = None) -> str:+ """ISO-8601 UTC 文本,与 `task_run`、`entity` 同一种写法。"""+ return (moment or datetime.now(timezone.utc)).astimezone(+ timezone.utc).isoformat(timespec="milliseconds").replace("+00:00", "Z")+++def scan_code(text: str | None) -> str | None:+ """从一段文本里找出番号:整段先试一次,不成再逐词元试。++ 番号的判据一个字都不新写,全部转给 `catalog_rules.release_code_from_text`——+ 两份实现漂移会产生两个封面缓存键,那是 `catalog_rules` 自己注释里记着的旧伤。+ 这里加的只是「标题里夹着简介时也要能找到」这一层。+ """+ if not text:+ return None+ whole = release_code_from_text(text)+ if whole:+ return whole+ for token in _TOKEN.findall(str(text)):+ found = release_code_from_text(token)+ if found:+ return found+ return None+++@dataclass(frozen=True)+class FeedEntry:+ """一条已解析的条目。`item_key` 是这个源内部的去重真值。"""++ item_key: str+ title: str+ link: str | None = None+ published_at: str | None = None++ @property+ def code(self) -> str | None:+ return scan_code(self.title) or None+++@dataclass(frozen=True)+class ParsedFeed:+ title: str | None+ entries: tuple[FeedEntry, ...]+++def _text(node, *paths: str) -> str | None:+ for path in paths:+ value = node.findtext(path)+ if isinstance(value, str) and value.strip():+ return value.strip()+ return None+++def _as_utc(moment: datetime) -> str:+ """没带时区的时间按 UTC 读,不按本机时区。++ 两种来源都会给出这种值:RSS 的 `-0000` 按 RFC 5322 表示「时区未知」,+ `parsedate_to_datetime` 于是返回 naive;JavDB 的 `.meta` 只有一个日期。+ naive 值交给 `astimezone` 会被当成本机时间,于是同一份 feed 在 UTC+8 的机器上+ 整体前移八小时——发行日 2026-10-20 变成 10-19,而排序和「这一天发了什么」都按它算。+ """+ return stamp(moment if moment.tzinfo is not None+ else moment.replace(tzinfo=timezone.utc))+++def _published(value: str | None) -> str | None:+ """RSS 的 RFC 822 与 Atom 的 ISO-8601 都认,认不出就当没有。++ 发布时间是排序真值:拿不到它才回退到首次见到的时间。把认不出的日期当成「现在」+ 会让一整页历史条目全部挤在同一秒,那之后就再也分不出先后了。+ """+ if not value:+ return None+ raw = value.strip()+ try:+ return _as_utc(parsedate_to_datetime(raw))+ except (TypeError, ValueError):+ pass+ try:+ return _as_utc(datetime.fromisoformat(raw.replace("Z", "+00:00")))+ except ValueError:+ return None+++def parse_feed(body: bytes) -> ParsedFeed | None:+ """RSS 2.0 或 Atom 的字节 → 条目。不是 feed 时返回 None。++ 条目为空但文档本身合法不算失败:源这一刻确实没有新东西。+ """+ if not body or not body.strip():+ return None+ try:+ root = ElementTree.fromstring(body)+ except ElementTree.ParseError:+ return None+ tag = root.tag.split("}")[-1]+ rows: list[FeedEntry] = []+ if tag == "rss":+ channel = root.find("channel")+ if channel is None:+ return None+ for item in channel.findall("item")[:MAX_ENTRIES]:+ title = _text(item, "title") or ""+ link = _text(item, "link")+ key = _text(item, "guid") or link or title+ if not key:+ continue+ rows.append(FeedEntry(key, title, link,+ _published(_text(item, "pubDate"))))+ return ParsedFeed(_text(channel, "title"), tuple(rows))+ if tag == "feed":+ for item in root.findall(f"{_ATOM}entry")[:MAX_ENTRIES]:+ title = _text(item, f"{_ATOM}title") or ""+ anchor = item.find(f"{_ATOM}link")+ link = anchor.get("href") if anchor is not None else None+ key = _text(item, f"{_ATOM}id") or link or title+ if not key:+ continue+ rows.append(FeedEntry(key, title, link,+ _published(_text(item, f"{_ATOM}published",+ f"{_ATOM}updated"))))+ return ParsedFeed(_text(root, f"{_ATOM}title"), tuple(rows))+ return None+++def parse_javdb_actor(html: str, base_url: str) -> ParsedFeed | None:+ """JavDB 演员页 → 条目。一条作品都解不出时返回 None。++ 解不出不等于这个人没作品:同一轮里带查询串的地址会回一份 27 KB、一条作品都没有的+ 页面(2026-09-22 实测),而不带参数的仍是 78 KB 的完整页。所以这种情况按拉取失败+ 报出来,而不是当成「这次没有新作」——后者会把一个坏掉的源伪装成安静的源。+ """+ if not html:+ return None+ rows: list[FeedEntry] = []+ for found in list(_JAVDB_BOX.finditer(html))[:MAX_ENTRIES]:+ href = found.group("href")+ code = found.group("code").strip()+ tail = _TAGS.sub("", found.group("title")).strip()+ title = f"{code} {tail}".strip() if code else tail+ rows.append(FeedEntry(href, title, urljoin(base_url, href),+ _published(found.group("date"))))+ if not rows:+ return None+ return ParsedFeed(None, tuple(rows))+++def parse(kind: str, body: bytes, url: str) -> ParsedFeed | None:+ if kind == KIND_JAVDB_ACTOR:+ return parse_javdb_actor(body.decode("utf-8", "replace"), url)+ return parse_feed(body)+++# -- 订阅 ------------------------------------------------------------------+++def normalize_url(value: object) -> str:+ """订阅地址只收 HTTPS。++ 明文地址在这里没有可用的场景:两类可用来源都是 HTTPS,而 Feed 拉回来的东西会直接+ 变成用户看见的新作——中途被改写的内容没有任何一步会被察觉。地址解析到内网的那一层+ 由 `http.public_https_url` 在真正发请求时挡住。+ """+ url = str(value or "").strip()+ if not url.startswith("https://"):+ raise ValueError("订阅地址必须以 https:// 开头")+ return url+++def normalize_interval(value: object) -> int:+ try:+ minutes = int(value)+ except (TypeError, ValueError) as error:+ raise ValueError("拉取间隔必须是整数分钟") from error+ if not MIN_INTERVAL_MINUTES <= minutes <= MAX_INTERVAL_MINUTES:+ raise ValueError(+ f"拉取间隔必须在 {MIN_INTERVAL_MINUTES} 到 {MAX_INTERVAL_MINUTES} 分钟之间")+ return minutes+++def add_source(connection: sqlite3.Connection, *, kind: str, url: str, name: str = "",+ entity_id: int | None = None,+ interval_minutes: int = DEFAULT_INTERVAL_MINUTES,+ enabled: bool = True) -> int:+ """登记一条订阅。地址重复直接拒绝——同一个源订两遍只会让同一条新作出现两次。"""+ if kind not in KINDS:+ raise ValueError(f"认不出这种订阅源:{kind}")+ address = normalize_url(url)+ minutes = normalize_interval(interval_minutes)+ if connection.execute("SELECT 1 FROM feed_source WHERE url=?", (address,)).fetchone():+ raise ValueError("这个订阅地址已经在列表里了")+ cursor = connection.execute(+ "INSERT INTO feed_source(kind,name,url,entity_id,enabled,interval_minutes,"+ "created_at) VALUES(?,?,?,?,?,?,?)",+ (kind, str(name or "").strip(), address, entity_id, 1 if enabled else 0,+ minutes, stamp()))+ return int(cursor.lastrowid)+++def remove_source(connection: sqlite3.Connection, source_id: int) -> None:+ connection.execute("DELETE FROM feed_source WHERE id=?", (int(source_id),))+++def set_enabled(connection: sqlite3.Connection, source_id: int, enabled: bool) -> None:+ connection.execute("UPDATE feed_source SET enabled=? WHERE id=?",+ (1 if enabled else 0, int(source_id)))+++def sources(connection: sqlite3.Connection) -> list[dict]:+ rows = connection.execute(+ "SELECT s.*, e.canonical_name AS entity_name,"+ " (SELECT count(*) FROM feed_item i WHERE i.source_id=s.id) AS seen"+ " FROM feed_source s LEFT JOIN entity e ON e.id=s.entity_id"+ " ORDER BY s.kind, s.name, s.id").fetchall()+ return [{+ "id": int(row["id"]),+ "kind": row["kind"],+ "kind_label": KIND_LABELS.get(row["kind"], row["kind"]),+ "name": row["name"] or row["entity_name"] or "",+ "url": row["url"],+ "entity_id": row["entity_id"],+ "entity_name": row["entity_name"],+ "enabled": bool(row["enabled"]),+ "interval_minutes": int(row["interval_minutes"]),+ "last_fetched_at": row["last_fetched_at"],+ "next_fetch_at": row["next_fetch_at"],+ "last_error": row["last_error"],+ "last_seen_count": int(row["last_seen_count"]),+ "last_new_count": int(row["last_new_count"]),+ "seen": int(row["seen"] or 0),+ } for row in rows]+++def due_sources(connection: sqlite3.Connection, now: str | None = None) -> list[sqlite3.Row]:+ """到期该拉的源。从没拉过的(`next_fetch_at` 为空)总是到期。"""+ moment = now or stamp()+ return list(connection.execute(+ "SELECT * FROM feed_source WHERE enabled=1"+ " AND (next_fetch_at IS NULL OR next_fetch_at<=?) ORDER BY id", (moment,)))+++def settle(connection: sqlite3.Connection, source_id: int, *, error: str | None = None,+ etag: str | None = None, last_modified: str | None = None,+ interval_minutes: int, seen: int = 0, new: int = 0,+ now: datetime | None = None) -> None:+ """结算一次拉取。++ 失败也按同一间隔排下一次,不做指数退避——退避要么在这里写第二套判据,要么让一个+ 临时挡回来的源沉默半天。下次时间在所有返回路径上都写,任何一种结局都不会让源卡住。+ """+ moment = now or datetime.now(timezone.utc)+ connection.execute(+ "UPDATE feed_source SET last_error=?,last_fetched_at=?,next_fetch_at=?,"+ "etag=COALESCE(?,etag),last_modified=COALESCE(?,last_modified),"+ "last_seen_count=?,last_new_count=? WHERE id=?",+ (error, stamp(moment), stamp(moment + timedelta(minutes=interval_minutes)),+ etag, last_modified, int(seen), int(new), int(source_id)))+++# -- 条目与壳 --------------------------------------------------------------+++def seen_keys(connection: sqlite3.Connection, source_id: int) -> set[str]:+ return {str(row[0]) for row in connection.execute(+ "SELECT item_key FROM feed_item WHERE source_id=?", (int(source_id),))}+++def in_library(connection: sqlite3.Connection, code: str) -> bool:+ """这个番号已经入库了没有。++ 比的是归一化之后的键:账本里写的是 `SSIS-950`,源里可能给 `ssis00950`,+ 按原文比会把同一部片当成两部。`normalise_code_key` 由 `LedgerDatabase.connect`+ 注册成 SQL 函数,两侧因此是同一份实现。+ """+ key = normalise_code_key(code)+ if not key:+ return False+ row = connection.execute(+ "SELECT 1 FROM asset WHERE code IS NOT NULL AND normalise_code_key(code)=? LIMIT 1",+ (key,)).fetchone()+ return row is not None+++def record_entry(connection: sqlite3.Connection, source_id: int, entry: FeedEntry,+ *, code: str | None, now: str | None = None) -> bool:+ """记下「这个源见过这一条」。已经见过返回 False。"""+ moment = now or stamp()+ try:+ connection.execute(+ "INSERT INTO feed_item(source_id,item_key,code,title,link,published_at,"+ "first_seen) VALUES(?,?,?,?,?,?,?)",+ (int(source_id), entry.item_key, code, entry.title or None, entry.link,+ entry.published_at, moment))+ except sqlite3.IntegrityError:+ return False+ return True+++def create_shell(connection: sqlite3.Connection, code: str, *, source_id: int | None,+ title: str | None = None, link: str | None = None,+ release_date: str | None = None,+ entity_id: int | None = None, now: str | None = None) -> int | None:+ """给一个还没入库的番号建壳。已入库或已有壳时返回 None。++ 两层去重里的第二层就在这三行:先查 `asset`,再靠 `code` 上的唯一约束兜住并发。+ """+ if in_library(connection, code):+ return None+ moment = now or stamp()+ try:+ cursor = connection.execute(+ "INSERT INTO feed_discovery(code,source_id,title,link,release_date,"+ "discovered_at) VALUES(?,?,?,?,?,?)",+ (code, source_id, title, link, release_date, moment))+ except sqlite3.IntegrityError:+ return None+ discovery_id = int(cursor.lastrowid)+ if entity_id:+ link_entity(connection, discovery_id, int(entity_id))+ return discovery_id+++def link_entity(connection: sqlite3.Connection, discovery_id: int, entity_id: int) -> None:+ connection.execute(+ "INSERT OR IGNORE INTO feed_discovery_entity(discovery_id,entity_id) VALUES(?,?)",+ (int(discovery_id), int(entity_id)))+++def match_performers(connection: sqlite3.Connection, names) -> list[int]:+ """按女优名找账本里的实体。正名与别名都查,认不出的名字直接丢掉。++ 这里只做关联,不建实体:Feed 发现的是番号,不是人。凭一个来源给的名字往账本里+ 加一个人,等于让未经复核的断言变成实体。+ """+ found: list[int] = []+ for name in names or []:+ key = normalize_entity_name(str(name or ""))+ if not key:+ continue+ row = connection.execute(+ "SELECT id FROM entity WHERE kind='performer' AND normalized_name=?",+ (key,)).fetchone()+ if row is None:+ row = connection.execute(+ "SELECT entity_id AS id FROM entity_alias a"+ " JOIN entity e ON e.id=a.entity_id AND e.kind='performer'"+ " WHERE a.normalized_alias=? LIMIT 1", (key,)).fetchone()+ if row is not None and int(row["id"]) not in found:+ found.append(int(row["id"]))+ return found+++def poll(connection: sqlite3.Connection, source: sqlite3.Row,+ parsed: ParsedFeed) -> dict:+ """把一次拉取的解析结果落库,返回这一轮的账。++ 写入顺序是源给出的倒序:无日期的条目按旧→新拿到递增的 id,于是「没有发布时间」+ 的那些在列表里也还排得出先后。建壳仍按源给出的顺序,最新的先排上刮削。+ """+ source_id = int(source["id"])+ entity_id = source["entity_id"]+ already = seen_keys(connection, source_id)+ fresh = [entry for entry in parsed.entries if entry.item_key not in already]+ moment = stamp()+ codes: list[tuple[FeedEntry, str | None]] = []+ for entry in reversed(fresh):+ code = entry.code+ record_entry(connection, source_id, entry, code=code, now=moment)+ codes.append((entry, code))+ created: list[tuple[int, str]] = []+ skipped = 0+ for entry, code in reversed(codes):+ if code is None:+ skipped += 1+ continue+ if len(created) >= MAX_NEW_PER_POLL:+ break+ shell = create_shell(connection, code, source_id=source_id,+ title=entry.title or None, link=entry.link,+ release_date=(entry.published_at or "")[:10] or None,+ entity_id=entity_id, now=moment)+ if shell is not None:+ created.append((shell, code))+ return {"seen": len(parsed.entries), "fresh": len(fresh),+ "without_code": skipped, "created": created}diff --git a/src/peach/follow_scheduler.py b/src/peach/follow_scheduler.pyindex cbb85112d..321eba095 100644--- a/src/peach/follow_scheduler.py+++ b/src/peach/follow_scheduler.py@@ -29,6 +29,11 @@ def _stamp(moment: datetime | None = None) -> str:"+00:00", "Z")+#: 订阅源拉取(ADR-0042)借用同一个实现,只是换一个 job id 与一份自己的状态文件。+#: 间隔、退避、跳过与状态上报只有一份:第二套定时会长出第二种「上次什么时候跑的」。+FEED_JOB_ID = "peach-feed-update"++@dataclass(frozen=True)class FollowScheduleConfig:enabled: bool = True@@ -38,8 +43,10 @@ class FollowScheduleConfig:class FollowScheduleStore:"""Small replace-on-write state file; scheduling preferences are not ledger truth."""- def __init__(self, state_root: Path):- self.path = Path(state_root) / "follow-schedule.json"+ def __init__(self, state_root: Path, filename: str = "follow-schedule.json",+ default: FollowScheduleConfig | None = None):+ self.path = Path(state_root) / filename+ self.default = default or FollowScheduleConfig()@staticmethoddef validate(enabled: object, interval_minutes: object) -> FollowScheduleConfig:@@ -56,12 +63,14 @@ class FollowScheduleStore:def load(self) -> FollowScheduleConfig:try:payload = json.loads(self.path.read_text(encoding="utf-8"))- return self.validate(payload.get("enabled", True), payload.get("interval_minutes", 60))+ return self.validate(payload.get("enabled", self.default.enabled),+ payload.get("interval_minutes",+ self.default.interval_minutes))except FileNotFoundError:- return FollowScheduleConfig()+ return self.defaultexcept (OSError, TypeError, ValueError, json.JSONDecodeError):LOGGER.warning("invalid follow schedule preference at %s; using defaults", self.path)- return FollowScheduleConfig()+ return self.defaultdef save(self, config: FollowScheduleConfig) -> None:self.path.parent.mkdir(parents=True, exist_ok=True)@@ -75,8 +84,14 @@ class FollowScheduleStore:class FollowUpdateScheduler:"""Own one interval job and expose its state to the settings surface."""- def __init__(self, state_root: Path, run_check: Callable[[], dict], *, available: bool):- self.store = FollowScheduleStore(state_root)+ def __init__(self, state_root: Path, run_check: Callable[[], dict], *, available: bool,+ job_id: str = JOB_ID, filename: str = "follow-schedule.json",+ default: FollowScheduleConfig | None = None,+ unavailable_message: str =+ "automatic follow updates are available only on the ledger writer"):+ self.job_id = job_id+ self.unavailable_message = unavailable_message+ self.store = FollowScheduleStore(state_root, filename, default)self.run_check = run_checkself.available = bool(available)self.config = self.store.load()@@ -107,7 +122,7 @@ class FollowUpdateScheduler:def update(self, *, enabled: object, interval_minutes: object) -> dict:if not self.available:- raise ValueError("automatic follow updates are available only on the ledger writer")+ raise ValueError(self.unavailable_message)self.config = self.store.validate(enabled, interval_minutes)self.store.save(self.config)if self._started:@@ -116,14 +131,14 @@ class FollowUpdateScheduler:def _apply_job(self) -> None:if not self.config.enabled:- if self.scheduler.get_job(JOB_ID) is not None:- self.scheduler.remove_job(JOB_ID)+ if self.scheduler.get_job(self.job_id) is not None:+ self.scheduler.remove_job(self.job_id)returninterval = self.config.interval_minutesself.scheduler.add_job(self._run,"interval",- id=JOB_ID,+ id=self.job_id,minutes=interval,next_run_time=datetime.now(timezone.utc) + timedelta(minutes=interval),replace_existing=True,@@ -203,7 +218,7 @@ class FollowUpdateScheduler:returntry:self.scheduler.modify_job(- JOB_ID,+ self.job_id,next_run_time=datetime.now(timezone.utc) + timedelta(minutes=delay))except JobLookupError:# 任务在这一轮跑的过程中被关掉了。没什么要退避的。@@ -213,7 +228,7 @@ class FollowUpdateScheduler:with self._state_lock:# 任务与本类的状态必须是同一张快照:分开读会出现「已经不在跑了,# 下次运行时间却还是上一轮的」这种自相矛盾的回答。- job = self.scheduler.get_job(JOB_ID) if self._started else None+ job = self.scheduler.get_job(self.job_id) if self._started else Nonenext_run = job.next_run_time if job is not None else Nonereturn {"ok": True,diff --git a/src/peach/task_runs.py b/src/peach/task_runs.pyindex 377a75b92..f964c3f44 100644--- a/src/peach/task_runs.py+++ b/src/peach/task_runs.py@@ -87,6 +87,8 @@ TASK_LABELS = {"scrape-codes": "番号资料刮削","jav-covers": "封面批量抓取","entity-avatar": "补实体头像",+ "feed-check": "订阅源拉取",+ "feed-scrape": "取新作资料",}diff --git a/src/peach/web_feeds.py b/src/peach/web_feeds.pynew file mode 100644index 000000000..76880b444--- /dev/null+++ b/src/peach/web_feeds.py@@ -0,0 +1,286 @@+"""番号发现源的读写契约:订阅管理、拉取、未入库新作的列表与已读/忽略(ADR-0042)。++这里是 Feed 唯一会向站点发请求的地方。HTTP 走 `scraping_access.SourceTransport`+(按来源的凭据、代理与冷却)套 `HostLimitedTransport`(按主机的间隔),+和刮削链同一套预算——Feed 是后台跑的,不因此另开一套限流。+"""+from __future__ import annotations++import threading+import time+import uuid++from . import feed_followup, feeds+from .http import HttpRequest, public_https_url++#: 一次拉取的超时与体积上限。一份 RSS 正常几十到几百 KB;JavDB 演员页 78 KB。+#: 2 MiB 之外的东西不是 feed,是被替换成了别的页面。+FETCH_TIMEOUT = 30.0+FETCH_MAX_BYTES = 2 * 1024 * 1024++#: 一轮里最多拉几个源。源多的时候分几轮拉完,而不是让一轮跑到限流上去。+MAX_SOURCES_PER_RUN = 20++_NOT_MODIFIED = 304+++def _transport(contract):+ from .jav_cover_fetch import HostLimitedTransport+ from .library_processing import SOURCE_INTERVALS+ from .scraping_access import SourceTransport++ return HostLimitedTransport(+ SourceTransport(contract.follow_secrets_root), 2.0, intervals=SOURCE_INTERVALS)+++def fetch(transport, url: str, *, etag: str | None = None,+ last_modified: str | None = None):+ """取一次订阅地址。304 不是失败,原样交给调用方判。"""+ if not public_https_url(url):+ raise ValueError("订阅地址必须是解析到公网的 HTTPS 地址")+ headers = {"Accept": "application/rss+xml, application/atom+xml, application/xml,"+ " text/xml;q=0.9, text/html;q=0.8"}+ if etag:+ headers["If-None-Match"] = etag+ if last_modified:+ headers["If-Modified-Since"] = last_modified+ return transport(HttpRequest("GET", url, headers), FETCH_TIMEOUT, FETCH_MAX_BYTES)+++def poll_source(contract, transport, source) -> dict:+ """拉一个源并落库,返回这一轮的账。任何失败都写进源的 `last_error`。++ 四条返回路径(请求失败、304、解析失败、正常)都经 `feeds.settle` 写下次时间,+ 所以任何一种结局都不会让这个源卡住不再排队。+ """+ source_id = int(source["id"])+ interval = int(source["interval_minutes"])+ # `ok` 与 `added` 两个键名跟着 `follow_scheduler` 读结果的那一套写:它按+ # `ok` 数失败、按 `added` 数新增,两个调度对象共用同一段结算。+ report = {"source": source_id, "name": source["name"] or source["url"],+ "ok": True, "seen": 0, "added": 0, "without_code": 0, "error": None}+ try:+ response = fetch(transport, source["url"], etag=source["etag"],+ last_modified=source["last_modified"])+ except Exception as error: # noqa: BLE001 - 原因写到源那一行上给人看+ report.update(ok=False, error=str(error))+ with contract.database.write_transaction() as connection:+ feeds.settle(connection, source_id, error=str(error),+ interval_minutes=interval)+ return report+ if response.status == _NOT_MODIFIED:+ with contract.database.write_transaction() as connection:+ feeds.settle(connection, source_id, error=None, interval_minutes=interval)+ report["not_modified"] = True+ return report+ if response.status != 200:+ message = f"来源回了 HTTP {response.status}"+ report.update(ok=False, error=message)+ with contract.database.write_transaction() as connection:+ feeds.settle(connection, source_id, error=message, interval_minutes=interval)+ return report+ parsed = feeds.parse(source["kind"], response.body, source["url"])+ if parsed is None:+ # 解不出不等于「这次没有新作」:JavDB 那种回了一份不含作品的页面也是这条路。+ # 当成安静的源会让一个坏掉的订阅永远不报错。+ message = "这一页解不出任何条目"+ report.update(ok=False, error=message)+ with contract.database.write_transaction() as connection:+ feeds.settle(connection, source_id, error=message, interval_minutes=interval)+ return report+ headers = {key.lower(): value for key, value in (response.headers or {}).items()}+ with contract.database.write_transaction() as connection:+ outcome = feeds.poll(connection, source, parsed)+ feeds.settle(connection, source_id, error=None,+ etag=headers.get("etag"), last_modified=headers.get("last-modified"),+ interval_minutes=interval, seen=outcome["seen"],+ new=len(outcome["created"]))+ report.update(seen=outcome["seen"], fresh=outcome["fresh"],+ without_code=outcome["without_code"],+ added=len(outcome["created"]),+ codes=[code for _id, code in outcome["created"]])+ return report+++def _execute_check(contract, body, job_id: str) -> dict:+ only = body.get("sources")+ with contract.database.read_connection() as connection:+ if isinstance(only, list) and only:+ wanted = {int(value) for value in only}+ rows = [row for row in connection.execute(+ "SELECT * FROM feed_source ORDER BY id") if int(row["id"]) in wanted]+ elif body.get("all"):+ rows = list(connection.execute(+ "SELECT * FROM feed_source WHERE enabled=1 ORDER BY id"))+ else:+ rows = feeds.due_sources(connection)+ rows = rows[:MAX_SOURCES_PER_RUN]+ transport = _transport(contract)+ results, codes = [], []+ try:+ for index, source in enumerate(rows):+ contract.feed_job.update(job_id, checked=index, total=len(rows),+ current=source["name"] or source["url"])+ report = poll_source(contract, transport, source)+ results.append(report)+ codes.extend(report.get("codes") or [])+ finally:+ close = getattr(transport, "close", None)+ if close:+ close()+ contract.cache_bust()+ return {"ok": True, "checked": len(rows), "total": len(rows), "results": results,+ "added": len(codes),+ # 后继由结果声明,调度端统一派(ADR-0040):这里只把清单交出去。+ "followups": [dict(key=item.key, task_key=item.task_key, label=item.label)+ for item in feed_followup.plan(codes)]}+++def w_feed_check(contract, body) -> dict:+ """拉一轮订阅。不带参数只拉到期的源,`all` 拉全部启用的源。"""+ finished = threading.Event()+ request_id = uuid.uuid4().hex++ def work(job_id):+ try:+ result = _execute_check(contract, body, job_id)+ contract.feed_job.update(job_id, **result, status="complete",+ current=None, completed_at=time.time())+ finally:+ finished.set()++ started = contract.feed_job.start(+ work, restart=True,+ trigger="scheduled" if body.get("automatic") else "manual",+ initial={"ok": True, "checked": 0, "total": 0, "results": [], "added": 0,+ "request_id": request_id, "current": None})+ if body.get("background"):+ return started+ if started["request_id"] != request_id:+ return {"ok": False, "busy": True, "checked": 0, "results": []}+ finished.wait()+ return contract.feed_job.snapshot() or started+++def q_feed_check(contract, args) -> dict:+ return contract.feed_job.snapshot() or {"status": "idle"}+++def q_feeds(contract, args) -> dict:+ """设置页「订阅源」小节的首屏。"""+ with contract.database.read_connection() as connection:+ rows = feeds.sources(connection)+ pending = connection.execute(+ "SELECT count(*) FROM feed_discovery WHERE ignored_at IS NULL"+ " AND read_at IS NULL").fetchone()[0]+ return {"ok": True, "sources": rows, "unread": int(pending or 0),+ "kinds": [{"value": kind, "label": feeds.KIND_LABELS[kind]}+ for kind in feeds.KINDS],+ "min_interval_minutes": feeds.MIN_INTERVAL_MINUTES,+ "max_interval_minutes": feeds.MAX_INTERVAL_MINUTES}+++def w_feed_source(contract, body) -> dict:+ """增删订阅与开关。新增不当场拉取:第一轮由到期扫描带上,错误显示在那一行。"""+ action = str(body.get("action") or "add")+ if action == "remove":+ source_id = body.get("id")+ if not isinstance(source_id, int):+ raise ValueError("id must be an integer feed source id")+ with contract.database.write_transaction() as connection:+ feeds.remove_source(connection, source_id)+ return {"ok": True, "removed": source_id}+ if action == "enabled":+ source_id, enabled = body.get("id"), body.get("enabled")+ if not isinstance(source_id, int) or not isinstance(enabled, bool):+ raise ValueError("id must be an integer and enabled must be a boolean")+ with contract.database.write_transaction() as connection:+ feeds.set_enabled(connection, source_id, enabled)+ return {"ok": True, "source": source_id, "enabled": enabled}+ if action != "add":+ raise ValueError(f"unknown feed source action: {action}")+ entity_id = body.get("entity_id")+ with contract.database.write_transaction() as connection:+ source_id = feeds.add_source(+ connection, kind=str(body.get("kind") or feeds.KIND_RSS),+ url=body.get("url"), name=str(body.get("name") or ""),+ entity_id=int(entity_id) if isinstance(entity_id, int) else None,+ interval_minutes=body.get("interval_minutes", feeds.DEFAULT_INTERVAL_MINUTES))+ return {"ok": True, "source": source_id}+++#: 列表一次给多少条。首页那一块只放一行,人物页给一屏。+DISCOVERY_LIMIT = 24+++def q_feed_discoveries(contract, args) -> dict:+ """未入库的新作。`entity` 限定到某个人,`state` 切换忽略视图。++ 「已入库」是现算的:壳上不存这个布尔,它的真相在 `asset` 那一侧(ADR-0042 第三条)。+ 已经入库的番号不出现在列表里——那条新作的使命已经完成了。+ """+ entity_id = args.get("entity")+ state = str(args.get("state") or "active")+ try:+ limit = min(int(args.get("limit") or DISCOVERY_LIMIT), 100)+ except (TypeError, ValueError):+ limit = DISCOVERY_LIMIT+ where = ["NOT EXISTS (SELECT 1 FROM asset a WHERE a.code IS NOT NULL"+ " AND normalise_code_key(a.code)=normalise_code_key(d.code))"]+ params: list[object] = []+ if state == "ignored":+ where.append("d.ignored_at IS NOT NULL")+ elif state != "all":+ where.append("d.ignored_at IS NULL")+ if entity_id:+ where.append("EXISTS (SELECT 1 FROM feed_discovery_entity de"+ " WHERE de.discovery_id=d.id AND de.entity_id=?)")+ params.append(int(entity_id))+ with contract.database.read_connection() as connection:+ rows = connection.execute(+ "SELECT d.*, s.name AS source_name, s.kind AS source_kind"+ " FROM feed_discovery d LEFT JOIN feed_source s ON s.id=d.source_id"+ f" WHERE {' AND '.join(where)}"+ " ORDER BY COALESCE(d.release_date,d.discovered_at) DESC, d.id DESC"+ " LIMIT ?", (*params, limit + 1)).fetchall()+ more = len(rows) > limit+ return {"ok": True, "more": more, "items": [{+ "id": int(row["id"]),+ "code": row["code"],+ "title": row["title"],+ "link": row["link"],+ "cover_url": row["cover_url"],+ "release_date": row["release_date"],+ "studio": row["studio"],+ "performers": row["performers"],+ "source_name": row["source_name"],+ "read": bool(row["read_at"]),+ "ignored": bool(row["ignored_at"]),+ "scrape_error": row["scrape_error"],+ } for row in rows[:limit]]}+++#: 允许的状态动作。已读与忽略彼此正交,各写各的列,都不改变去重(ADR-0042 第五条)。+ACTIONS = {"read": ("read_at", True), "unread": ("read_at", False),+ "ignore": ("ignored_at", True), "unignore": ("ignored_at", False)}+++def w_feed_discovery(contract, body) -> dict:+ """把一条或几条新作标成已读/未读、忽略/取消忽略。幂等。"""+ action = str(body.get("action") or "")+ if action not in ACTIONS:+ raise ValueError(f"unknown feed discovery action: {action}")+ raw = body.get("ids")+ ids = [value for value in (raw if isinstance(raw, list) else [raw])+ if type(value) is int]+ if not ids:+ raise ValueError("ids must be a nonempty list of feed discovery ids")+ column, setting = ACTIONS[action]+ value = feeds.stamp() if setting else None+ marks = ",".join("?" for _ in ids)+ with contract.database.write_transaction() as connection:+ cursor = connection.execute(+ f"UPDATE feed_discovery SET {column}=? WHERE id IN ({marks})",+ (value, *ids))+ contract.cache_bust()+ return {"ok": True, "action": action, "affected": int(cursor.rowcount or 0)}diff --git a/src/peach/web_router.py b/src/peach/web_router.pyindex 1b5c7fe4d..eac2c6907 100644--- a/src/peach/web_router.py+++ b/src/peach/web_router.py@@ -42,6 +42,14 @@ from .web_entity import (w_entity_alias,w_entity_name,)+from .web_feeds import (+ q_feed_check,+ q_feed_discoveries,+ q_feeds,+ w_feed_check,+ w_feed_discovery,+ w_feed_source,+)from .web_follow import (q_follow,q_follow_authors,@@ -283,6 +291,9 @@ GET_HANDLERS = {"/api/scraping": q_scraping,"/api/scraping/cover": lambda contract, args: contract.scraping_cover_job.snapshot() or {"status": "idle"},"/api/settings": q_settings,+ "/api/feeds": q_feeds,+ "/api/feeds/check": q_feed_check,+ "/api/feeds/discoveries": q_feed_discoveries,"/api/follow": q_follow,"/api/follow/credentials": q_follow_credentials,"/api/follow/tags": q_follow_tags,@@ -327,6 +338,9 @@ POST_HANDLERS = {"/api/scraping/settings": w_scraping_settings,"/api/scraping/cover": w_scraping_cover,"/api/scraping/check": w_scraping_check,+ "/api/feeds/check": w_feed_check,+ "/api/feeds/source": w_feed_source,+ "/api/feeds/discovery": w_feed_discovery,"/api/follow/check": w_follow_check,"/api/follow/schedule": w_follow_schedule,"/api/follow/source": w_follow_source,diff --git a/src/peach/web_state.py b/src/peach/web_state.pyindex c0ea4c147..333443284 100644--- a/src/peach/web_state.py+++ b/src/peach/web_state.py@@ -155,9 +155,11 @@ class WebContract:#: 后继调度(ADR-0040)。导入 `avatar_followup` 就是它的登记动作:调度器本身#: 不认识任何一种后继,登记表在 `followups.REGISTRY` 里。from . import avatar_followup # noqa: F401 登记补头像后继+ from . import feed_followup # noqa: F401 登记取新作资料后继from .followups import FollowupRunnerself.followups = FollowupRunner(self)self.follow_job = self._job("PeachFollowCheckJob", "follow-check")+ self.feed_job = self._job("PeachFeedCheckJob", "feed-check")self.follow_resolve_job = self._job("PeachFollowResolveJob", "follow-resolve")self.taste_refresh_job = self._job("PeachTasteRefreshJob", "taste-refresh")self.link_prune_job = self._job("PeachLinkPruneJob", "link-prune")@@ -171,6 +173,9 @@ class WebContract:# 整理(ADR-0039):同一时间只跑一批,互斥由这个任务自己的键提供。self.organize_job = self._job("PeachOrganizeJob", "organize")self.follow_scheduler = None+ #: 订阅源的定时拉取(ADR-0042)。与追更共用 `follow_scheduler` 那一个实现,+ #: 只是各占一个 job id 与一份状态文件;由 `api` 在装配时接上。+ self.feed_scheduler = None#: 批量修 MP4 头要的两件东西,由 `api` 在装配时接上:它们属于播放链路,#: 建在 app 那一侧,契约这边只留接口。没接上时修复端点会说清楚。self.header_repairs = None@@ -254,6 +259,7 @@ class WebContract:self.link_prune_job.stop()self.resource_apply_job.stop()self.link_check.stop()+ self.feed_job.stop()self.followups.stop()def cache_bust(self):diff --git a/tests/test_feeds.py b/tests/test_feeds.pynew file mode 100644index 000000000..c5e597575--- /dev/null+++ b/tests/test_feeds.py@@ -0,0 +1,299 @@+"""番号发现源:解析、两层去重、已读与忽略、空壳与真实资产的边界(ADR-0042)。"""+from __future__ import annotations++import sqlite3+import sys+import tempfile+import unittest+from pathlib import Path++sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))++from peach import feeds # noqa: E402+from peach.migrations import upgrade # noqa: E402+from peach.repository import LedgerDatabase # noqa: E402++MIGRATIONS = Path(__file__).resolve().parents[1] / "migrations"++RSS = b"""<?xml version="1.0" encoding="UTF-8"?>+<rss version="2.0"><channel>+ <title>Sukebei - Home - Torrent File RSS</title>+ <item>+ <title>HMN-071 \xe6\x96\xb0\xe4\xba\xba \xe6\x88\xb6\xe5\xb7\x9d\xe6\xad\xa5[\xe6\x9c\x89\xe7\xa2\xbc]</title>+ <link>https://sukebei.nyaa.si/download/4719097.torrent</link>+ <guid>https://sukebei.nyaa.si/view/4719097</guid>+ <pubDate>Tue, 22 Sep 2026 10:36:13 -0000</pubDate>+ </item>+ <item>+ <title>[H265 1080p] DSOD-114 \xe8\x8a\xb1\xe5\xae\xae\xe4\xba\xac\xe5\xad\x90</title>+ <link>https://sukebei.nyaa.si/download/4719080.torrent</link>+ <guid>https://sukebei.nyaa.si/view/4719080</guid>+ <pubDate>Tue, 22 Sep 2026 09:12:00 -0000</pubDate>+ </item>+ <item>+ <title>\xe5\x90\x88\xe9\x9b\x86 30 \xe9\x83\xa8\xe6\x89\x93\xe5\x8c\x85</title>+ <link>https://sukebei.nyaa.si/download/4719001.torrent</link>+ <guid>https://sukebei.nyaa.si/view/4719001</guid>+ <pubDate>Tue, 22 Sep 2026 08:00:00 -0000</pubDate>+ </item>+</channel></rss>"""++ATOM = b"""<?xml version="1.0" encoding="UTF-8"?>+<feed xmlns="http://www.w3.org/2005/Atom">+ <title>example</title>+ <entry>+ <id>tag:example,2026:1</id>+ <title>SSIS-950 sample</title>+ <link href="https://example.test/a"/>+ <published>2026-09-20T03:00:00Z</published>+ </entry>+</feed>"""++JAVDB_ACTOR = """+<div class="movie-list h cols-4 vcols-8">+ <div class="item">+ <a href="/v/5nr8mp" class="box" title="ignored">+ <div class="cover"><img src="x.jpg" /></div>+ <div class="video-title"><strong>PBD-528</strong> 気高きお姉さん達</div>+ <div class="score"><span class="value">4.0分</span></div>+ <div class="meta">+ 2026-10-20+ </div>+ </a>+ </div>+ <div class="item">+ <a href="/v/RkPb5z" class="box" title="ignored">+ <div class="cover"><img src="y.jpg" /></div>+ <div class="video-title"><strong>BBSS-106</strong> 別の作品</div>+ <div class="meta">+ 2026-10-13+ </div>+ </a>+ </div>+</div>+"""+++def _database(root: Path) -> LedgerDatabase:+ path = root / "ledger.db"+ upgrade(path, MIGRATIONS)+ return LedgerDatabase(path)+++class FeedParsingTest(unittest.TestCase):+ def test_rss_entries_take_guid_as_item_key(self):+ parsed = feeds.parse_feed(RSS)+ self.assertIsNotNone(parsed)+ self.assertEqual(parsed.title, "Sukebei - Home - Torrent File RSS")+ self.assertEqual([entry.item_key for entry in parsed.entries],+ ["https://sukebei.nyaa.si/view/4719097",+ "https://sukebei.nyaa.si/view/4719080",+ "https://sukebei.nyaa.si/view/4719001"])+ self.assertEqual(parsed.entries[0].published_at, "2026-09-22T10:36:13.000Z")++ def test_atom_entries_take_id_and_link(self):+ parsed = feeds.parse_feed(ATOM)+ self.assertEqual(len(parsed.entries), 1)+ self.assertEqual(parsed.entries[0].item_key, "tag:example,2026:1")+ self.assertEqual(parsed.entries[0].link, "https://example.test/a")+ self.assertEqual(parsed.entries[0].code, "SSIS-950")++ def test_not_a_feed_is_none(self):+ self.assertIsNone(feeds.parse_feed(b"<html><body>hi</body></html>"))+ self.assertIsNone(feeds.parse_feed(b""))++ def test_code_is_found_inside_a_title_full_of_prose(self):+ # 整段丢给 `release_code_from_text` 认不出来,词元扫描才认得出。+ title = "HMN-071 新人 帶來超稀有妹子 戶川步[有碼高清中文字幕]"+ self.assertEqual(feeds.scan_code(title), "HMN-071")+ self.assertEqual(feeds.scan_code("[H265 1080p] DSOD-114 花宮京子"), "DSOD-114")+ self.assertIsNone(feeds.scan_code("合集 30 部打包"))++ def test_javdb_actor_page_reads_code_and_release_date(self):+ parsed = feeds.parse_javdb_actor(JAVDB_ACTOR, "https://javdb.com/actors/pRMq")+ self.assertEqual([entry.item_key for entry in parsed.entries],+ ["/v/5nr8mp", "/v/RkPb5z"])+ self.assertEqual(parsed.entries[0].code, "PBD-528")+ self.assertEqual(parsed.entries[0].link, "https://javdb.com/v/5nr8mp")+ self.assertEqual(parsed.entries[0].published_at, "2026-10-20T00:00:00.000Z")++ def test_a_page_without_any_work_is_a_failure_not_an_empty_poll(self):+ # 带查询串的演员页会回一份不含作品的页面。当成「这次没有新作」会让一个坏掉的+ # 订阅永远不报错。+ self.assertIsNone(feeds.parse_javdb_actor("<html>nothing</html>",+ "https://javdb.com/actors/pRMq"))+++class FeedStoreTest(unittest.TestCase):+ def setUp(self):+ self._tmp = tempfile.TemporaryDirectory()+ self.root = Path(self._tmp.name)+ self.database = _database(self.root)+ self.addCleanup(self._tmp.cleanup)++ def _source(self, **kwargs) -> int:+ with self.database.write_transaction() as connection:+ return feeds.add_source(connection, kind=feeds.KIND_RSS,+ url=kwargs.pop("url", "https://example.test/rss"),+ **kwargs)++ def _poll(self, source_id: int, body: bytes = RSS) -> dict:+ parsed = feeds.parse_feed(body)+ with self.database.write_transaction() as connection:+ source = connection.execute("SELECT * FROM feed_source WHERE id=?",+ (source_id,)).fetchone()+ return feeds.poll(connection, source, parsed)++ def test_https_only(self):+ with self.assertRaises(ValueError):+ feeds.normalize_url("http://example.test/rss")++ def test_same_url_twice_is_refused(self):+ self._source()+ with self.assertRaises(ValueError):+ self._source()++ def test_first_poll_records_every_entry_and_shells_the_coded_ones(self):+ source_id = self._source()+ outcome = self._poll(source_id)+ self.assertEqual(outcome["seen"], 3)+ self.assertEqual(outcome["fresh"], 3)+ # 解不出番号的条目照样记一行,只是不建壳。+ self.assertEqual(outcome["without_code"], 1)+ self.assertEqual(sorted(code for _id, code in outcome["created"]),+ ["DSOD-114", "HMN-071"])+ with self.database.read_connection() as connection:+ self.assertEqual(connection.execute(+ "SELECT count(*) FROM feed_item").fetchone()[0], 3)++ def test_second_poll_of_the_same_document_creates_nothing(self):+ source_id = self._source()+ self._poll(source_id)+ outcome = self._poll(source_id)+ self.assertEqual(outcome["fresh"], 0)+ self.assertEqual(outcome["created"], [])++ def test_two_sources_reporting_one_code_share_a_single_shell(self):+ first = self._source(url="https://example.test/a.xml")+ second = self._source(url="https://example.test/b.xml")+ self._poll(first)+ outcome = self._poll(second)+ # 源内那一层是各自的,所以第二个源仍然把三条都记成新条目……+ self.assertEqual(outcome["fresh"], 3)+ # ……但全局那一层只认番号,壳一个都不再建。+ self.assertEqual(outcome["created"], [])+ with self.database.read_connection() as connection:+ self.assertEqual(connection.execute(+ "SELECT count(*) FROM feed_discovery").fetchone()[0], 2)+ self.assertEqual(connection.execute(+ "SELECT count(*) FROM feed_item").fetchone()[0], 6)++ def test_a_code_already_in_the_library_gets_no_shell(self):+ with self.database.write_transaction() as connection:+ connection.execute(+ "INSERT INTO asset(location,path,name,medium,code) "+ "VALUES('R','R:\\\\media\\\\hmn071.mp4','hmn071.mp4','video','hmn00071')")+ source_id = self._source()+ outcome = self._poll(source_id)+ # 归一化之后 `hmn00071` 与 `HMN-071` 是同一部片。+ self.assertEqual([code for _id, code in outcome["created"]], ["DSOD-114"])++ def test_read_and_ignore_are_independent_and_do_not_touch_dedupe(self):+ source_id = self._source()+ created = self._poll(source_id)["created"]+ discovery_id = created[0][0]+ with self.database.write_transaction() as connection:+ connection.execute("UPDATE feed_discovery SET read_at=? WHERE id=?",+ (feeds.stamp(), discovery_id))+ connection.execute("UPDATE feed_discovery SET ignored_at=? WHERE id=?",+ (feeds.stamp(), discovery_id))+ row = connection.execute(+ "SELECT read_at,ignored_at FROM feed_discovery WHERE id=?",+ (discovery_id,)).fetchone()+ self.assertIsNotNone(row["read_at"])+ self.assertIsNotNone(row["ignored_at"])+ # 忽略之后再拉一轮,这条既不重建也不变回未忽略。+ outcome = self._poll(source_id)+ self.assertEqual(outcome["created"], [])+ with self.database.read_connection() as connection:+ row = connection.execute(+ "SELECT ignored_at FROM feed_discovery WHERE id=?",+ (discovery_id,)).fetchone()+ self.assertIsNotNone(row["ignored_at"])++ def test_settle_writes_the_next_time_on_every_path(self):+ source_id = self._source(interval_minutes=60)+ with self.database.write_transaction() as connection:+ feeds.settle(connection, source_id, error="来源回了 HTTP 503",+ interval_minutes=60)+ with self.database.read_connection() as connection:+ row = connection.execute("SELECT * FROM feed_source WHERE id=?",+ (source_id,)).fetchone()+ self.assertEqual(row["last_error"], "来源回了 HTTP 503")+ self.assertIsNotNone(row["next_fetch_at"])+ self.assertGreater(row["next_fetch_at"], row["last_fetched_at"])++ def test_disabled_sources_are_never_due(self):+ source_id = self._source()+ with self.database.write_transaction() as connection:+ feeds.set_enabled(connection, source_id, False)+ with self.database.read_connection() as connection:+ self.assertEqual(feeds.due_sources(connection), [])++ def test_performer_names_match_existing_entities_only(self):+ with self.database.write_transaction() as connection:+ connection.execute(+ "INSERT INTO entity(kind,canonical_name,normalized_name,created_at,updated_at)"+ " VALUES('performer','深田えいみ',peach_normalize('深田えいみ'),?,?)",+ (feeds.stamp(), feeds.stamp()))+ with self.database.read_connection() as connection:+ found = feeds.match_performers(connection, ["深田えいみ", "查无此人"])+ self.assertEqual(len(found), 1)+++class ShellBoundaryTest(unittest.TestCase):+ """壳不进 asset,所以整理、抽帧与馆藏统计看不到它(ADR-0042 第二条)。"""++ def setUp(self):+ self._tmp = tempfile.TemporaryDirectory()+ self.database = _database(Path(self._tmp.name))+ self.addCleanup(self._tmp.cleanup)++ def test_a_shell_adds_no_asset_row(self):+ with self.database.write_transaction() as connection:+ source_id = feeds.add_source(connection, kind=feeds.KIND_RSS,+ url="https://example.test/rss")+ feeds.poll(connection, connection.execute(+ "SELECT * FROM feed_source WHERE id=?", (source_id,)).fetchone(),+ feeds.parse_feed(RSS))+ with self.database.read_connection() as connection:+ self.assertEqual(connection.execute(+ "SELECT count(*) FROM asset").fetchone()[0], 0)+ self.assertGreater(connection.execute(+ "SELECT count(*) FROM feed_discovery").fetchone()[0], 0)++ def test_the_shell_table_is_not_an_asset_reference(self):+ # 物理删除资产时要清的引用名单里没有它:壳不引用 asset,两者只按番号对上。+ from peach.web_batch import ASSET_REFERENCE_TABLES+ self.assertNotIn("feed_discovery", ASSET_REFERENCE_TABLES)+ self.assertNotIn("feed_item", ASSET_REFERENCE_TABLES)++ def test_deleting_a_source_takes_its_items_but_leaves_the_shell(self):+ # 壳是「这个番号还没入库」,它不该随着某个订阅被删而消失。+ with self.database.write_transaction() as connection:+ connection.execute("PRAGMA foreign_keys=ON")+ source_id = feeds.add_source(connection, kind=feeds.KIND_RSS,+ url="https://example.test/rss")+ feeds.poll(connection, connection.execute(+ "SELECT * FROM feed_source WHERE id=?", (source_id,)).fetchone(),+ feeds.parse_feed(RSS))+ feeds.remove_source(connection, source_id)+ with self.database.read_connection() as connection:+ self.assertEqual(connection.execute(+ "SELECT count(*) FROM feed_item").fetchone()[0], 0)+ self.assertEqual(connection.execute(+ "SELECT count(*) FROM feed_discovery").fetchone()[0], 2)+++if __name__ == "__main__": # pragma: no cover+ unittest.main()diff --git a/tests/test_feeds_web.py b/tests/test_feeds_web.pynew file mode 100644index 000000000..d5b4f89a2--- /dev/null+++ b/tests/test_feeds_web.py@@ -0,0 +1,254 @@+"""番号发现源的契约层:拉取一轮、建壳、列表、已读与忽略(ADR-0042)。"""+from __future__ import annotations++import sys+import tempfile+import time+import unittest+from pathlib import Path++sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))+sys.path.insert(0, str(Path(__file__).resolve().parent))++from peach import feed_followup, feeds, web_feeds # noqa: E402+from peach.http import HttpResponse # noqa: E402+from peach.web_contract import WebContract # noqa: E402+from peach.web_router import dispatch_api_get, dispatch_api_post # noqa: E402+from support.ledger import fresh_ledger # noqa: E402++#: 端到端那一趟读的是临时数据根里的这份文件:拉取只吃已下载的字节,+#: 字节从网络来还是从盘上来与解析、去重、建壳那几步无关。+SAMPLE = """<?xml version="1.0" encoding="UTF-8"?>+<rss version="2.0"><channel>+ <title>示例新作</title>+ <item>+ <title>SSIS-950 作品标题</title>+ <link>https://feeds.example.test/view/2</link>+ <guid>https://feeds.example.test/view/2</guid>+ <pubDate>Mon, 21 Sep 2026 03:00:00 +0000</pubDate>+ </item>+ <item>+ <title>HMN-071 另一部作品[有碼高清中文字幕]</title>+ <link>https://feeds.example.test/view/1</link>+ <guid>https://feeds.example.test/view/1</guid>+ <pubDate>Sun, 20 Sep 2026 03:00:00 +0000</pubDate>+ </item>+ <item>+ <title>合集 30 部打包</title>+ <link>https://feeds.example.test/view/0</link>+ <guid>https://feeds.example.test/view/0</guid>+ <pubDate>Sat, 19 Sep 2026 03:00:00 +0000</pubDate>+ </item>+</channel></rss>+"""+++class FakeTransport:+ """按地址回一份事先备好的响应。记下每次请求,好核对条件请求头。"""++ def __init__(self, responses):+ self.responses = responses+ self.requests = []++ def __call__(self, request, timeout, max_bytes):+ self.requests.append(request)+ return self.responses[request.url]+++class FeedWebTest(unittest.TestCase):+ def setUp(self):+ self.temporary = tempfile.TemporaryDirectory()+ self.addCleanup(self.temporary.cleanup)+ self.db_path = fresh_ledger(self.temporary.name)+ self.contract = WebContract(self.db_path)+ self.addCleanup(self.contract.stop_background_jobs)+ # 后继在服务里由后台线程领走,在测试里那是一个和断言赛跑的线程:它可能在+ # assert 之后才写完,也可能在临时目录删掉之后才醒。这里关掉自动领取,+ # 要跑后继的用例自己 `drain()`。+ self.contract.followups.stop()+ self.url = "https://feeds.example.test/new.xml"+ sample = Path(self.temporary.name) / "feed-sample.xml"+ sample.write_text(SAMPLE, encoding="utf-8")+ self.transport = FakeTransport({self.url: HttpResponse(+ 200, {"ETag": 'W/"abc"', "Content-Type": "application/xml"},+ sample.read_bytes(), self.url)})+ self._patched = web_feeds.fetch+ web_feeds.fetch = self._fetch+ self.addCleanup(lambda: setattr(web_feeds, "fetch", self._patched))+ # 建壳会派取资料后继,后继由契约自己的 runner 领走。不替掉问来源那一步的话,+ # 这个套件每跑一次就朝真实来源发一轮请求——番号是假的,配额是真的。+ self._collect = feed_followup.collect+ feed_followup.collect = lambda provider, code: (+ {"title": f"{code} 的标题", "studio": "示例厂牌",+ "release_date": "2026-09-20",+ "performers": [{"name": "深田えいみ"}]},+ "https://images.example.test/cover.jpg")+ self.addCleanup(lambda: setattr(feed_followup, "collect", self._collect))++ def _fetch(self, transport, url, *, etag=None, last_modified=None):+ # 真实路径上的 SSRF 闸门要做 DNS,这里替换掉的正是那一层;条件请求头仍原样传下去。+ headers = {}+ if etag:+ headers["If-None-Match"] = etag+ if last_modified:+ headers["If-Modified-Since"] = last_modified+ from peach.http import HttpRequest+ return transport(HttpRequest("GET", url, headers), 30.0, 1 << 21)++ def _add(self, **body):+ return dispatch_api_post(self.contract, "/api/feeds/source",+ {"action": "add", "url": self.url, "name": "示例源",+ **body})++ def _check(self):+ original = web_feeds._transport+ web_feeds._transport = lambda contract: self.transport+ try:+ return dispatch_api_post(self.contract, "/api/feeds/check", {"all": True})+ finally:+ web_feeds._transport = original++ def test_settings_snapshot_lists_the_source_and_its_kinds(self):+ self._add()+ snapshot = dispatch_api_get(self.contract, "/api/feeds", {})+ self.assertEqual(len(snapshot["sources"]), 1)+ self.assertEqual(snapshot["sources"][0]["name"], "示例源")+ self.assertTrue(snapshot["sources"][0]["enabled"])+ self.assertEqual([kind["value"] for kind in snapshot["kinds"]],+ list(feeds.KINDS))++ def test_one_round_turns_a_local_feed_into_unfiled_new_releases(self):+ self._add()+ result = self._check()+ self.assertEqual(result["checked"], 1)+ self.assertEqual(result["results"][0]["error"], None)+ self.assertEqual(result["added"], 2)+ # 后继由结果声明,调度端统一派(ADR-0040)。+ self.assertEqual([item["task_key"] for item in result["followups"]],+ ["feed-scrape", "feed-scrape"])+ listing = dispatch_api_get(self.contract, "/api/feeds/discoveries", {})+ self.assertEqual([item["code"] for item in listing["items"]],+ ["SSIS-950", "HMN-071"])+ self.assertFalse(listing["items"][0]["read"])++ def test_the_second_round_uses_the_stored_validators_and_adds_nothing(self):+ self._add()+ self._check()+ self.transport.responses[self.url] = HttpResponse(304, {}, b"", self.url)+ result = self._check()+ self.assertTrue(result["results"][0]["not_modified"])+ self.assertEqual(self.transport.requests[-1].headers["If-None-Match"], 'W/"abc"')+ listing = dispatch_api_get(self.contract, "/api/feeds/discoveries", {})+ self.assertEqual(len(listing["items"]), 2)++ def test_a_failing_source_reports_on_its_own_row_and_stays_scheduled(self):+ self._add()+ self.transport.responses[self.url] = HttpResponse(503, {}, b"", self.url)+ result = self._check()+ self.assertFalse(result["results"][0]["ok"])+ row = dispatch_api_get(self.contract, "/api/feeds", {})["sources"][0]+ self.assertEqual(row["last_error"], "来源回了 HTTP 503")+ self.assertIsNotNone(row["next_fetch_at"])++ def test_read_and_ignore_are_separate_and_idempotent(self):+ self._add()+ self._check()+ first = dispatch_api_get(self.contract, "/api/feeds/discoveries", {})["items"][0]+ dispatch_api_post(self.contract, "/api/feeds/discovery",+ {"action": "read", "ids": [first["id"]]})+ dispatch_api_post(self.contract, "/api/feeds/discovery",+ {"action": "read", "ids": [first["id"]]})+ listing = dispatch_api_get(self.contract, "/api/feeds/discoveries", {})+ self.assertTrue(listing["items"][0]["read"])+ self.assertFalse(listing["items"][0]["ignored"])++ dispatch_api_post(self.contract, "/api/feeds/discovery",+ {"action": "ignore", "ids": [first["id"]]})+ active = dispatch_api_get(self.contract, "/api/feeds/discoveries", {})+ self.assertEqual([item["code"] for item in active["items"]], ["HMN-071"])+ ignored = dispatch_api_get(self.contract, "/api/feeds/discoveries",+ {"state": "ignored"})+ self.assertEqual([item["code"] for item in ignored["items"]], ["SSIS-950"])++ dispatch_api_post(self.contract, "/api/feeds/discovery",+ {"action": "unignore", "ids": [first["id"]]})+ back = dispatch_api_get(self.contract, "/api/feeds/discoveries", {})+ # 取消忽略只恢复可见性,已读状态不跟着变。+ self.assertEqual([item["code"] for item in back["items"]],+ ["SSIS-950", "HMN-071"])+ self.assertTrue(back["items"][0]["read"])++ def test_a_code_that_reaches_the_library_leaves_the_list(self):+ self._add()+ self._check()+ with self.contract.database.write_transaction() as connection:+ connection.execute(+ "INSERT INTO asset(location,path,name,medium,code) "+ "VALUES('R','R:\\\\media\\\\ssis950.mp4','ssis950.mp4','video','SSIS-950')")+ listing = dispatch_api_get(self.contract, "/api/feeds/discoveries", {})+ self.assertEqual([item["code"] for item in listing["items"]], ["HMN-071"])++ def test_the_entity_filter_only_returns_that_person(self):+ with self.contract.database.write_transaction() as connection:+ cursor = connection.execute(+ "INSERT INTO entity(kind,canonical_name,normalized_name,created_at,updated_at)"+ " VALUES('performer','深田えいみ',peach_normalize('深田えいみ'),?,?)",+ (feeds.stamp(), feeds.stamp()))+ entity_id = int(cursor.lastrowid)+ self._add(entity_id=entity_id)+ self._check()+ mine = dispatch_api_get(self.contract, "/api/feeds/discoveries",+ {"entity": entity_id})+ self.assertEqual(len(mine["items"]), 2)+ nobody = dispatch_api_get(self.contract, "/api/feeds/discoveries",+ {"entity": entity_id + 1})+ self.assertEqual(nobody["items"], [])++ def test_removing_a_source_keeps_the_new_releases_it_found(self):+ self._add()+ self._check()+ source_id = dispatch_api_get(self.contract, "/api/feeds", {})["sources"][0]["id"]+ dispatch_api_post(self.contract, "/api/feeds/source",+ {"action": "remove", "id": source_id})+ listing = dispatch_api_get(self.contract, "/api/feeds/discoveries", {})+ self.assertEqual(len(listing["items"]), 2)++ def _drain(self, expected):+ """等后继排上再跑掉它们。++ `w_feed_check` 在任务体收尾时就放行调用方,而声明的后继是任务包装那一层在+ 之后派的(ADR-0040)。直接 `drain()` 会赶在入队之前,跑到零条。+ """+ deadline = time.monotonic() + 5.0+ done = 0+ while done < expected and time.monotonic() < deadline:+ done += self.contract.followups.drain()+ return done++ def test_the_scrape_followup_fills_the_shell_and_links_the_performer(self):+ with self.contract.database.write_transaction() as connection:+ connection.execute(+ "INSERT INTO entity(kind,canonical_name,normalized_name,created_at,updated_at)"+ " VALUES('performer','深田えいみ',peach_normalize('深田えいみ'),?,?)",+ (feeds.stamp(), feeds.stamp()))+ self._add()+ self._check()+ self.assertEqual(self._drain(2), 2)+ items = {row["code"]: row for row in dispatch_api_get(+ self.contract, "/api/feeds/discoveries", {})["items"]}+ item = items["SSIS-950"]+ self.assertEqual(item["title"], "SSIS-950 的标题")+ self.assertEqual(item["studio"], "示例厂牌")+ self.assertEqual(item["performers"], "深田えいみ")+ # 壳只认已有的人,不新建实体;关联上了人物页那一块才看得到。+ self.assertEqual(len(dispatch_api_get(+ self.contract, "/api/feeds/discoveries", {"entity": 1})["items"]), 2)++ def test_an_unknown_action_is_refused(self):+ with self.assertRaises(ValueError):+ dispatch_api_post(self.contract, "/api/feeds/discovery",+ {"action": "delete", "ids": [1]})+++if __name__ == "__main__": # pragma: no cover+ unittest.main()diff --git a/tests/test_migrations.py b/tests/test_migrations.pyindex 0ed5281f9..dfe30d545 100644--- a/tests/test_migrations.py+++ b/tests/test_migrations.py@@ -25,7 +25,7 @@ class MigrationTests(unittest.TestCase):backup = self.root / "before.db"done = upgrade(self.db, MIGRATIONS, backup)self.assertEqual([m.version for m in done],- ["0000", "0001", "0002", "0003", "0004", "0005", "0006", "0007", "0008", "0009", "0010", "0011", "0012", "0013", "0014", "0015", "0016", "0017", "0018", "0019", "0020", "0021", "0022", "0023", "0024", "0025", "0026", "0027", "0028", "0029", "0030", "0031", "0032", "0033"])+ ["0000", "0001", "0002", "0003", "0004", "0005", "0006", "0007", "0008", "0009", "0010", "0011", "0012", "0013", "0014", "0015", "0016", "0017", "0018", "0019", "0020", "0021", "0022", "0023", "0024", "0025", "0026", "0027", "0028", "0029", "0030", "0031", "0032", "0033", "0034"])self.assertTrue(backup.exists())con = sqlite3.connect(self.db)tables = {row[0] for row in con.execute(@@ -42,7 +42,7 @@ class MigrationTests(unittest.TestCase):"playlist", "playlist_item","asset_tag_preference", "asset_search", "follow_playback","genre_decision", "asset_subtitle", "task_run", "schema_migration"} <= tables)- self.assertEqual(versions, ["0000", "0001", "0002", "0003", "0004", "0005", "0006", "0007", "0008", "0009", "0010", "0011", "0012", "0013", "0014", "0015", "0016", "0017", "0018", "0019", "0020", "0021", "0022", "0023", "0024", "0025", "0026", "0027", "0028", "0029", "0030", "0031", "0032", "0033"])+ self.assertEqual(versions, ["0000", "0001", "0002", "0003", "0004", "0005", "0006", "0007", "0008", "0009", "0010", "0011", "0012", "0013", "0014", "0015", "0016", "0017", "0018", "0019", "0020", "0021", "0022", "0023", "0024", "0025", "0026", "0027", "0028", "0029", "0030", "0031", "0032", "0033", "0034"])self.assertEqual(upgrade(self.db, MIGRATIONS), [])self.assertEqual(plan(self.db, MIGRATIONS)[1], [])diff --git a/tests/test_rm_web.py b/tests/test_rm_web.pyindex fba7b135f..e6033c5e3 100644--- a/tests/test_rm_web.py+++ b/tests/test_rm_web.py@@ -903,6 +903,7 @@ class WebDataTests(unittest.TestCase):"/api/links/prune", "/api/resource-sync/apply","/api/follow/tags", "/api/follow/authors","/api/taste", "/api/settings", "/api/links", "/api/organize",+ "/api/feeds", "/api/feeds/check", "/api/feeds/discoveries",})self.assertEqual(set(rm_web.POST_HANDLERS), {"/api/library-processing", "/api/thumbnail-jobs", "/api/media-repair",@@ -923,6 +924,7 @@ class WebDataTests(unittest.TestCase):"/api/taste/refresh", "/api/taste/source", "/api/settings","/api/entity-name", "/api/entity-alias","/api/organize/preview", "/api/organize/apply", "/api/organize/rollback",+ "/api/feeds/check", "/api/feeds/source", "/api/feeds/discovery",})with self.assertRaises(rm_web.ContractRouteNotFound):rm_web.dispatch_api_get(self.contract, "/api/typo", {})diff --git a/web/app.js b/web/app.jsindex 835289c01..f3d1bef95 100644--- a/web/app.js+++ b/web/app.js@@ -4606,11 +4606,65 @@ function showHomeSurfaces(){上一页挂在里面的 React 根(换头像)就没人卸,留着一棵管着已经不在页面上的节点的根。 */unmountIsland($('#index'));$('#stats').hidden=true;$('#index').hidden=true;+ // 新作那一行由 `load()` 按路径重画;这里先收起,换页时不会有上一页的内容留着。+ $('#feedNew').hidden=true;$('#tiers').style.display='';$('#tagbar').style.display='';buildManageBar();paintListTitle(); // 放在最后:管理区要盖掉上面刚恢复的首页横条}function closeStats(push=true){if(push)route('/');showHomeSurfaces();load(true)}+/* 「新作 · 未入库」:订阅源发现的番号,库里还没有文件(ADR-0042)。+ *+ * 这一块和网格里的卡片说的不是同一件事——那些是本机有文件的作品,这些只是「外面出了+ * 这一部」。所以它自己一行,卡片上不出时长、大小、来源徽章:那几个读数对一条还没有+ * 文件的番号全是空的,照着资产卡画会让人以为点开能看。+ *+ * 落点用发现时那条地址,不另拼。JavDB 演员页那类源给的就是作品页 `/v/…`,而按番号拼+ * 搜索地址是把「这是哪一部」交给站内检索去猜——缺 id 就不给入口,全站同一条规矩。 */+function feedNewCardHtml(item){+ const label=[item.studio,item.release_date].filter(Boolean).join(' · ');+ const cover=item.cover_url+ ?`<img class="poster" src="${esc(item.cover_url)}" alt="" loading="lazy" referrerpolicy="no-referrer" data-drop="self">`+ :'<span class="nopic">无封面</span>';+ /* 点击区自己一个类,不共用 `.cardopenhit`:那一个是「在 Peach 里打开这条」的落点,+ 全站按它认站内跳转(`test_follow_web` 盯着它不许变成外链)。这一条通向别人的站。 */+ const open=item.link+ ?`<a class="feednewopen" href="${esc(item.link)}" target="_blank" rel="noreferrer" aria-label="打开 ${esc(item.code)} 的作品页"></a>`:'';+ return `<article class="card feednewcard${item.read?' isread':''}" data-feed-id="${item.id}">+ ${open}<div class="pic" style="--card-ratio:${COVER_FRONT_RATIO}">${cover}+ <div class="hovertools feednewtools">+ <button type="button" data-feed-action="ignore" title="不想看" aria-label="不想看 ${esc(item.code)}">${icon('x')}</button>+ <button type="button" data-feed-action="read" title="标为已看过" aria-label="标为已看过 ${esc(item.code)}">${icon('check')}</button></div></div>+ <div class="meta"><div class="mtext"><b class="t mono">${esc(item.code)}</b>+ <div class="s mono">${esc(item.title||item.performers||'资料还没取到')}</div>+ ${label?`<div class="s mono">${esc(label)}</div>`:''}</div></div></article>`;+}++/* 拉取由定时器做,页面只读已经发现的那些:进这一页顺手发一轮请求,等于把用户的每次+ 刷新都变成对别人服务器的一次拉取,而订阅的间隔本来就是按天算的。 */+async function renderFeedNew(host,entityId){+ if(!host)return;+ const query=new URLSearchParams({limit:'12'});+ if(entityId)query.set('entity',String(entityId));+ const data=await api('/api/feeds/discoveries?'+query).catch(()=>null);+ const items=data&&!data.error?(data.items||[]):[];+ if(!items.length){host.hidden=true;host.innerHTML='';return}+ host.hidden=false;+ host.innerHTML=`<h3 class="feednewtitle disp">新作 · 未入库</h3>+ <div class="feednewrow srow">${items.map(feedNewCardHtml).join('')}</div>`;+ host.querySelectorAll('[data-feed-action]').forEach(button=>button.onclick=async()=>{+ const card=button.closest('[data-feed-id]');+ const action=button.dataset.feedAction;+ await api('/api/feeds/discovery',{method:'POST',+ body:JSON.stringify({action,ids:[Number(card.dataset.feedId)]})}).catch(()=>null);+ // 忽略的那条当场消失,已看过的留在原位只是变淡:已读是标记,不是关掉。+ if(action==='ignore')card.remove();else card.classList.add('isread');+ if(!host.querySelector('[data-feed-id]'))host.hidden=true;+ });+ wireDrag(host.querySelector('.feednewrow'));+ wireHorizontalScroller(host.querySelector('.feednewrow'));+}+/* 外链是别人服务器上的东西,会在我们不知情的时候烂掉——实测 719 条里 152 条打不开,而它们在资料页上和好链接长得一模一样,只有点下去才知道。所以检查要能随时重跑,不是一次性脚本。放在资源同步上面:两块都是「把库里的记录和外部现实对齐」。 */@@ -8024,12 +8078,16 @@ async function openEntity(kind,name,push=true){${links?`<div class="entitylinks">${links}</div>`:''}${entryMarks?`<div class="entrymarks">${entryMarks}</div>`:''}</div></div>${related?`<div class="entityfoot" aria-label="同台艺人"><div class="relatedpeople">${related}</div></div>`:''}</section>+ <section class="feednew" data-feed-new aria-label="新作 · 未入库" hidden></section><div class="combo entitycombo"></div><section class="entitytagbar" aria-label="媒体与标签">${mediaToggle}${mediaToggle?'<span class="sep" aria-hidden="true"></span>':''}<div class="filterscroll"><div class="viewpills entityviews" role="group" aria-label="观看状态">${VIEW_PILLS.map(v=>`<button type="button" class="pill" data-entity-state="${v.k}" aria-pressed="${(filters.state||'')===v.k}">${v.label}</button>`).join('')}<span class="sep" aria-hidden="true"></span></div><div class="tagscroll entitytags">${tags}</div></div></section><div class="entitysection"></div>`;/* 圆框角上那个加号。自动挑的那张按来源优先级来,而那个顺序回答的是「先试哪一张」,不是「哪一张适合当头像」:图库排第一的常是写真封面,同一个人往下翻几张就有片商的正脸原图。换完重进这一页——头像索引在服务端已经失效过一次,重画才读得到新图。 */+ /* 关注的这位有新作、库里还没有文件时,那一行摆在资料卡和作品之间:它讲的是这个人,+ 但不是这一页的正文。一条都没有就整块不出(`renderFeedNew` 自己判)。 */+ if(d.id)void renderFeedNew($('#index').querySelector('[data-feed-new]'),Number(d.id));const pickerHost=$('#index').querySelector('[data-avatar-picker]');if(pickerHost&&d.id)import('/dist/peach-ui.js').then(ui=>ui.mountIsland('avatar-picker',pickerHost,{kind,entityId:Number(d.id),name:d.canonical_name||name,@@ -8659,6 +8717,13 @@ async function load(reset){// 已经挂着就让它接着跑:重挂要先清空容器,而它这一刻要说的话跟上一刻是同一句。if(reset&&isCatalogPath(location.pathname)&&!islandMounted($('#libraryProcessingNotice')))void mountIsland('library-processing',$('#libraryProcessingNotice'),{toast,mode:'notice'},{isCurrent:()=>surfaceCurrent(surface)});+ /* 新作那一行只在目录路径上出现:管理页、回收站这些页面回答的是别的问题,一行「外面出了+ 什么」摆在那里只是噪音。离开目录时要显式收起——它是 `#main` 的固定子节点,没人收就+ 一直挂在那儿。 */+ if(reset){+ if(isCatalogPath(location.pathname))void renderFeedNew($('#feedNew'));+ else{$('#feedNew').hidden=true;$('#feedNew').innerHTML=''}+ }if(!reset&&listLoading)return;if(!reset)listLoading=true;const pageOffset=reset?0:offset+appSettings.batchSize;diff --git a/web/css/12-cards.css b/web/css/12-cards.cssindex 9b9d51ef2..dcdc55552 100644--- a/web/css/12-cards.css+++ b/web/css/12-cards.css@@ -457,3 +457,25 @@ body[data-density="dense"] .card .meta .watchcount{display:none}.srow{display:flex;gap:13px;overflow-x:auto;padding-bottom:7px}.srow .scard{flex:none;width:214px;cursor:pointer}body[data-density="dense"] .shorts-inline .scard{width:calc(214px * 168 / 336)}++/* 订阅源发现的新作(ADR-0041)。横排复用 `.srow`,卡片复用 `.card` 的封套与元数据;+ * 这里只定宽度、淡出已读那一档,以及那两颗悬浮动作键——其余形态跟着资产卡走,+ * 两种卡长得不一样的地方只应该是它们真的不一样的地方。 */+.feednew{margin:0 0 18px}+.feednewtitle{margin:0 0 10px;font-size:var(--fs-sm);letter-spacing:.08em;color:var(--muted)}+.feednewrow{padding-bottom:7px}+.feednewcard{flex:none;width:168px}+/* 已看过的不移走,只退到背景里:已读是标记,不是关掉。 */+.feednewcard.isread{opacity:.55}+/* 通向作品页的点击区。形态同 `.cardopenhit`,但那一个的语义是站内落点,这一条是外链。 */+.feednewopen{position:absolute;inset:0;z-index:1;border-radius:inherit}+.feednewopen:focus-visible{outline:2px solid var(--tungsten);outline-offset:2px}+/* 两颗动作键沿用 `.hovertools` 的磨砂圆底,只换尺寸和落点。`.hovertools` 默认+ `pointer-events:none`——那是为了让指针落到底下的预览上,而这两颗是这张卡唯一能按的+ 东西,所以在显形的同时把点击收回来。 */+.feednewtools{inset:auto 7px 7px auto;gap:6px}+.feednewcard:hover .feednewtools,.feednewcard:focus-within .feednewtools{opacity:1}+.feednewcard:hover .feednewtools button,.feednewcard:focus-within .feednewtools button{pointer-events:auto}+.feednewtools button{width:32px;height:32px}+.feednewtools button svg{width:17px;height:17px}+.feednewcard .meta .t{font-size:var(--fs-sm)}diff --git a/web/dist/peach-react.js b/web/dist/peach-react.jsindex deb5b45a7..677b541f4 100644--- a/web/dist/peach-react.js+++ b/web/dist/peach-react.js@@ -31957,8 +31957,146 @@ async function vD(e) {});}//#endregion+//#region src/react/settings/feed-settings.tsx+function yD(e) {+ let t = e.last_fetched_at ? `上次拉取 ${new Date(e.last_fetched_at).toLocaleString()}` : "还没拉过", n = e.interval_minutes >= 60 ? `每 ${Math.round(e.interval_minutes / 60)} 小时一次` : `每 ${e.interval_minutes} 分钟一次`;+ return `${e.kind_label} · ${n} · ${t} · 上次新增 ${e.last_new_count} 条`;+}+function bD() {+ let [e, t] = (0, C.useState)(null), [n, r] = (0, C.useState)(""), i = (0, C.useCallback)(async (e) => {+ try {+ let n = await Qm("/api/feeds", e);+ Array.isArray(n?.sources) && t(n);+ } catch (t) {+ e?.aborted || r(q(t));+ }+ }, []);+ (0, C.useEffect)(() => {+ let e = new AbortController();+ return i(e.signal), () => e.abort();+ }, [i]);+ let a = e?.kinds ?? [], [o, s] = (0, C.useState)(""), [c, l] = (0, C.useState)(""), [u, d] = (0, C.useState)(""), [f, p] = (0, C.useState)("6"), m = _b(), h = (e) => {+ e.preventDefault();+ let t = Math.round(Number(f) * 60);+ m.run("add", (e) => $m("/api/feeds/source", {+ action: "add",+ kind: o || a[0]?.value,+ url: c.trim(),+ name: u.trim(),+ interval_minutes: Number.isFinite(t) ? t : void 0+ }, "POST", e), () => {+ l(""), d(""), i();+ });+ }, g = (e, t) => {+ m.run(`enabled-${e.id}`, (n) => $m("/api/feeds/source", {+ action: "enabled",+ id: e.id,+ enabled: t+ }, "POST", n), () => void i());+ }, _ = (e) => {+ m.run(`remove-${e.id}`, (t) => $m("/api/feeds/source", {+ action: "remove",+ id: e.id+ }, "POST", t), () => void i());+ };+ return e ? /* @__PURE__ */ (0, w.jsxs)(MS, {+ title: "订阅源",+ onSubmit: h,+ children: [+ e.sources.length ? /* @__PURE__ */ (0, w.jsx)(NS, { children: e.sources.map((e) => /* @__PURE__ */ (0, w.jsx)(kS, {+ label: e.name || e.url,+ description: yD(e),+ children: /* @__PURE__ */ (0, w.jsxs)("div", {+ className: "flex items-center gap-1",+ children: [/* @__PURE__ */ (0, w.jsx)(Ib, {+ "aria-label": `启用 ${e.name || e.url}`,+ isSelected: e.enabled,+ onChange: (t) => g(e, t)+ }), /* @__PURE__ */ (0, w.jsx)(qy, {+ icon: Rf,+ "aria-label": `移除 ${e.name || e.url}`,+ onClick: () => _(e),+ ...Z(m.busy === `remove-${e.id}`)+ })]+ })+ }, e.id)) }) : null,+ /* @__PURE__ */ (0, w.jsxs)(PS, {+ divided: e.sources.length > 0,+ children: [+ e.sources.filter((e) => e.last_error).map((e) => /* @__PURE__ */ (0, w.jsx)(J, {+ tone: "error",+ title: `${e.name || e.url} 拉取失败`,+ children: e.last_error+ }, e.id)),+ /* @__PURE__ */ (0, w.jsxs)("div", {+ className: "inline-grid grid-cols-1 gap-3 @lg:grid-cols-2",+ children: [/* @__PURE__ */ (0, w.jsxs)("div", {+ className: "flex flex-col gap-1.5",+ children: [/* @__PURE__ */ (0, w.jsx)(RS, { children: "来源类型" }), /* @__PURE__ */ (0, w.jsx)(Qw, {+ "aria-label": "来源类型",+ selectedKey: o || a[0]?.value,+ onSelectionChange: (e) => {+ e !== null && s(String(e));+ },+ children: a.map((e) => /* @__PURE__ */ (0, w.jsx)($w, {+ id: e.value,+ textValue: e.label,+ children: e.label+ }, e.value))+ })]+ }), /* @__PURE__ */ (0, w.jsx)(eb, {+ label: "拉取间隔(小时)",+ inputMode: "decimal",+ value: f,+ onChange: p,+ hint: `最短 ${e.min_interval_minutes} 分钟。`+ })]+ }),+ /* @__PURE__ */ (0, w.jsx)(eb, {+ label: "订阅地址",+ placeholder: "https://",+ value: c,+ onChange: l,+ hint: "RSS/Atom 的地址,或 JavDB 的演员页地址。只收 HTTPS。"+ }),+ /* @__PURE__ */ (0, w.jsx)(eb, {+ label: "名称",+ maxLength: 80,+ placeholder: "不填就用地址",+ value: u,+ onChange: d+ }),+ m.error ? /* @__PURE__ */ (0, w.jsx)(LS, { children: m.error }) : null,+ /* @__PURE__ */ (0, w.jsx)(IS, { children: "订阅只发现番号、建一条「未入库」的新作,不下载任何文件。新作在首页和人物页里看。" })+ ]+ }),+ /* @__PURE__ */ (0, w.jsxs)(FS, {+ status: e.unread ? `有 ${e.unread} 条新作还没看` : "新作都看过了",+ children: [/* @__PURE__ */ (0, w.jsx)(X, {+ onClick: () => {+ m.run("check", (e) => $m("/api/feeds/check", { all: !0 }, "POST", e), () => void i());+ },+ ...Z(m.busy === "check"),+ children: "立即拉取"+ }), /* @__PURE__ */ (0, w.jsx)(X, {+ type: "submit",+ ...Z(m.busy === "add"),+ children: "添加订阅"+ })]+ })+ ]+ }) : /* @__PURE__ */ (0, w.jsx)(MS, {+ title: "订阅源",+ children: /* @__PURE__ */ (0, w.jsx)(PS, { children: n ? /* @__PURE__ */ (0, w.jsx)(J, {+ tone: "error",+ title: "打不开订阅源",+ children: n+ }) : /* @__PURE__ */ (0, w.jsx)(IS, { children: "正在读订阅源。" }) })+ });+}+//#endregion//#region src/react/settings/entry-links-settings.tsx-function yD({ initial: e, receipt: t }) {+function xD({ initial: e, receipt: t }) {let [n, r] = (0, C.useState)(e.sites), i = _b(), a = (e, t) => r((n) => n.map((n) => n.key === e ? {...n,host: t@@ -31998,19 +32136,19 @@ function yD({ initial: e, receipt: t }) {}//#endregion//#region src/react/settings/general-settings.tsx-function bD({ data: e, receipt: t }) {+function SD({ data: e, receipt: t }) {return /* @__PURE__ */ (0, w.jsxs)("div", {className: "flex flex-col gap-6",- children: [e.startup ? /* @__PURE__ */ (0, w.jsx)(xD, {+ children: [e.startup ? /* @__PURE__ */ (0, w.jsx)(CD, {startup: e.startup,receipt: t- }) : null, e.entry_links ? /* @__PURE__ */ (0, w.jsx)(yD, {+ }) : null, e.entry_links ? /* @__PURE__ */ (0, w.jsx)(xD, {initial: e.entry_links,receipt: t}) : null]});}-function xD({ startup: e, receipt: t }) {+function CD({ startup: e, receipt: t }) {let [n, r] = (0, C.useState)(e.enabled), [i, a] = (0, C.useState)(e.silent), [o, s] = (0, C.useState)(e.desktop), c = _b(), l = e.available && !e.desktop_message;return /* @__PURE__ */ (0, w.jsxs)(MS, {title: "开机自启",@@ -32068,7 +32206,7 @@ function xD({ startup: e, receipt: t }) {}//#endregion//#region src/react/settings/media-repair.tsx-var SD = {+var wD = {status: "idle",stage: "",checked: 0,@@ -32078,16 +32216,16 @@ var SD = {failed: 0,skipped: 0,message: ""-}, CD = (e) => Number(e).toLocaleString();-function wD(e) {+}, TD = (e) => Number(e).toLocaleString();+function ED(e) {if (e.status === "running") {- let t = e.total ? `${CD(e.checked)} / ${CD(e.total)}` : "准备中";+ let t = e.total ? `${TD(e.checked)} / ${TD(e.total)}` : "准备中";return e.stage === "修复" && e.message ? `修复 ${t} · ${e.message}` : `${e.stage || "扫描"} ${t}`;}- return e.status === "complete" && (e.repaired || e.failed) ? e.failed ? `修好 ${CD(e.repaired)} 部,${CD(e.failed)} 部修不了` : `修好 ${CD(e.repaired)} 部` : "";+ return e.status === "complete" && (e.repaired || e.failed) ? e.failed ? `修好 ${TD(e.repaired)} 部,${TD(e.failed)} 部修不了` : `修好 ${TD(e.repaired)} 部` : "";}-function TD({ initial: e }) {- let [t, n] = (0, C.useState)(e || SD), [r, i] = (0, C.useState)(!1), a = _b(), o = t.status === "running";+function DD({ initial: e }) {+ let [t, n] = (0, C.useState)(e || wD), [r, i] = (0, C.useState)(!1), a = _b(), o = t.status === "running";(0, C.useEffect)(() => {let e = new AbortController(), t, r = async () => {try {@@ -32125,9 +32263,9 @@ function TD({ initial: e }) {}) : null,a.error || t.error ? /* @__PURE__ */ (0, w.jsx)(LS, { children: a.error || t.error }) : null] }), /* @__PURE__ */ (0, w.jsx)(FS, {- status: wD(t) ? /* @__PURE__ */ (0, w.jsx)("p", {+ status: ED(t) ? /* @__PURE__ */ (0, w.jsx)("p", {role: "status",- children: wD(t)+ children: ED(t)}) : null,children: o ? /* @__PURE__ */ (0, w.jsx)(X, {onClick: c,@@ -32143,23 +32281,23 @@ function TD({ initial: e }) {}//#endregion//#region src/react/settings/release-updates.tsx-var ED = /* @__PURE__ */ new Set([+var OD = /* @__PURE__ */ new Set(["downloading","verifying","extracting","preparing","restarting","installing"-]), DD = [+]), kD = [65,67,90-], OD = 120;-function kD({ initial: e, initialJob: t }) {+], AD = 120;+function jD({ initial: e, initialJob: t }) {let [n, r] = (0, C.useState)(e), [i, a] = (0, C.useState)(t || {state: "idle",progress: 0- }), [o, s] = (0, C.useState)(""), l = _b(), u = (0, C.useRef)(!1), d = (0, C.useRef)(!0), f = ED.has(i.state);+ }), [o, s] = (0, C.useState)(""), l = _b(), u = (0, C.useRef)(!1), d = (0, C.useRef)(!0), f = OD.has(i.state);(0, C.useEffect)(() => (d.current = !0, () => {d.current = !1;}), []);@@ -32176,7 +32314,7 @@ function kD({ initial: e, initialJob: t }) {(0, C.useEffect)(() => {i.state !== "ready" || u.current || (u.current = !0, m());}, [i.state]), (0, C.useEffect)(() => {- let e = new AbortController(), t = ED.has(i.state) ? 1e3 : 3e4, n, o = 0, c = async () => {+ let e = new AbortController(), t = OD.has(i.state) ? 1e3 : 3e4, n, o = 0, c = async () => {try {let t = await Qm("/api/configuration/update-status", e.signal);if (e.signal.aborted) return;@@ -32189,9 +32327,9 @@ function kD({ initial: e, initialJob: t }) {let n = await Qm("/api/configuration/automatic-updates", e.signal);!e.signal.aborted && n.result && r(n.result);} catch {- o += 1, o >= OD && !e.signal.aborted && s("尚未连接到 Peach,请检查托盘后刷新页面。");+ o += 1, o >= AD && !e.signal.aborted && s("尚未连接到 Peach,请检查托盘后刷新页面。");}- !e.signal.aborted && o < OD && (n = setTimeout(c, t));+ !e.signal.aborted && o < AD && (n = setTimeout(c, t));};return n = setTimeout(c, t), () => {e.abort(), clearTimeout(n);@@ -32246,7 +32384,7 @@ function kD({ initial: e, initialJob: t }) {/* @__PURE__ */ (0, w.jsx)(fh, {label: "更新准备进度",value: i.progress,- stops: DD+ stops: kD}),/* @__PURE__ */ (0, w.jsxs)(IS, { children: ["下载 → 校验 → 解压 → 准备安装 · ", i.message] }),/* @__PURE__ */ (0, w.jsx)(IS, { children: v })@@ -32282,37 +32420,37 @@ function kD({ initial: e, initialJob: t }) {}//#endregion//#region src/react/settings/maintenance-settings.tsx-var AD = [+var MD = [["6", "每 6 小时"],["24", "每天"],["168", "每周"]];-function jD({ data: e, receipt: t, reopenTutorial: n }) {+function ND({ data: e, receipt: t, reopenTutorial: n }) {return /* @__PURE__ */ (0, w.jsxs)("div", {className: "flex flex-col gap-6",children: [- e.automatic_updates ? /* @__PURE__ */ (0, w.jsx)(ND, {+ e.automatic_updates ? /* @__PURE__ */ (0, w.jsx)(FD, {initial: e.automatic_updates,receipt: t}) : null,- e.updates ? /* @__PURE__ */ (0, w.jsx)(kD, {+ e.updates ? /* @__PURE__ */ (0, w.jsx)(jD, {initial: e.updates,initialJob: e.update_job}) : null,- /* @__PURE__ */ (0, w.jsx)(TD, {}),- /* @__PURE__ */ (0, w.jsx)(PD, { facts: e.facts }),- /* @__PURE__ */ (0, w.jsx)(MD, {+ /* @__PURE__ */ (0, w.jsx)(DD, {}),+ /* @__PURE__ */ (0, w.jsx)(ID, { facts: e.facts }),+ /* @__PURE__ */ (0, w.jsx)(PD, {receipt: t,reopenTutorial: n}),- e.uninstall ? /* @__PURE__ */ (0, w.jsx)(FD, {+ e.uninstall ? /* @__PURE__ */ (0, w.jsx)(LD, {uninstall: e.uninstall,receipt: t}) : null]});}-function MD({ receipt: e, reopenTutorial: t }) {+function PD({ receipt: e, reopenTutorial: t }) {let n = _b();return /* @__PURE__ */ (0, w.jsxs)(MS, {title: "安装教程",@@ -32323,7 +32461,7 @@ function MD({ receipt: e, reopenTutorial: t }) {}) })]});}-function ND({ initial: e, receipt: t }) {+function FD({ initial: e, receipt: t }) {let [n, r] = (0, C.useState)(e.mode), [i, a] = (0, C.useState)(e.interval_hours), o = _b(e.error), s = (r) => {r.preventDefault(), e.available && o.run("save", (e) => $m("/api/configuration/automatic-updates", {mode: n,@@ -32363,7 +32501,7 @@ function ND({ initial: e, receipt: t }) {onSelectionChange: (e) => {e !== null && a(Number(e));},- children: AD.map(([e, t]) => /* @__PURE__ */ (0, w.jsx)($w, {+ children: MD.map(([e, t]) => /* @__PURE__ */ (0, w.jsx)($w, {id: e,children: t}, e))@@ -32383,7 +32521,7 @@ function ND({ initial: e, receipt: t }) {]});}-function PD({ facts: e }) {+function ID({ facts: e }) {return /* @__PURE__ */ (0, w.jsx)(MS, {title: "运行信息",children: /* @__PURE__ */ (0, w.jsx)(BS, { children: e.map((e) => /* @__PURE__ */ (0, w.jsxs)(VS, {@@ -32395,7 +32533,7 @@ function PD({ facts: e }) {}, e.term)) })});}-function FD({ uninstall: e, receipt: t }) {+function LD({ uninstall: e, receipt: t }) {let [n, r] = (0, C.useState)(!1), [i, a] = (0, C.useState)(""), o = () => void c({title: "卸载 Peach",danger: !0,@@ -32444,7 +32582,7 @@ function FD({ uninstall: e, receipt: t }) {}//#endregion//#region src/react/settings/clouddrive-guide.tsx-var ID = [+var RD = [{name: "机械硬盘,或内存 8 GB 以内",cache: "10–20 GiB",@@ -32463,12 +32601,12 @@ var ID = [read: "256 / 128 KB",task: "2 个起步"}-], LD = [+], zD = [["cache", "缓存上限"],["read", "读取长度(默认 / 最小)"],["task", "同时处理视频"]];-function RD() {+function BD() {return /* @__PURE__ */ (0, w.jsxs)("div", {className: "@container flex flex-col gap-3",children: [/* @__PURE__ */ (0, w.jsxs)(IS, { children: ["先在 CloudDrive 登录网盘并挂载,开启「启动时自动挂载」。", /* @__PURE__ */ (0, w.jsx)(zS, {@@ -32481,14 +32619,14 @@ function RD() {/* @__PURE__ */ (0, w.jsx)("ul", {"aria-label": "按缓存所在硬盘分档",className: "flex flex-col gap-2",- children: ID.map((e) => /* @__PURE__ */ (0, w.jsxs)("li", {+ children: RD.map((e) => /* @__PURE__ */ (0, w.jsxs)("li", {className: "flex flex-col gap-2 rounded-2lg border border-separator-border bg-background-primary-default p-3",children: [/* @__PURE__ */ (0, w.jsx)("p", {className: "text-body-medium text-text-primary",children: e.name}), /* @__PURE__ */ (0, w.jsx)("dl", {className: "inline-grid grid-cols-1 gap-2 @md:grid-cols-3",- children: LD.map(([t, n]) => /* @__PURE__ */ (0, w.jsxs)("div", {+ children: zD.map(([t, n]) => /* @__PURE__ */ (0, w.jsxs)("div", {className: "flex flex-col",children: [/* @__PURE__ */ (0, w.jsx)("dt", {className: "text-caption-1-regular text-text-secondary",@@ -32523,7 +32661,7 @@ function RD() {}//#endregion//#region src/react/settings/library-icon-picker.tsx-var zD = [+var VD = [["", "自动识别"],["hard-drive", "磁盘"],["database", "资料库"],@@ -32567,13 +32705,13 @@ var zD = [["star", "收藏"],["tags", "主题"]];-function BD(e) {+function HD(e) {let t = e === "local" ? "" : o[e];return t ? [t, "自动识别"] : ["hard-drive", "默认"];}-var VD = "auto";-function HD({ value: e, label: t, kind: n = "local", onChange: r }) {- let i = (0, C.useRef)(null), [a, o] = (0, C.useState)(!1), [s, c] = (0, C.useState)(e), [l, u] = BD(n);+var UD = "auto";+function WD({ value: e, label: t, kind: n = "local", onChange: r }) {+ let i = (0, C.useRef)(null), [a, o] = (0, C.useState)(!1), [s, c] = (0, C.useState)(e), [l, u] = HD(n);return /* @__PURE__ */ (0, w.jsxs)(w.Fragment, { children: [/* @__PURE__ */ (0, w.jsx)(X, {ref: i,variant: "secondary",@@ -32587,7 +32725,7 @@ function HD({ value: e, label: t, kind: n = "local", onChange: r }) {children: /* @__PURE__ */ (0, w.jsxs)("span", {"data-icon-choice": !0,className: "flex items-center gap-2",- children: [/* @__PURE__ */ (0, w.jsx)(WS, { mark: e || l }), ((e) => e && zD.find(([t]) => t === e)?.[1] || u)(e)]+ children: [/* @__PURE__ */ (0, w.jsx)(WS, { mark: e || l }), ((e) => e && VD.find(([t]) => t === e)?.[1] || u)(e)]})}), /* @__PURE__ */ (0, w.jsx)(X_, {triggerRef: i,@@ -32607,15 +32745,15 @@ function HD({ value: e, label: t, kind: n = "local", onChange: r }) {}),/* @__PURE__ */ (0, w.jsx)(_v, {"aria-label": "候选图标",- value: s || VD,- onChange: (e) => c(e === VD ? "" : e),+ value: s || UD,+ onChange: (e) => c(e === UD ? "" : e),className: "inline-grid grid-cols-7 gap-1",- children: zD.map(([e, t]) => /* @__PURE__ */ (0, w.jsx)(vv, {- value: e || VD,+ children: VD.map(([e, t]) => /* @__PURE__ */ (0, w.jsx)(vv, {+ value: e || UD,"aria-label": e ? t : u,className: "flex h-10 cursor-pointer items-center justify-center rounded-lg text-foreground-icon-secondary outline-none hover:bg-dropdown-item-hover-background focus-visible:ring-2 focus-visible:ring-border-focus-ring data-selected:bg-dropdown-item-hover-background data-selected:text-text-primary",children: /* @__PURE__ */ (0, w.jsx)(WS, { mark: e || l })- }, e || VD))+ }, e || UD))}),/* @__PURE__ */ (0, w.jsxs)("div", {className: "flex justify-end gap-2 border-t border-separator-border pt-2.5",@@ -32637,8 +32775,8 @@ function HD({ value: e, label: t, kind: n = "local", onChange: r }) {}//#endregion//#region src/react/settings/push-discovery-settings.tsx-var UD = "/api/configuration/push-discovery", WD = "/api/configuration/push-discovery/secret";-function GD({ initial: e, receipt: t }) {+var GD = "/api/configuration/push-discovery", KD = "/api/configuration/push-discovery/secret";+function qD({ initial: e, receipt: t }) {let [n, r] = (0, C.useState)(e), [i, a] = (0, C.useState)(e.prefixes), [o, s] = (0, C.useState)(""), c = _b(), l = n.media_roots, u = (e, n) => {r(e), a(e.prefixes), s(""), t(n);}, d = (e, t) => a((n) => n.map((n, r) => r === e ? {@@ -32655,7 +32793,7 @@ function GD({ initial: e, receipt: t }) {cloud: n.cloud,prefixes: i};- c.run("save", (e) => $m(UD, t, "POST", e), (e) => u(e, "已保存配置"), (e) => s(q(e)));+ c.run("save", (e) => $m(GD, t, "POST", e), (e) => u(e, "已保存配置"), (e) => s(q(e)));},children: [/* @__PURE__ */ (0, w.jsxs)(NS, { children: [@@ -32777,7 +32915,7 @@ function GD({ initial: e, receipt: t }) {status: "CloudDrive2 那一侧要填的地址、密钥与设置步骤见帮助文档。",children: [/* @__PURE__ */ (0, w.jsx)(X, {onClick: () => {- c.run("secret", (e) => $m(WD, {}, "POST", e), (e) => u(e, "已更换共享密钥"), (e) => s(q(e)));+ c.run("secret", (e) => $m(KD, {}, "POST", e), (e) => u(e, "已更换共享密钥"), (e) => s(q(e)));},disabled: !n.available,...Z(c.busy === "secret"),@@ -32794,8 +32932,8 @@ function GD({ initial: e, receipt: t }) {}//#endregion//#region src/react/settings/media-settings.tsx-var KD = 8e3;-function qD({ className: e }) {+var JD = 8e3;+function YD({ className: e }) {return /* @__PURE__ */ (0, w.jsx)("svg", {"aria-hidden": !0,viewBox: "0 0 24 24",@@ -32808,33 +32946,33 @@ function qD({ className: e }) {children: /* @__PURE__ */ (0, w.jsx)("use", { href: "#i-folder-search" })});}-var JD = [+var XD = [["local", "本地磁盘"],["115", "CloudDrive · 115"],["pikpak", "CloudDrive · PikPak"]-], YD = (e) => JD.find(([t]) => t === e)?.[1] ?? e, XD = (e) => o[e] || "database", ZD = (e = "") => ({+], ZD = (e) => XD.find(([t]) => t === e)?.[1] ?? e, QD = (e) => o[e] || "database", $D = (e = "") => ({path: e,location: "local",root: "",library: "",library_icon: ""});-function QD(e) {- let t = e.media_sources?.filter((e) => JD.some(([t]) => t === e.location));+function eO(e) {+ let t = e.media_sources?.filter((e) => XD.some(([t]) => t === e.location));return t?.length ? t.map((e) => ({path: e.path,location: e.location,root: e.root,library: e.library || "",library_icon: e.library_icon || ""- })) : (e.media_dirs.length ? e.media_dirs : [""]).map((e) => ZD(e));+ })) : (e.media_dirs.length ? e.media_dirs : [""]).map((e) => $D(e));}-var $D = (e) => !(e instanceof Xm) || e.status !== 400 ? null : e.body?.errors ?? null;-function eO({ data: e, receipt: t }) {+var tO = (e) => !(e instanceof Xm) || e.status !== 400 ? null : e.body?.errors ?? null;+function nO({ data: e, receipt: t }) {return /* @__PURE__ */ (0, w.jsxs)("div", {className: "flex flex-col gap-6",children: [- e.editable ? /* @__PURE__ */ (0, w.jsx)(tO, {+ e.editable ? /* @__PURE__ */ (0, w.jsx)(rO, {data: e,receipt: t}) : /* @__PURE__ */ (0, w.jsx)(J, {@@ -32842,21 +32980,21 @@ function eO({ data: e, receipt: t }) {title: "只读",children: e.notice}),- /* @__PURE__ */ (0, w.jsx)(rO, { data: e }),- e.push_discovery ? /* @__PURE__ */ (0, w.jsx)(GD, {+ /* @__PURE__ */ (0, w.jsx)(aO, { data: e }),+ e.push_discovery ? /* @__PURE__ */ (0, w.jsx)(qD, {initial: e.push_discovery,receipt: t}) : null]});}-function tO({ data: e, receipt: t }) {- let [n, r] = (0, C.useState)(() => QD(e)), [i, a] = (0, C.useState)(String(e.port)), [o, s] = (0, C.useState)(!1), [c, l] = (0, C.useState)([]), [u, d] = (0, C.useState)(""), [f, p] = (0, C.useState)(""), [m, h] = (0, C.useState)(null), [g, _] = (0, C.useState)(null), [v, y] = (0, C.useState)(null), b = (0, C.useRef)(!1), x = (0, C.useRef)(e.revision), S = (0, C.useRef)([]), T = _b();+function rO({ data: e, receipt: t }) {+ let [n, r] = (0, C.useState)(() => eO(e)), [i, a] = (0, C.useState)(String(e.port)), [o, s] = (0, C.useState)(!1), [c, l] = (0, C.useState)([]), [u, d] = (0, C.useState)(""), [f, p] = (0, C.useState)(""), [m, h] = (0, C.useState)(null), [g, _] = (0, C.useState)(null), [v, y] = (0, C.useState)(null), b = (0, C.useRef)(!1), x = (0, C.useRef)(e.revision), S = (0, C.useRef)([]), T = _b();(0, C.useLayoutEffect)(() => {g !== null && (S.current[g]?.focus(), _(null));}, [g]), (0, C.useEffect)(() => {if (!m) return;- let e = setTimeout(() => location.assign(m.url), KD);+ let e = setTimeout(() => location.assign(m.url), JD);return () => clearTimeout(e);}, [m]);let E = (e, t) => r((n) => n.map((n, r) => r === e ? {@@ -32867,7 +33005,7 @@ function tO({ data: e, receipt: t }) {for (; r.length <= e;) r.push("");return r[e] = t, r;}), O = () => {- _(n.length), r((e) => [...e, ZD()]);+ _(n.length), r((e) => [...e, $D()]);}, k = (e) => {r((t) => t.filter((t, n) => n !== e)), l((t) => t.filter((t, n) => n !== e));}, A = async (e) => {@@ -32892,7 +33030,7 @@ function tO({ data: e, receipt: t }) {}, "POST", t), (e) => {x.current = e.revision, l([]), d(""), t("已保存配置"), h(e);}, (e) => {- let t = $D(e);+ let t = tO(e);l(t?.media_dirs ?? []), d(t?.port ?? ""), t || p(q(e));});};@@ -32945,7 +33083,7 @@ function tO({ data: e, receipt: t }) {hint: c[r] || void 0}),/* @__PURE__ */ (0, w.jsx)(qy, {- icon: qD,+ icon: YD,"aria-label": "选择文件夹",onClick: () => void A(r),...Z(v === r)@@ -32968,7 +33106,7 @@ function tO({ data: e, receipt: t }) {}),/* @__PURE__ */ (0, w.jsxs)("div", {className: "flex flex-col gap-1.5",- children: [/* @__PURE__ */ (0, w.jsx)(RS, { children: "媒体库图标" }), /* @__PURE__ */ (0, w.jsx)(HD, {+ children: [/* @__PURE__ */ (0, w.jsx)(RS, { children: "媒体库图标" }), /* @__PURE__ */ (0, w.jsx)(WD, {label: `媒体库图标 ${r + 1}`,value: t.library_icon,kind: t.location,@@ -32983,10 +33121,10 @@ function tO({ data: e, receipt: t }) {onSelectionChange: (e) => {e !== null && E(r, { location: String(e) });},- children: JD.map(([e, t]) => /* @__PURE__ */ (0, w.jsxs)($w, {+ children: XD.map(([e, t]) => /* @__PURE__ */ (0, w.jsxs)($w, {id: e,textValue: t,- children: [/* @__PURE__ */ (0, w.jsx)(WS, { mark: XD(e) }), t]+ children: [/* @__PURE__ */ (0, w.jsx)(WS, { mark: QD(e) }), t]}, e))})]}),@@ -33007,7 +33145,7 @@ function tO({ data: e, receipt: t }) {})]}),- M ? /* @__PURE__ */ (0, w.jsx)(RD, {}) : null,+ M ? /* @__PURE__ */ (0, w.jsx)(BD, {}) : null,N.map((e) => /* @__PURE__ */ (0, w.jsxs)(IS, { children: ["未检测到 ",e.name,@@ -33048,7 +33186,7 @@ function tO({ data: e, receipt: t }) {})]});}-function nO({ online: e }) {+function iO({ online: e }) {return e === !0 ? /* @__PURE__ */ (0, w.jsxs)("span", {"data-mount": "online",className: "inline-flex items-center gap-1.5 text-body-2-medium text-notification-success-foreground",@@ -33072,14 +33210,14 @@ function nO({ online: e }) {}), "未检测"]});}-function rO({ data: e }) {+function aO({ data: e }) {let t = e.media_sources, n = _b();return t ? /* @__PURE__ */ (0, w.jsxs)(MS, {title: "挂载状态",children: [/* @__PURE__ */ (0, w.jsx)(BS, { children: t.map((e, t) => /* @__PURE__ */ (0, w.jsxs)(VS, {- term: /* @__PURE__ */ (0, w.jsxs)(w.Fragment, { children: [/* @__PURE__ */ (0, w.jsx)(WS, { mark: XD(e.location) }), YD(e.location)] }),- children: [e.path || "未配置挂载点", /* @__PURE__ */ (0, w.jsx)(nO, { online: e.online })]+ term: /* @__PURE__ */ (0, w.jsxs)(w.Fragment, { children: [/* @__PURE__ */ (0, w.jsx)(WS, { mark: QD(e.location) }), ZD(e.location)] }),+ children: [e.path || "未配置挂载点", /* @__PURE__ */ (0, w.jsx)(iO, { online: e.online })]}, t)) }),n.error ? /* @__PURE__ */ (0, w.jsx)(PS, {divided: !0,@@ -33095,12 +33233,12 @@ function rO({ data: e }) {}//#endregion//#region src/react/settings/access-settings.tsx-var iO = {+var oO = {legacy: "当前使用系统生成的访问口令。改设自己的密码,或关闭登录要求。",locked: "访问设置无法读取,请在本机检查配置文件。",password: "已设置密码。新设备需要登录,保持登录时间在登录页选择。"};-function aO({ initial: e, receipt: t }) {+function sO({ initial: e, receipt: t }) {let [n, r] = (0, C.useState)(e), [i, a] = (0, C.useState)(""), [o, s] = (0, C.useState)(""), [c, l] = (0, C.useState)(""), [u, d] = (0, C.useState)(!1), [f, p] = (0, C.useState)({}), m = (0, C.useRef)(null), h = _b(), g = (e) => {e.preventDefault();let f = {};@@ -33121,7 +33259,7 @@ function aO({ initial: e, receipt: t }) {let t = e instanceof Xm ? e.body : null, n = t?.errors || t?.detail?.errors;n ? p(n) : h.setError(q(e));});- }, _ = iO[n.mode], v = n.mode !== "locked";+ }, _ = oO[n.mode], v = n.mode !== "locked";return /* @__PURE__ */ (0, w.jsxs)(MS, {title: "访问密码",onSubmit: g,@@ -33198,11 +33336,11 @@ function aO({ initial: e, receipt: t }) {}//#endregion//#region src/react/settings/tunnel-settings.tsx-var oO = 2e3, sO = [["quick", "临时链接"], ["named", "命名隧道"]], cO = {+var cO = 2e3, lO = [["quick", "临时链接"], ["named", "命名隧道"]], uO = {quick: "只用于临时预览;地址随机、重启后会变化。启动前必须设置访问密码。",named: "地址是 Cloudflare 后台绑定的公开主机名,重启后不变。启动前必须设置访问密码,身份策略在 Cloudflare Access 里配置。"};-function lO({ revision: e, initial: t, receipt: n }) {+function dO({ revision: e, initial: t, receipt: n }) {let [r, i] = (0, C.useState)(t), [a, o] = (0, C.useState)(e), [s, c] = (0, C.useState)(t.mode), [l, u] = (0, C.useState)(t.hostname), [d, f] = (0, C.useState)(""), [p, m] = (0, C.useState)({}), h = _b(), g = r.state === "starting" || r.state === "running", _ = r.named_available && s === "named";(0, C.useEffect)(() => {if (r.state !== "starting") return;@@ -33210,7 +33348,7 @@ function lO({ revision: e, initial: t, receipt: n }) {_D(e.signal).then((t) => {e.signal.aborted || !t.tunnel || (ph.setQueryData(gD, t), i(t.tunnel), o(t.revision));}).catch(() => void 0);- }, oO);+ }, cO);return () => {e.abort(), window.clearInterval(t);};@@ -33241,13 +33379,13 @@ function lO({ revision: e, initial: t, receipt: n }) {isDisabled: g,onChange: (e) => c(e),className: fS,- children: sO.map(([e, t]) => /* @__PURE__ */ (0, w.jsx)(vv, {+ children: lO.map(([e, t]) => /* @__PURE__ */ (0, w.jsx)(vv, {value: e,className: pS,children: t}, e))}) : null,- /* @__PURE__ */ (0, w.jsx)(IS, { children: cO[_ ? "named" : "quick"] }),+ /* @__PURE__ */ (0, w.jsx)(IS, { children: uO[_ ? "named" : "quick"] }),_ ? /* @__PURE__ */ (0, w.jsxs)(w.Fragment, { children: [/* @__PURE__ */ (0, w.jsx)(eb, {id: "tunnel-hostname",label: "公开主机名",@@ -33307,24 +33445,24 @@ function lO({ revision: e, initial: t, receipt: n }) {}//#endregion//#region src/react/settings/network-settings.tsx-var uO = [+var fO = [["environment", "系统代理"],["direct", "直连"],["proxy", "自定义"]];-function dO({ data: e, receipt: t }) {+function pO({ data: e, receipt: t }) {return /* @__PURE__ */ (0, w.jsxs)("div", {className: "flex flex-col gap-6",children: [- e.peach_proxy ? /* @__PURE__ */ (0, w.jsx)(fO, {+ e.peach_proxy ? /* @__PURE__ */ (0, w.jsx)(mO, {initial: e.peach_proxy,receipt: t}) : null,- e.access ? /* @__PURE__ */ (0, w.jsx)(aO, {+ e.access ? /* @__PURE__ */ (0, w.jsx)(sO, {initial: e.access,receipt: t}) : null,- e.tunnel ? /* @__PURE__ */ (0, w.jsx)(lO, {+ e.tunnel ? /* @__PURE__ */ (0, w.jsx)(dO, {revision: e.revision,initial: e.tunnel,receipt: t@@ -33332,7 +33470,7 @@ function dO({ data: e, receipt: t }) {]});}-function fO({ initial: e, receipt: t }) {+function mO({ initial: e, receipt: t }) {let [n, r] = (0, C.useState)(e), [i, a] = (0, C.useState)(e.mode), [o, s] = (0, C.useState)(""), c = _b();return /* @__PURE__ */ (0, w.jsxs)(MS, {id: "peachProxy",@@ -33355,7 +33493,7 @@ function fO({ initial: e, receipt: t }) {onSelectionChange: (e) => {e !== null && a(String(e));},- children: uO.map(([e, t]) => /* @__PURE__ */ (0, w.jsx)($w, {+ children: fO.map(([e, t]) => /* @__PURE__ */ (0, w.jsx)($w, {id: e,children: t}, e))@@ -33391,7 +33529,7 @@ function fO({ initial: e, receipt: t }) {}//#endregion//#region src/react/settings/configuration-page.tsx-function pO({ receipt: e, reopenTutorial: t }) {+function hO({ receipt: e, reopenTutorial: t }) {let n = ut({queryKey: gD,queryFn: ({ signal: e }) => _D(e)@@ -33407,30 +33545,33 @@ function pO({ receipt: e, reopenTutorial: t }) {let i = {data: r,receipt: e- }, a = !!(r.startup || r.entry_links), o = !!(r.peach_proxy || r.access || r.tunnel);+ }, a = !!(r.peach_proxy || r.access || r.tunnel);return /* @__PURE__ */ (0, w.jsxs)("div", {className: "configpage",children: [- a ? /* @__PURE__ */ (0, w.jsx)("h2", {+ /* @__PURE__ */ (0, w.jsx)("h2", {className: "configgroup",children: "通用"- }) : null,- a ? /* @__PURE__ */ (0, w.jsx)(bD, { ...i }) : null,+ }),+ /* @__PURE__ */ (0, w.jsxs)("div", {+ className: "flex flex-col gap-6",+ children: [/* @__PURE__ */ (0, w.jsx)(SD, { ...i }), /* @__PURE__ */ (0, w.jsx)(bD, {})]+ }),/* @__PURE__ */ (0, w.jsx)("h2", {className: "configgroup",children: "媒体"}),- /* @__PURE__ */ (0, w.jsx)(eO, { ...i }),- o ? /* @__PURE__ */ (0, w.jsx)("h2", {+ /* @__PURE__ */ (0, w.jsx)(nO, { ...i }),+ a ? /* @__PURE__ */ (0, w.jsx)("h2", {className: "configgroup",children: "网络与访问"}) : null,- o ? /* @__PURE__ */ (0, w.jsx)(dO, { ...i }) : null,+ a ? /* @__PURE__ */ (0, w.jsx)(pO, { ...i }) : null,/* @__PURE__ */ (0, w.jsx)("h2", {className: "configgroup",children: "更新与维护"}),- /* @__PURE__ */ (0, w.jsx)(jD, {+ /* @__PURE__ */ (0, w.jsx)(ND, {...i,reopenTutorial: t})@@ -33439,15 +33580,15 @@ function pO({ receipt: e, reopenTutorial: t }) {}//#endregion//#region src/react/stats/stats.ts-var mO = "/api/stats", hO = ["stats"], gO = (e) => Qm(mO, e);-async function _O(e) {+var gO = "/api/stats", _O = ["stats"], vO = (e) => Qm(gO, e);+async function yO(e) {await ph.fetchQuery({- queryKey: hO,- queryFn: () => gO(e)+ queryKey: _O,+ queryFn: () => vO(e)});}-var vO = (e, t) => t ? Math.round(e / t * 100) : 0, yO = (e) => e >= 3600 ? `${(e / 3600).toFixed(1)} 小时` : `${Math.round(e / 60)} 分钟`, bO = (e) => e.duration ? Math.min(e.play_seconds / e.duration, 1) * 100 : 0, xO = (e) => (e.max_reached || 0) * 100, SO = (e) => e.kind === "online" ? "在线直接观看" : bO(e) < xO(e) - 25 ? "快进扫过" : e.o_count ? `高潮 ${e.o_count}` : "正常观看", CO = (e) => `${e.kind === "online" ? "/follow/item/" : "/item/"}${e.id}`;-function wO(e) {+var bO = (e, t) => t ? Math.round(e / t * 100) : 0, xO = (e) => e >= 3600 ? `${(e / 3600).toFixed(1)} 小时` : `${Math.round(e / 60)} 分钟`, SO = (e) => e.duration ? Math.min(e.play_seconds / e.duration, 1) * 100 : 0, CO = (e) => (e.max_reached || 0) * 100, wO = (e) => e.kind === "online" ? "在线直接观看" : SO(e) < CO(e) - 25 ? "快进扫过" : e.o_count ? `高潮 ${e.o_count}` : "正常观看", TO = (e) => `${e.kind === "online" ? "/follow/item/" : "/item/"}${e.id}`;+function EO(e) {let t = Math.max(1, ...e) * 1.1, n = Math.min(22, 110 / Math.max(1, e.length)), r = Math.min(15, n * .68);return e.map((e, i) => ({radius: 32 + i * n,@@ -33457,7 +33598,7 @@ function wO(e) {}//#endregion//#region src/react/components/expandable-ranking.tsx-function TO({ children: e, className: t = "", previewCount: n = 10 }) {+function DO({ children: e, className: t = "", previewCount: n = 10 }) {let r = (0, C.useId)(), i = (0, C.useRef)(null), [a, o] = (0, C.useState)(!1), [s, c] = (0, C.useState)(!1), l = C.Children.toArray(e), u = l.length > n;(0, C.useLayoutEffect)(() => {let e = i.current;@@ -33504,21 +33645,21 @@ function TO({ children: e, className: t = "", previewCount: n = 10 }) {}//#endregion//#region src/react/stats/radial-card.tsx-var EO = [+var OO = ["stroke-chart-1","stroke-chart-2","stroke-chart-3","stroke-chart-4","stroke-chart-5","stroke-chart-6"-], DO = [+], kO = ["bg-chart-1","bg-chart-2","bg-chart-3","bg-chart-4","bg-chart-5","bg-chart-6"-], OO = [+], AO = ["aria-pressed:bg-chart-1/10 aria-pressed:ring-chart-1","aria-pressed:bg-chart-2/10 aria-pressed:ring-chart-2","aria-pressed:bg-chart-3/10 aria-pressed:ring-chart-3",@@ -33526,10 +33667,10 @@ var EO = ["aria-pressed:bg-chart-5/10 aria-pressed:ring-chart-5","aria-pressed:bg-chart-6/10 aria-pressed:ring-chart-6"];-function kO({ title: e, rows: t, unit: n = "个视频" }) {+function jO({ title: e, rows: t, unit: n = "个视频" }) {let [r, i] = (0, C.useState)(-1), [a, o] = (0, C.useState)(-1), s = t.filter((e) => Number.isFinite(e.value) && e.value >= 0);if (!s.length) return null;- let c = a >= 0 ? a : r, l = s.reduce((e, t) => e + t.value, 0), u = wO(s.map((e) => e.value)), d = s[c], f = (e) => i((t) => t === e ? -1 : e);+ let c = a >= 0 ? a : r, l = s.reduce((e, t) => e + t.value, 0), u = EO(s.map((e) => e.value)), d = s[c], f = (e) => i((t) => t === e ? -1 : e);return /* @__PURE__ */ (0, w.jsxs)("section", {className: `${sh({ radius: "chart" })} flex flex-col gap-4 max-sm:p-4`,children: [@@ -33578,7 +33719,7 @@ function kO({ title: e, rows: t, unit: n = "个视频" }) {pathLength: 100,transform: "rotate(-90 160 160)",strokeDasharray: `${u[t].length} ${100 - u[t].length}`,- className: c >= 0 && c !== t ? `cursor-pointer opacity-30 transition-opacity ${EO[t % 6]}` : `cursor-pointer transition-opacity ${EO[t % 6]}`+ className: c >= 0 && c !== t ? `cursor-pointer opacity-30 transition-opacity ${OO[t % 6]}` : `cursor-pointer transition-opacity ${OO[t % 6]}`})]}, e.name))@@ -33593,13 +33734,13 @@ function kO({ title: e, rows: t, unit: n = "个视频" }) {onPointerLeave: () => o(-1),onFocus: () => o(t),onBlur: () => o(-1),- className: `flex min-w-0 cursor-pointer flex-col items-start gap-1 rounded-xl bg-background-tertiary-default p-2.5 text-left outline-none aria-pressed:ring-1 aria-pressed:ring-inset focus-visible:ring-2 focus-visible:ring-border-focus-ring ${OO[t % 6]}`,+ className: `flex min-w-0 cursor-pointer flex-col items-start gap-1 rounded-xl bg-background-tertiary-default p-2.5 text-left outline-none aria-pressed:ring-1 aria-pressed:ring-inset focus-visible:ring-2 focus-visible:ring-border-focus-ring ${AO[t % 6]}`,children: [/* @__PURE__ */ (0, w.jsxs)("span", {className: "flex min-w-0 items-center gap-1.5 text-caption-1-regular text-text-secondary",children: [/* @__PURE__ */ (0, w.jsx)("i", {"aria-hidden": !0,- className: `size-3 shrink-0 rounded-sm ${DO[t % 6]}`+ className: `size-3 shrink-0 rounded-sm ${kO[t % 6]}`}), e.name]}),/* @__PURE__ */ (0, w.jsx)("b", {@@ -33618,8 +33759,8 @@ function kO({ title: e, rows: t, unit: n = "个视频" }) {}//#endregion//#region src/react/stats/stats-page.tsx-var AO = 10, jO = `${sh()} flex flex-col gap-4`, MO = "添加媒体文件夹或关注来源后,这里会显示馆藏统计。", NO = "补全资料或添加标签后,这里会显示馆藏中的内容标签。", PO = "开始播放后,这里会显示最近的真实观看证据。", FO = "刮削或手动打标之后,这里会显示每个来源覆盖了多少视频。", IO = "添加媒体文件夹后,这里会显示存储空间。";-function LO({ term: e, value: t }) {+var MO = 10, NO = `${sh()} flex flex-col gap-4`, PO = "添加媒体文件夹或关注来源后,这里会显示馆藏统计。", FO = "补全资料或添加标签后,这里会显示馆藏中的内容标签。", IO = "开始播放后,这里会显示最近的真实观看证据。", LO = "刮削或手动打标之后,这里会显示每个来源覆盖了多少视频。", RO = "添加媒体文件夹后,这里会显示存储空间。";+function zO({ term: e, value: t }) {return /* @__PURE__ */ (0, w.jsxs)("div", {className: "flex min-h-16 min-w-0 flex-col gap-1.5 rounded-2lg bg-background-primary-default p-3",children: [/* @__PURE__ */ (0, w.jsx)("span", {@@ -33631,7 +33772,7 @@ function LO({ term: e, value: t }) {})]});}-function RO({ term: e, value: t, total: n }) {+function BO({ term: e, value: t, total: n }) {return /* @__PURE__ */ (0, w.jsxs)("div", {className: "flex flex-col gap-1.5 border-b border-separator-border py-3 last:border-b-0",children: [/* @__PURE__ */ (0, w.jsxs)("p", {@@ -33640,7 +33781,7 @@ function RO({ term: e, value: t, total: n }) {className: "tabular-nums",children: [t.toLocaleString(), /* @__PURE__ */ (0, w.jsxs)("span", {className: "ml-1.5 text-caption-1-regular text-text-secondary",- children: [vO(t, n), "%"]+ children: [bO(t, n), "%"]})]})]}), /* @__PURE__ */ (0, w.jsx)(fh, {@@ -33650,7 +33791,7 @@ function RO({ term: e, value: t, total: n }) {})]});}-function zO({ term: e, figure: t, unit: n }) {+function VO({ term: e, figure: t, unit: n }) {return /* @__PURE__ */ (0, w.jsxs)("div", {className: "flex shrink-0 flex-col gap-0.5 pb-5 md:w-64 md:pr-6 md:pb-0",children: [@@ -33669,26 +33810,26 @@ function zO({ term: e, figure: t, unit: n }) {]});}-function BO({ headline: e, children: t }) {+function HO({ headline: e, children: t }) {return /* @__PURE__ */ (0, w.jsxs)("div", {- className: `${jO} md:flex-row md:gap-6`,+ className: `${NO} md:flex-row md:gap-6`,children: [e, /* @__PURE__ */ (0, w.jsx)("div", {className: "min-w-0 grow",children: t})]});}-function VO({ data: t, configurable: r, openMediaSettings: i }) {+function UO({ data: t, configurable: r, openMediaSettings: i }) {return t.by_loc.reduce((e, t) => e + t.videos, 0) ? /* @__PURE__ */ (0, w.jsxs)("div", {className: "inline-grid w-full gap-5 md:grid-cols-2",- children: [/* @__PURE__ */ (0, w.jsx)(kO, {+ children: [/* @__PURE__ */ (0, w.jsx)(jO, {title: "网盘与本地",rows: t.by_loc.map((t) => ({name: e[t.k] ?? t.k,value: t.videos,detail: n(t.bytes)}))- }), /* @__PURE__ */ (0, w.jsx)(kO, {+ }), /* @__PURE__ */ (0, w.jsx)(jO, {title: "媒体库",rows: t.by_library.map((e) => ({name: e.name,@@ -33709,35 +33850,35 @@ function VO({ data: t, configurable: r, openMediaSettings: i }) {size: "small",children: "添加关注"})] }),- children: MO+ children: PO});}-function HO({ attribution: e }) {+function WO({ attribution: e }) {let t = e.videos;return /* @__PURE__ */ (0, w.jsxs)("div", {className: "flex flex-col",children: [- /* @__PURE__ */ (0, w.jsx)(RO, {+ /* @__PURE__ */ (0, w.jsx)(BO, {term: "有创作者",value: e.creator,total: t}),- /* @__PURE__ */ (0, w.jsx)(RO, {+ /* @__PURE__ */ (0, w.jsx)(BO, {term: "有番号",value: e.code,total: t}),- /* @__PURE__ */ (0, w.jsx)(RO, {+ /* @__PURE__ */ (0, w.jsx)(BO, {term: "有厂牌",value: e.studio,total: t}),- /* @__PURE__ */ (0, w.jsx)(RO, {+ /* @__PURE__ */ (0, w.jsx)(BO, {term: "已抽帧",value: e.thumb,total: t}),- /* @__PURE__ */ (0, w.jsx)(RO, {+ /* @__PURE__ */ (0, w.jsx)(BO, {term: "已探测时长",value: e.duration,total: t@@ -33745,7 +33886,7 @@ function HO({ attribution: e }) {]});}-function UO({ volume: e }) {+function GO({ volume: e }) {let t = e.total, r = e.used ?? 0;return /* @__PURE__ */ (0, w.jsxs)("article", {className: "flex min-w-0 flex-col gap-1.5",@@ -33757,7 +33898,7 @@ function UO({ volume: e }) {children: e.label}), /* @__PURE__ */ (0, w.jsx)("b", {className: "text-body-2-medium whitespace-nowrap text-text-primary",- children: t == null ? e.online ? "容量未取得" : "离线" : `${vO(r, t)}%`+ children: t == null ? e.online ? "容量未取得" : "离线" : `${bO(r, t)}%`})]}),/* @__PURE__ */ (0, w.jsx)("small", {@@ -33781,10 +33922,10 @@ function UO({ volume: e }) {]});}-function WO({ volumes: e, configurable: t, openMediaSettings: n }) {+function KO({ volumes: e, configurable: t, openMediaSettings: n }) {return e.length ? /* @__PURE__ */ (0, w.jsx)("div", {className: "flex flex-col gap-5",- children: e.map((e) => /* @__PURE__ */ (0, w.jsx)(UO, { volume: e }, `${e.kind}:${e.label}`))+ children: e.map((e) => /* @__PURE__ */ (0, w.jsx)(GO, { volume: e }, `${e.kind}:${e.label}`))}) : /* @__PURE__ */ (0, w.jsx)(lh, {shell: "plain",icon: Jf,@@ -33794,12 +33935,12 @@ function WO({ volumes: e, configurable: t, openMediaSettings: n }) {onClick: n,children: "添加媒体文件夹"}) : void 0,- children: IO+ children: RO});}-function GO({ tags: e, tagLabel: t, onTag: n }) {- return e.length ? /* @__PURE__ */ (0, w.jsx)(TO, {- previewCount: AO,+function qO({ tags: e, tagLabel: t, onTag: n }) {+ return e.length ? /* @__PURE__ */ (0, w.jsx)(DO, {+ previewCount: MO,className: "inline-grid w-full gap-x-6 gap-y-1 sm:grid-cols-2",children: e.map((e, r) => /* @__PURE__ */ (0, w.jsx)("li", {className: "min-w-0",@@ -33832,14 +33973,14 @@ function GO({ tags: e, tagLabel: t, onTag: n }) {size: "small",children: "补全资料"}),- children: NO+ children: FO});}-function KO({ rows: e }) {+function JO({ rows: e }) {return e.length ? /* @__PURE__ */ (0, w.jsx)("div", {className: "flex flex-col gap-5",children: e.map((e) => {- let t = bO(e);+ let t = SO(e);return /* @__PURE__ */ (0, w.jsxs)("article", {className: "flex flex-wrap items-center gap-x-6 gap-y-2",children: [/* @__PURE__ */ (0, w.jsxs)("div", {@@ -33847,14 +33988,14 @@ function KO({ rows: e }) {children: [/* @__PURE__ */ (0, w.jsx)("h3", {className: "min-w-0 text-body-2-medium text-text-primary",children: /* @__PURE__ */ (0, w.jsx)("a", {- href: CO(e),+ href: TO(e),"data-middle-truncate": !0,className: "block max-w-full overflow-hidden whitespace-nowrap hover:underline",children: e.name})}), /* @__PURE__ */ (0, w.jsxs)("p", {className: "flex flex-wrap gap-3 text-caption-1-regular text-text-secondary",- children: [/* @__PURE__ */ (0, w.jsx)("span", { children: e.creator ?? "" }), /* @__PURE__ */ (0, w.jsx)("span", { children: SO(e) })]+ children: [/* @__PURE__ */ (0, w.jsx)("span", { children: e.creator ?? "" }), /* @__PURE__ */ (0, w.jsx)("span", { children: wO(e) })]})]}), /* @__PURE__ */ (0, w.jsxs)("div", {className: "min-w-0 basis-40",@@ -33863,7 +34004,7 @@ function KO({ rows: e }) {value: t}), /* @__PURE__ */ (0, w.jsx)("small", {className: "mt-1.5 block text-caption-1-regular text-text-secondary",- children: `真实 ${t.toFixed(0)}% · 到达 ${xO(e).toFixed(0)}%`+ children: `真实 ${t.toFixed(0)}% · 到达 ${CO(e).toFixed(0)}%`})]})]}, `${e.kind}:${e.id}`);@@ -33877,10 +34018,10 @@ function KO({ rows: e }) {size: "small",children: "浏览馆藏"}),- children: PO+ children: IO});}-function qO({ sources: e, videos: t }) {+function YO({ sources: e, videos: t }) {return e.length ? /* @__PURE__ */ (0, w.jsx)("div", {className: "inline-grid w-full gap-x-8 gap-y-6 sm:grid-cols-2",children: e.map((e) => /* @__PURE__ */ (0, w.jsxs)("article", {@@ -33919,10 +34060,10 @@ function qO({ sources: e, videos: t }) {size: "small",children: "补全资料"}),- children: FO+ children: LO});}-function JO({ id: e, label: t, figure: n, detail: r, icon: i, accent: a }) {+function XO({ id: e, label: t, figure: n, detail: r, icon: i, accent: a }) {return /* @__PURE__ */ (0, w.jsx)(Ry, {id: e,className: gS({@@ -33938,17 +34079,17 @@ function JO({ id: e, label: t, figure: n, detail: r, icon: i, accent: a }) {})});}-function YO(e) {+function ZO(e) {let t = ut({- queryKey: hO,- queryFn: ({ signal: e }) => gO(e)+ queryKey: _O,+ queryFn: ({ signal: e }) => vO(e)}), r = t.data;if (!r) return /* @__PURE__ */ (0, w.jsx)(dh, { children: /* @__PURE__ */ (0, w.jsx)(J, {tone: "error",title: "读取失败",children: t.error ? q(t.error) : "读取统计失败"}) });- let i = r.consumption, a = r.storage_summary, o = r.by_loc.reduce((e, t) => e + t.videos, 0), s = r.by_loc.reduce((e, t) => e + t.bytes, 0), c = vO(r.tag_cov, r.attribution.videos);+ let i = r.consumption, a = r.storage_summary, o = r.by_loc.reduce((e, t) => e + t.videos, 0), s = r.by_loc.reduce((e, t) => e + t.bytes, 0), c = bO(r.tag_cov, r.attribution.videos);return /* @__PURE__ */ (0, w.jsxs)(dh, { children: [/* @__PURE__ */ (0, w.jsx)("p", {className: "text-caption-1-regular text-text-secondary",@@ -33961,7 +34102,7 @@ function YO(e) {"aria-label": "统计视图",className: _S,children: [- /* @__PURE__ */ (0, w.jsx)(JO, {+ /* @__PURE__ */ (0, w.jsx)(XO, {id: "inventory",label: "馆藏视频",icon: Vf,@@ -33969,15 +34110,15 @@ function YO(e) {figure: o.toLocaleString(),detail: n(s)}),- /* @__PURE__ */ (0, w.jsx)(JO, {+ /* @__PURE__ */ (0, w.jsx)(XO, {id: "viewing",label: "看过",icon: Gf,accent: 1,figure: i.played.toLocaleString(),- detail: yO(i.play_seconds)+ detail: xO(i.play_seconds)}),- /* @__PURE__ */ (0, w.jsx)(JO, {+ /* @__PURE__ */ (0, w.jsx)(XO, {id: "coverage",label: "内容标签",icon: np,@@ -33985,7 +34126,7 @@ function YO(e) {figure: `${c}%`,detail: `${r.tag_cov.toLocaleString()} / ${r.attribution.videos.toLocaleString()}`}),- /* @__PURE__ */ (0, w.jsx)(JO, {+ /* @__PURE__ */ (0, w.jsx)(XO, {id: "storage",label: "使用空间",icon: Jf,@@ -33997,15 +34138,15 @@ function YO(e) {}),/* @__PURE__ */ (0, w.jsx)(zy, {id: "inventory",- children: /* @__PURE__ */ (0, w.jsx)(VO, {+ children: /* @__PURE__ */ (0, w.jsx)(UO, {data: r,...e})}),/* @__PURE__ */ (0, w.jsx)(zy, {id: "viewing",- children: /* @__PURE__ */ (0, w.jsx)(BO, {- headline: /* @__PURE__ */ (0, w.jsx)(zO, {+ children: /* @__PURE__ */ (0, w.jsx)(HO, {+ headline: /* @__PURE__ */ (0, w.jsx)(VO, {term: "观看",figure: i.played.toLocaleString(),unit: "个作品有播放记录"@@ -34013,31 +34154,31 @@ function YO(e) {children: /* @__PURE__ */ (0, w.jsxs)("div", {className: "inline-grid w-full gap-3 sm:grid-cols-2",children: [- /* @__PURE__ */ (0, w.jsx)(LO, {+ /* @__PURE__ */ (0, w.jsx)(zO, {term: "馆藏观看",value: i.library_played}),- /* @__PURE__ */ (0, w.jsx)(LO, {+ /* @__PURE__ */ (0, w.jsx)(zO, {term: "在线直接观看",value: i.online_played}),- /* @__PURE__ */ (0, w.jsx)(LO, {+ /* @__PURE__ */ (0, w.jsx)(zO, {term: "高潮计数",value: i.o_total}),- /* @__PURE__ */ (0, w.jsx)(LO, {+ /* @__PURE__ */ (0, w.jsx)(zO, {term: "快进扫过",value: i.skimmed}),- /* @__PURE__ */ (0, w.jsx)(LO, {+ /* @__PURE__ */ (0, w.jsx)(zO, {term: "明确不喜欢",value: i.dislike}),- /* @__PURE__ */ (0, w.jsx)(LO, {+ /* @__PURE__ */ (0, w.jsx)(zO, {term: "看过了",value: i.seen}),- /* @__PURE__ */ (0, w.jsx)(LO, {+ /* @__PURE__ */ (0, w.jsx)(zO, {term: "回收站",value: i.trash})@@ -34047,24 +34188,24 @@ function YO(e) {}),/* @__PURE__ */ (0, w.jsx)(zy, {id: "coverage",- children: /* @__PURE__ */ (0, w.jsx)(BO, {- headline: /* @__PURE__ */ (0, w.jsx)(zO, {+ children: /* @__PURE__ */ (0, w.jsx)(HO, {+ headline: /* @__PURE__ */ (0, w.jsx)(VO, {term: "内容标签覆盖",figure: `${c}%`,unit: `${r.tag_cov.toLocaleString()} / ${r.attribution.videos.toLocaleString()}`}),- children: /* @__PURE__ */ (0, w.jsx)(HO, { attribution: r.attribution })+ children: /* @__PURE__ */ (0, w.jsx)(WO, { attribution: r.attribution })})}),/* @__PURE__ */ (0, w.jsx)(zy, {id: "storage",- children: /* @__PURE__ */ (0, w.jsx)(BO, {- headline: /* @__PURE__ */ (0, w.jsx)(zO, {+ children: /* @__PURE__ */ (0, w.jsx)(HO, {+ headline: /* @__PURE__ */ (0, w.jsx)(VO, {term: "使用空间",figure: String(a.measured),unit: "个卷已取得容量"}),- children: /* @__PURE__ */ (0, w.jsx)(WO, {+ children: /* @__PURE__ */ (0, w.jsx)(KO, {volumes: r.storage_volumes,...e})@@ -34102,7 +34243,7 @@ function YO(e) {/* @__PURE__ */ (0, w.jsx)(zy, {id: "tags",className: "px-4 pt-3.5 pb-4",- children: /* @__PURE__ */ (0, w.jsx)(GO, {+ children: /* @__PURE__ */ (0, w.jsx)(qO, {tags: r.top_tags,...e})@@ -34110,12 +34251,12 @@ function YO(e) {/* @__PURE__ */ (0, w.jsx)(zy, {id: "recent",className: "px-4 pt-3.5 pb-4",- children: /* @__PURE__ */ (0, w.jsx)(KO, { rows: r.recent })+ children: /* @__PURE__ */ (0, w.jsx)(JO, { rows: r.recent })}),/* @__PURE__ */ (0, w.jsx)(zy, {id: "sources",className: "px-4 pt-3.5 pb-4",- children: /* @__PURE__ */ (0, w.jsx)(qO, {+ children: /* @__PURE__ */ (0, w.jsx)(YO, {sources: r.tag_source,videos: r.attribution.videos})@@ -34126,7 +34267,7 @@ function YO(e) {}//#endregion//#region node_modules/d3-array/src/max.js-function XO(e, t) {+function QO(e, t) {let n;if (t === void 0) for (let t of e) t != null && (n < t || n === void 0 && t >= t) && (n = t);else {@@ -34137,7 +34278,7 @@ function XO(e, t) {}//#endregion//#region node_modules/d3-array/src/min.js-function ZO(e, t) {+function $O(e, t) {let n;if (t === void 0) for (let t of e) t != null && (n > t || n === void 0 && t >= t) && (n = t);else {@@ -34148,7 +34289,7 @@ function ZO(e, t) {}//#endregion//#region node_modules/d3-array/src/sum.js-function QO(e, t) {+function ek(e, t) {let n = 0;if (t === void 0) for (let t of e) (t = +t) && (n += t);else {@@ -34159,66 +34300,66 @@ function QO(e, t) {}//#endregion//#region node_modules/d3-sankey/src/align.js-function $O(e, t) {+function tk(e, t) {return e.sourceLinks.length ? e.depth : t - 1;}//#endregion//#region node_modules/d3-sankey/src/constant.js-function ek(e) {+function nk(e) {return function() {return e;};}//#endregion//#region node_modules/d3-sankey/src/sankey.js-function tk(e, t) {- return rk(e.source, t.source) || e.index - t.index;+function rk(e, t) {+ return ak(e.source, t.source) || e.index - t.index;}-function nk(e, t) {- return rk(e.target, t.target) || e.index - t.index;+function ik(e, t) {+ return ak(e.target, t.target) || e.index - t.index;}-function rk(e, t) {+function ak(e, t) {return e.y0 - t.y0;}-function ik(e) {+function ok(e) {return e.value;}-function ak(e) {+function sk(e) {return e.index;}-function ok(e) {+function ck(e) {return e.nodes;}-function sk(e) {+function lk(e) {return e.links;}-function ck(e, t) {+function uk(e, t) {let n = e.get(t);if (!n) throw Error("missing: " + t);return n;}-function lk({ nodes: e }) {+function dk({ nodes: e }) {for (let t of e) {let e = t.y0, n = e;for (let n of t.sourceLinks) n.y0 = e + n.width / 2, e += n.width;for (let e of t.targetLinks) e.y1 = n + e.width / 2, n += e.width;}}-function uk() {- let e = 0, t = 0, n = 1, r = 1, i = 24, a = 8, o, s = ak, c = $O, l, u, d = ok, f = sk, p = 6;+function fk() {+ let e = 0, t = 0, n = 1, r = 1, i = 24, a = 8, o, s = sk, c = tk, l, u, d = ck, f = lk, p = 6;function m() {let e = {nodes: d.apply(null, arguments),links: f.apply(null, arguments)};- return h(e), g(e), _(e), v(e), x(e), lk(e), e;+ return h(e), g(e), _(e), v(e), x(e), dk(e), e;}m.update = function(e) {- return lk(e), e;+ return dk(e), e;}, m.nodeId = function(e) {- return arguments.length ? (s = typeof e == "function" ? e : ek(e), m) : s;+ return arguments.length ? (s = typeof e == "function" ? e : nk(e), m) : s;}, m.nodeAlign = function(e) {- return arguments.length ? (c = typeof e == "function" ? e : ek(e), m) : c;+ return arguments.length ? (c = typeof e == "function" ? e : nk(e), m) : c;}, m.nodeSort = function(e) {return arguments.length ? (l = e, m) : l;}, m.nodeWidth = function(e) {@@ -34226,9 +34367,9 @@ function uk() {}, m.nodePadding = function(e) {return arguments.length ? (a = o = +e, m) : a;}, m.nodes = function(e) {- return arguments.length ? (d = typeof e == "function" ? e : ek(e), m) : d;+ return arguments.length ? (d = typeof e == "function" ? e : nk(e), m) : d;}, m.links = function(e) {- return arguments.length ? (f = typeof e == "function" ? e : ek(e), m) : f;+ return arguments.length ? (f = typeof e == "function" ? e : nk(e), m) : f;}, m.linkSort = function(e) {return arguments.length ? (u = e, m) : u;}, m.size = function(i) {@@ -34244,12 +34385,12 @@ function uk() {for (let [e, r] of t.entries()) {r.index = e;let { source: t, target: i } = r;- typeof t != "object" && (t = r.source = ck(n, t)), typeof i != "object" && (i = r.target = ck(n, i)), t.sourceLinks.push(r), i.targetLinks.push(r);+ typeof t != "object" && (t = r.source = uk(n, t)), typeof i != "object" && (i = r.target = uk(n, i)), t.sourceLinks.push(r), i.targetLinks.push(r);}if (u != null) for (let { sourceLinks: t, targetLinks: n } of e) t.sort(u), n.sort(u);}function g({ nodes: e }) {- for (let t of e) t.value = t.fixedValue === void 0 ? Math.max(QO(t.sourceLinks, ik), QO(t.targetLinks, ik)) : t.fixedValue;+ for (let t of e) t.value = t.fixedValue === void 0 ? Math.max(ek(t.sourceLinks, ok), ek(t.targetLinks, ok)) : t.fixedValue;}function _({ nodes: e }) {let t = e.length, n = new Set(e), r = /* @__PURE__ */ new Set(), i = 0;@@ -34274,7 +34415,7 @@ function uk() {}}function y({ nodes: t }) {- let r = XO(t, (e) => e.depth) + 1, a = (n - e - i) / (r - 1), o = Array(r);+ let r = QO(t, (e) => e.depth) + 1, a = (n - e - i) / (r - 1), o = Array(r);for (let n of t) {let t = Math.max(0, Math.min(r - 1, Math.floor(c.call(null, n, r))));n.layer = t, n.x0 = e + t * a, n.x1 = n.x0 + i, o[t] ? o[t].push(n) : o[t] = [n];@@ -34283,7 +34424,7 @@ function uk() {return o;}function b(e) {- let n = ZO(e, (e) => (r - t - (e.length - 1) * o) / QO(e, ik));+ let n = $O(e, (e) => (r - t - (e.length - 1) * o) / ek(e, ok));for (let i of e) {let e = t;for (let t of i) {@@ -34300,7 +34441,7 @@ function uk() {}function x(e) {let n = y(e);- o = Math.min(a, (r - t) / (XO(n, (e) => e.length) - 1)), b(n);+ o = Math.min(a, (r - t) / (QO(n, (e) => e.length) - 1)), b(n);for (let e = 0; e < p; ++e) {let t = .99 ** e, r = Math.max(1 - t, (e + 1) / p);C(n, t, r), S(n, t, r);@@ -34319,7 +34460,7 @@ function uk() {let i = (n / r - e.y0) * t;e.y0 += i, e.y1 += i, D(e);}- l === void 0 && i.sort(rk), w(i, n);+ l === void 0 && i.sort(ak), w(i, n);}}function C(e, t, n) {@@ -34335,7 +34476,7 @@ function uk() {let i = (n / r - e.y0) * t;e.y0 += i, e.y1 += i, D(e);}- l === void 0 && i.sort(rk), w(i, n);+ l === void 0 && i.sort(ak), w(i, n);}}function w(e, n) {@@ -34356,12 +34497,12 @@ function uk() {}function D({ sourceLinks: e, targetLinks: t }) {if (u === void 0) {- for (let { source: { sourceLinks: e } } of t) e.sort(nk);- for (let { target: { targetLinks: t } } of e) t.sort(tk);+ for (let { source: { sourceLinks: e } } of t) e.sort(ik);+ for (let { target: { targetLinks: t } } of e) t.sort(rk);}}function O(e) {- if (u === void 0) for (let { sourceLinks: t, targetLinks: n } of e) t.sort(nk), n.sort(tk);+ if (u === void 0) for (let { sourceLinks: t, targetLinks: n } of e) t.sort(ik), n.sort(rk);}function k(e, t) {let n = e.y0 - (e.sourceLinks.length - 1) * o / 2;@@ -34391,15 +34532,15 @@ function uk() {}//#endregion//#region node_modules/d3-path/src/path.js-var dk = Math.PI, fk = 2 * dk, pk = 1e-6, mk = fk - pk;-function hk() {+var pk = Math.PI, mk = 2 * pk, hk = 1e-6, gk = mk - hk;+function _k() {this._x0 = this._y0 = this._x1 = this._y1 = null, this._ = "";}-function gk() {- return new hk();+function vk() {+ return new _k();}-hk.prototype = gk.prototype = {- constructor: hk,+_k.prototype = vk.prototype = {+ constructor: _k,moveTo: function(e, t) {this._ += "M" + (this._x0 = this._x1 = +e) + "," + (this._y0 = this._y1 = +t);},@@ -34420,11 +34561,11 @@ hk.prototype = gk.prototype = {var a = this._x1, o = this._y1, s = n - e, c = r - t, l = a - e, u = o - t, d = l * l + u * u;if (i < 0) throw Error("negative radius: " + i);if (this._x1 === null) this._ += "M" + (this._x1 = e) + "," + (this._y1 = t);- else if (d > pk) {- if (!(Math.abs(u * s - c * l) > pk) || !i) this._ += "L" + (this._x1 = e) + "," + (this._y1 = t);+ else if (d > hk) {+ if (!(Math.abs(u * s - c * l) > hk) || !i) this._ += "L" + (this._x1 = e) + "," + (this._y1 = t);else {- var f = n - a, p = r - o, m = s * s + c * c, h = f * f + p * p, g = Math.sqrt(m), _ = Math.sqrt(d), v = i * Math.tan((dk - Math.acos((m + d - h) / (2 * g * _))) / 2), y = v / _, b = v / g;- Math.abs(y - 1) > pk && (this._ += "L" + (e + y * l) + "," + (t + y * u)), this._ += "A" + i + "," + i + ",0,0," + +(u * f > l * p) + "," + (this._x1 = e + b * s) + "," + (this._y1 = t + b * c);+ var f = n - a, p = r - o, m = s * s + c * c, h = f * f + p * p, g = Math.sqrt(m), _ = Math.sqrt(d), v = i * Math.tan((pk - Math.acos((m + d - h) / (2 * g * _))) / 2), y = v / _, b = v / g;+ Math.abs(y - 1) > hk && (this._ += "L" + (e + y * l) + "," + (t + y * u)), this._ += "A" + i + "," + i + ",0,0," + +(u * f > l * p) + "," + (this._x1 = e + b * s) + "," + (this._y1 = t + b * c);}}},@@ -34432,7 +34573,7 @@ hk.prototype = gk.prototype = {e = +e, t = +t, n = +n, a = !!a;var o = n * Math.cos(r), s = n * Math.sin(r), c = e + o, l = t + s, u = 1 ^ a, d = a ? r - i : i - r;if (n < 0) throw Error("negative radius: " + n);- this._x1 === null ? this._ += "M" + c + "," + l : (Math.abs(this._x1 - c) > pk || Math.abs(this._y1 - l) > pk) && (this._ += "L" + c + "," + l), n && (d < 0 && (d = d % fk + fk), d > mk ? this._ += "A" + n + "," + n + ",0,1," + u + "," + (e - o) + "," + (t - s) + "A" + n + "," + n + ",0,1," + u + "," + (this._x1 = c) + "," + (this._y1 = l) : d > pk && (this._ += "A" + n + "," + n + ",0," + +(d >= dk) + "," + u + "," + (this._x1 = e + n * Math.cos(i)) + "," + (this._y1 = t + n * Math.sin(i))));+ this._x1 === null ? this._ += "M" + c + "," + l : (Math.abs(this._x1 - c) > hk || Math.abs(this._y1 - l) > hk) && (this._ += "L" + c + "," + l), n && (d < 0 && (d = d % mk + mk), d > gk ? this._ += "A" + n + "," + n + ",0,1," + u + "," + (e - o) + "," + (t - s) + "A" + n + "," + n + ",0,1," + u + "," + (this._x1 = c) + "," + (this._y1 = l) : d > hk && (this._ += "A" + n + "," + n + ",0," + +(d >= pk) + "," + u + "," + (this._x1 = e + n * Math.cos(i)) + "," + (this._y1 = t + n * Math.sin(i))));},rect: function(e, t, n, r) {this._ += "M" + (this._x0 = this._x1 = +e) + "," + (this._y0 = this._y1 = +t) + "h" + +n + "v" + +r + "h" + -n + "Z";@@ -34443,90 +34584,90 @@ hk.prototype = gk.prototype = {};//#endregion//#region node_modules/d3-shape/src/constant.js-function _k(e) {+function yk(e) {return function() {return e;};}//#endregion//#region node_modules/d3-shape/src/point.js-function vk(e) {+function bk(e) {return e[0];}-function yk(e) {+function xk(e) {return e[1];}//#endregion//#region node_modules/d3-shape/src/array.js-var bk = Array.prototype.slice;+var Sk = Array.prototype.slice;//#endregion//#region node_modules/d3-shape/src/link/index.js-function xk(e) {+function Ck(e) {return e.source;}-function Sk(e) {+function wk(e) {return e.target;}-function Ck(e) {- var t = xk, n = Sk, r = vk, i = yk, a = null;+function Tk(e) {+ var t = Ck, n = wk, r = bk, i = xk, a = null;function o() {- var o, s = bk.call(arguments), c = t.apply(this, s), l = n.apply(this, s);- if (a ||= o = gk(), e(a, +r.apply(this, (s[0] = c, s)), +i.apply(this, s), +r.apply(this, (s[0] = l, s)), +i.apply(this, s)), o) return a = null, o + "" || null;+ var o, s = Sk.call(arguments), c = t.apply(this, s), l = n.apply(this, s);+ if (a ||= o = vk(), e(a, +r.apply(this, (s[0] = c, s)), +i.apply(this, s), +r.apply(this, (s[0] = l, s)), +i.apply(this, s)), o) return a = null, o + "" || null;}return o.source = function(e) {return arguments.length ? (t = e, o) : t;}, o.target = function(e) {return arguments.length ? (n = e, o) : n;}, o.x = function(e) {- return arguments.length ? (r = typeof e == "function" ? e : _k(+e), o) : r;+ return arguments.length ? (r = typeof e == "function" ? e : yk(+e), o) : r;}, o.y = function(e) {- return arguments.length ? (i = typeof e == "function" ? e : _k(+e), o) : i;+ return arguments.length ? (i = typeof e == "function" ? e : yk(+e), o) : i;}, o.context = function(e) {return arguments.length ? (a = e ?? null, o) : a;}, o;}-function wk(e, t, n, r, i) {+function Ek(e, t, n, r, i) {e.moveTo(t, n), e.bezierCurveTo(t = (t + r) / 2, n, t, i, r, i);}-function Tk() {- return Ck(wk);+function Dk() {+ return Tk(Ek);}//#endregion//#region node_modules/d3-sankey/src/sankeyLinkHorizontal.js-function Ek(e) {+function Ok(e) {return [e.source.x1, e.y0];}-function Dk(e) {+function kk(e) {return [e.target.x0, e.y1];}-function Ok() {- return Tk().source(Ek).target(Dk);+function Ak() {+ return Dk().source(Ok).target(kk);}//#endregion//#region src/react/taste/taste.ts-var kk = "/api/taste", Ak = "/api/taste/refresh", jk = "/api/taste/import", Mk = "/api/taste/source", Nk = (e) => ["taste", e], Pk = ["taste", "refresh"], Fk = [+var jk = "/api/taste", Mk = "/api/taste/refresh", Nk = "/api/taste/import", Pk = "/api/taste/source", Fk = (e) => ["taste", e], Ik = ["taste", "refresh"], Lk = [["7d", "最近 7 天"],["30d", "最近 30 天"],["90d", "最近 90 天"],["365d", "最近一年"],["all", "全部时间"]-], Ik = (e, t) => Qm(`${kk}?window=${e}`, t), Lk = (e) => Qm(Ak, e);-async function Rk(e, t) {+], Rk = (e, t) => Qm(`${jk}?window=${e}`, t), zk = (e) => Qm(Mk, e);+async function Bk(e, t) {await ph.fetchQuery({- queryKey: Nk(e),- queryFn: () => Ik(e, t)+ queryKey: Fk(e),+ queryFn: () => Rk(e, t)});}-var zk = (e) => $m(Ak, {+var Vk = (e) => $m(Mk, {window: e,background: !0-}), Bk = (e, t) => $m(Mk, {+}), Hk = (e, t) => $m(Pk, {operation: "remove",source_key: e,window: t});-async function Vk(e) {- let t = await fetch(jk, {+async function Uk(e) {+ let t = await fetch(Nk, {method: "POST",credentials: "same-origin",headers: {@@ -34544,34 +34685,34 @@ async function Vk(e) {}return n;}-var Hk = 2e3, Uk = 1e4, Wk = (e) => e?.status === "running" ? Hk : Uk, Gk = (e) => e ? new Date(e).toLocaleDateString("zh-CN") : "—", Kk = (e) => e >= 3600 ? `${(e / 3600).toFixed(1)} 小时` : `${Math.round(e / 60)} 分钟`, qk = (e) => Number(e.web_visits ?? e.score ?? e.visits ?? e.peach_items ?? 0);-function Jk(e) {+var Wk = 2e3, Gk = 1e4, Kk = (e) => e?.status === "running" ? Wk : Gk, qk = (e) => e ? new Date(e).toLocaleDateString("zh-CN") : "—", Jk = (e) => e >= 3600 ? `${(e / 3600).toFixed(1)} 小时` : `${Math.round(e / 60)} 分钟`, Yk = (e) => Number(e.web_visits ?? e.score ?? e.visits ?? e.peach_items ?? 0);+function Xk(e) {if (e.web_visits == null) return Number(e.score || e.visits || 0).toLocaleString();let t = [];return e.web_visits && t.push(`浏览 ${e.web_visits}`), e.peach_items && t.push(`Peach ${e.peach_items}`), t.join(" · ");}-function Yk(e) {- let t = e.map(qk), n = Math.max(1, ...t);+function Zk(e) {+ let t = e.map(Yk), n = Math.max(1, ...t);return t.map((e) => Math.max(0, Math.min(100, e / n * 100)));}-var Xk = {+var Qk = {x: 160,y: 140-}, Zk = [+}, $k = [25,50,75,100-], Qk = (e, t, n) => {+], eA = (e, t, n) => {let r = e / t * Math.PI * 2 - Math.PI / 2;- return [Xk.x + Math.cos(r) * n, Xk.y + Math.sin(r) * n];+ return [Qk.x + Math.cos(r) * n, Qk.y + Math.sin(r) * n];};-function $k(e) {+function tA(e) {let t = e.filter((e) => Number.isFinite(Number(e.score)) && Number(e.score) > 0).slice().sort((e, t) => Number(t.score) - Number(e.score)).slice(0, 6);if (t.length < 3) return [];let n = Math.max(...t.map((e) => Number(e.score)));return t.map((e, r) => {- let [i, a] = Qk(r, t.length, Number(e.score) / n * 100), [o, s] = Qk(r, t.length, 116);+ let [i, a] = eA(r, t.length, Number(e.score) / n * 100), [o, s] = eA(r, t.length, 116);return {name: e.name,x: i,@@ -34581,7 +34722,7 @@ function $k(e) {};});}-var eA = (e, t) => Array.from({ length: t }, (n, r) => Qk(r, t, e).map((e) => e.toFixed(2)).join(",")).join(" "), tA = (e) => e.map((e) => `${e.x.toFixed(2)},${e.y.toFixed(2)}`).join(" "), nA = [+var nA = (e, t) => Array.from({ length: t }, (n, r) => eA(r, t, e).map((e) => e.toFixed(2)).join(",")).join(" "), rA = (e) => e.map((e) => `${e.x.toFixed(2)},${e.y.toFixed(2)}`).join(" "), iA = ["周一","周二","周三",@@ -34589,8 +34730,8 @@ var eA = (e, t) => Array.from({ length: t }, (n, r) => Qk(r, t, e).map((e) => e."周五","周六","周日"-], rA = (e, t) => e ? Math.max(.12, e / t) : 0;-function iA(e) {+], aA = (e, t) => e ? Math.max(.12, e / t) : 0;+function oA(e) {let t = Array.from({ length: 7 }, () => Array(24).fill(0));for (let n of e?.hours || []) {let { weekday: e, hour: r, count: i } = n;@@ -34600,14 +34741,14 @@ function iA(e) {return {cells: t.flatMap((e, t) => e.map((e, n) => ({key: `${t}-${n}`,- label: `${nA[t]} ${n}:00`,+ label: `${iA[t]} ${n}:00`,count: e,- share: rA(e, r)+ share: aA(e, r)}))),total: n.reduce((e, t) => e + t, 0)};}-function aA(e) {+function sA(e) {let t = (e?.days || []).filter((e) => /^\d{4}-\d{2}-\d{2}$/.test(e.date) && Number.isFinite(e.count) && e.count >= 0).slice().sort((e, t) => e.date.localeCompare(t.date)), n = {cells: [],total: 0,@@ -34625,7 +34766,7 @@ function aA(e) {key: r,label: r,count: s,- share: rA(s, o)+ share: aA(s, o)};});return {@@ -34635,17 +34776,17 @@ function aA(e) {end: t.at(-1).date};}-var oA = {+var cA = {width: 720,height: 435-}, sA = {+}, lA = {source: 145,target: 545};-function cA(e = []) {+function uA(e = []) {let t = e.filter((e) => e.source && e.target && Number.isFinite(e.value) && e.value > 0);if (!t.length) return null;- let n = [...new Set(t.map((e) => e.source))], r = [...new Set(t.map((e) => e.target))], i = uk().nodeId((e) => e.id).nodeWidth(10).nodePadding(22).extent([[155, 16], [535, 404]])({+ let n = [...new Set(t.map((e) => e.source))], r = [...new Set(t.map((e) => e.target))], i = fk().nodeId((e) => e.id).nodeWidth(10).nodePadding(22).extent([[155, 16], [535, 404]])({nodes: [...n.map((e) => ({id: `source:${e}`,name: e,@@ -34660,7 +34801,7 @@ function cA(e = []) {target: `target:${e.target}`,value: e.value}))- }), a = t.reduce((e, t) => e + t.value, 0), o = Ok();+ }), a = t.reduce((e, t) => e + t.value, 0), o = Ak();return {nodes: i.nodes.map((e) => ({id: e.id,@@ -34690,22 +34831,22 @@ function cA(e = []) {total: a};}-var lA = (e) => e.length > 18 ? `${e.slice(0, 16)}…` : e, uA = [+var dA = (e) => e.length > 18 ? `${e.slice(0, 16)}…` : e, fA = ["stroke-chart-1","stroke-chart-2","stroke-chart-3","stroke-chart-4","stroke-chart-5","stroke-chart-6"-], dA = [+], pA = ["fill-chart-1","fill-chart-2","fill-chart-3","fill-chart-4","fill-chart-5","fill-chart-6"-], fA = `${sh({ radius: "chart" })} flex flex-col gap-4 max-sm:p-4`;-function pA({ title: e, figure: t, note: n }) {+], mA = `${sh({ radius: "chart" })} flex flex-col gap-4 max-sm:p-4`;+function hA({ title: e, figure: t, note: n }) {return /* @__PURE__ */ (0, w.jsxs)("header", {className: "flex flex-wrap items-end justify-between gap-x-4 gap-y-1",children: [/* @__PURE__ */ (0, w.jsxs)("span", {@@ -34723,8 +34864,8 @@ function pA({ title: e, figure: t, note: n }) {})]});}-function mA({ rows: e, label: t }) {- let n = $k(e);+function gA({ rows: e, label: t }) {+ let n = tA(e);if (!n.length) return null;let r = n.length;return /* @__PURE__ */ (0, w.jsxs)("svg", {@@ -34734,14 +34875,14 @@ function mA({ rows: e, label: t }) {className: "block w-full overflow-visible",children: [/* @__PURE__ */ (0, w.jsx)("title", { children: n.map((e) => e.name).join(",") }),- Zk.map((e) => /* @__PURE__ */ (0, w.jsx)("polygon", {- points: eA(e, r),+ $k.map((e) => /* @__PURE__ */ (0, w.jsx)("polygon", {+ points: nA(e, r),fill: "none",className: "stroke-separator-border",strokeWidth: 1}, e)),/* @__PURE__ */ (0, w.jsx)("polygon", {- points: tA(n),+ points: rA(n),strokeWidth: 2,strokeLinejoin: "round",fillOpacity: .18,@@ -34758,10 +34899,10 @@ function mA({ rows: e, label: t }) {]});}-function hA({ rows: e, label: t }) {+function _A({ rows: e, label: t }) {let n = e.filter((e) => Number.isFinite(Number(e.score)) && Number(e.score) > 0).slice().sort((e, t) => Number(t.score) - Number(e.score)).slice(0, 8);if (!n.length) return null;- let r = Yk(n);+ let r = Zk(n);return /* @__PURE__ */ (0, w.jsx)("ol", {"aria-label": t,className: "flex flex-col gap-2",@@ -34794,12 +34935,12 @@ function hA({ rows: e, label: t }) {}, e.name))});}-function gA({ title: e, unit: t, cells: n, total: r, columns: i, rows: a, axis: o, footer: s }) {+function vA({ title: e, unit: t, cells: n, total: r, columns: i, rows: a, axis: o, footer: s }) {let [c, l] = (0, C.useState)(null), u = o ? 30 : 0, d = o ? 18 : 0;return /* @__PURE__ */ (0, w.jsxs)("section", {- className: fA,+ className: mA,children: [- /* @__PURE__ */ (0, w.jsx)(pA, {+ /* @__PURE__ */ (0, w.jsx)(hA, {title: e,figure: (c ? c.count : r).toLocaleString(),note: c ? c.label : t@@ -34839,11 +34980,11 @@ function gA({ title: e, unit: t, cells: n, total: r, columns: i, rows: a, axis:]});}-var _A = "口味网站访问";-function vA({ activity: e }) {- let t = iA(e), n = aA(e);+var yA = "口味网站访问";+function bA({ activity: e }) {+ let t = oA(e), n = sA(e);if (!n.cells.length) return /* @__PURE__ */ (0, w.jsxs)("section", {- className: fA,+ className: mA,children: [/* @__PURE__ */ (0, w.jsx)("h3", {className: "text-title-2-medium text-text-primary",children: "浏览活跃时间"@@ -34852,7 +34993,7 @@ function vA({ activity: e }) {children: "还没有可用于分析的口味网站访问记录。"})]});- let r = /* @__PURE__ */ (0, w.jsxs)(w.Fragment, { children: [nA.map((e, t) => /* @__PURE__ */ (0, w.jsx)("text", {+ let r = /* @__PURE__ */ (0, w.jsxs)(w.Fragment, { children: [iA.map((e, t) => /* @__PURE__ */ (0, w.jsx)("text", {x: 0,y: 18 + t * 17 + 7,dominantBaseline: "middle",@@ -34867,18 +35008,18 @@ function vA({ activity: e }) {}, t))] });return /* @__PURE__ */ (0, w.jsxs)("div", {className: "inline-grid w-full gap-5 lg:grid-cols-2",- children: [/* @__PURE__ */ (0, w.jsx)(gA, {+ children: [/* @__PURE__ */ (0, w.jsx)(vA, {title: "浏览活跃时间",- unit: _A,+ unit: yA,cells: t.cells,total: t.total,columns: 24,rows: 7,axis: r,footer: /* @__PURE__ */ (0, w.jsxs)(w.Fragment, { children: [/* @__PURE__ */ (0, w.jsx)("span", { children: "星期 × 小时" }), /* @__PURE__ */ (0, w.jsx)("span", { children: e?.timezone || "UTC+08:00" })] })- }), /* @__PURE__ */ (0, w.jsx)(gA, {+ }), /* @__PURE__ */ (0, w.jsx)(vA, {title: "每日活跃",- unit: _A,+ unit: yA,cells: n.cells,total: n.total,columns: 13,@@ -34887,14 +35028,14 @@ function vA({ activity: e }) {})]});}-function yA({ flows: e }) {- let [t, n] = (0, C.useState)(null), r = cA(e);+function xA({ flows: e }) {+ let [t, n] = (0, C.useState)(null), r = uA(e);if (!r) return null;let i = t?.node ?? null, a = (e, n) => t ? i === null ? t.label === n : e.source === i || e.target === i : !0;return /* @__PURE__ */ (0, w.jsxs)("section", {- className: fA,+ className: mA,children: [- /* @__PURE__ */ (0, w.jsx)(pA, {+ /* @__PURE__ */ (0, w.jsx)(hA, {title: "创作者线索来源",figure: (t ? t.value : r.total).toLocaleString(),note: t ? t.label : "条线索"@@ -34902,7 +35043,7 @@ function yA({ flows: e }) {/* @__PURE__ */ (0, w.jsx)("div", {className: "min-w-0 overflow-x-auto",children: /* @__PURE__ */ (0, w.jsxs)("svg", {- viewBox: `0 0 ${oA.width} ${oA.height}`,+ viewBox: `0 0 ${cA.width} ${cA.height}`,fill: "none",role: "img","aria-label": "来源网站与创作者线索",@@ -34916,7 +35057,7 @@ function yA({ flows: e }) {"aria-label": `${e.label}:${e.value} 条线索`,fillOpacity: 0,strokeOpacity: a(e, e.label) ? .55 : .08,- className: `outline-none transition-opacity ${uA[e.color]}`,+ className: `outline-none transition-opacity ${fA[e.color]}`,onPointerEnter: () => n({value: e.value,label: e.label,@@ -34950,15 +35091,15 @@ function yA({ flows: e }) {width: 10,height: e.height,rx: 5,- className: e.side === "source" ? dA[e.color] : "fill-text-secondary"+ className: e.side === "source" ? pA[e.color] : "fill-text-secondary"}), /* @__PURE__ */ (0, w.jsxs)("text", {- x: sA[e.side],+ x: lA[e.side],y: e.y + e.height / 2,textAnchor: e.side === "source" ? "end" : "start",dominantBaseline: "middle",className: "fill-text-secondary text-caption-1-regular",- children: [lA(e.name), /* @__PURE__ */ (0, w.jsx)("tspan", {- x: sA[e.side],+ children: [dA(e.name), /* @__PURE__ */ (0, w.jsx)("tspan", {+ x: lA[e.side],dy: 15,children: e.side === "source" ? e.value.toLocaleString() : `${e.share.toFixed(1)}%`})]@@ -34975,8 +35116,8 @@ function yA({ flows: e }) {}//#endregion//#region src/react/taste/taste-page.tsx-var bA = 10, xA = Km(TS, ES, "text-body-2-medium"), SA = `${sh()} flex flex-col gap-4`, CA = "rounded-xl bg-background-primary-default p-3", wA = "读取运行 Peach 的这台电脑上的浏览记录", TA = "导入或读取浏览记录后,这里会列出已采集设备。", EA = "馆藏里暂时没有对得上浏览信号的标签。", DA = "采集浏览记录后,这里会显示聚合后的口味证据。", OA = "这些词在浏览记录中出现,但 Peach 观看记录还没有对应证据", kA = "在运行 Peach 的电脑上使用浏览器:点上面的「读取浏览器历史」。", AA = "记录在其他设备上:导出文件后,点上面的「导入历史文件」。多台设备的文件分别导入。", jA = "需要刷新时再次读取或导入;数据源可在页面底部移除。", MA = "这个数据源将不再用于口味分析。原始导出文件保留。", NA = "peach-taste-guide-dismissed";-function PA({ icon: e, term: t, figure: n, detail: r, accent: i }) {+var SA = 10, CA = Km(TS, ES, "text-body-2-medium"), wA = `${sh()} flex flex-col gap-4`, TA = "rounded-xl bg-background-primary-default p-3", EA = "读取运行 Peach 的这台电脑上的浏览记录", DA = "导入或读取浏览记录后,这里会列出已采集设备。", OA = "馆藏里暂时没有对得上浏览信号的标签。", kA = "采集浏览记录后,这里会显示聚合后的口味证据。", AA = "这些词在浏览记录中出现,但 Peach 观看记录还没有对应证据", jA = "在运行 Peach 的电脑上使用浏览器:点上面的「读取浏览器历史」。", MA = "记录在其他设备上:导出文件后,点上面的「导入历史文件」。多台设备的文件分别导入。", NA = "需要刷新时再次读取或导入;数据源可在页面底部移除。", PA = "这个数据源将不再用于口味分析。原始导出文件保留。", FA = "peach-taste-guide-dismissed";+function IA({ icon: e, term: t, figure: n, detail: r, accent: i }) {return /* @__PURE__ */ (0, w.jsx)("div", {className: gS(),children: /* @__PURE__ */ (0, w.jsx)(vS, {@@ -34988,7 +35129,7 @@ function PA({ icon: e, term: t, figure: n, detail: r, accent: i }) {})});}-function FA({ name: e, domain: t }) {+function LA({ name: e, domain: t }) {return /* @__PURE__ */ (0, w.jsxs)("span", {className: "relative inline-grid size-8 shrink-0 place-items-center overflow-hidden rounded-lg bg-background-tertiary-default text-caption-1-medium text-text-secondary",children: [e.slice(0, 1).toUpperCase(), /* @__PURE__ */ (0, w.jsx)("img", {@@ -35002,22 +35143,22 @@ function FA({ name: e, domain: t }) {})]});}-function IA({ html: e }) {+function RA({ html: e }) {return /* @__PURE__ */ (0, w.jsx)("span", {className: "relative inline-grid size-8 shrink-0 place-items-center overflow-hidden rounded-full bg-background-tertiary-default text-caption-1-medium text-text-secondary [&_img]:absolute [&_img]:inset-0 [&_img]:size-full [&_img]:object-cover",dangerouslySetInnerHTML: { __html: e }});}-function LA({ rows: e, kind: t, visual: n, empty: r, onSignal: i, avatarInner: a }) {+function zA({ rows: e, kind: t, visual: n, empty: r, onSignal: i, avatarInner: a }) {if (!e.length) return /* @__PURE__ */ (0, w.jsx)(lh, {shell: "plain",icon: ap,title: "暂无足够证据",children: r});- let o = Yk(e);- return /* @__PURE__ */ (0, w.jsx)(TO, {- previewCount: bA,+ let o = Zk(e);+ return /* @__PURE__ */ (0, w.jsx)(DO, {+ previewCount: SA,className: "inline-grid w-full gap-x-7 gap-y-2 sm:grid-cols-2",children: e.map((e, r) => {let s = !!t && !!e.peach_items, c = String(e.source_domain || ""), l = /* @__PURE__ */ (0, w.jsxs)(w.Fragment, { children: [@@ -35036,15 +35177,15 @@ function LA({ rows: e, kind: t, visual: n, empty: r, onSignal: i, avatarInner: aclassName: "w-6 shrink-0 text-caption-1-regular tabular-nums text-text-secondary",children: r + 1}),- n === "domain" ? /* @__PURE__ */ (0, w.jsx)(FA, {+ n === "domain" ? /* @__PURE__ */ (0, w.jsx)(LA, {name: e.name,domain: e.name}) : null,- n === "creator" && !e.entity_id && !e.has_avatar && c ? /* @__PURE__ */ (0, w.jsx)(FA, {+ n === "creator" && !e.entity_id && !e.has_avatar && c ? /* @__PURE__ */ (0, w.jsx)(LA, {name: e.name,domain: c}) : null,- n !== "none" && n !== "domain" && (e.entity_id || e.has_avatar || !c) ? /* @__PURE__ */ (0, w.jsx)(IA, { html: a(e.name, e.entity_id ? {+ n !== "none" && n !== "domain" && (e.entity_id || e.has_avatar || !c) ? /* @__PURE__ */ (0, w.jsx)(RA, { html: a(e.name, e.entity_id ? {id: e.entity_id,has_image: !!e.has_image,avatar_focus: e.avatar_focus@@ -35056,7 +35197,7 @@ function LA({ rows: e, kind: t, visual: n, empty: r, onSignal: i, avatarInner: achildren: e.name}), /* @__PURE__ */ (0, w.jsx)("small", {className: "text-caption-1-regular text-text-secondary",- children: Jk(e)+ children: Xk(e)})]}),s ? /* @__PURE__ */ (0, w.jsx)(Nf, {@@ -35079,7 +35220,7 @@ function LA({ rows: e, kind: t, visual: n, empty: r, onSignal: i, avatarInner: a})});}-function RA({ label: e, panels: t, onSignal: n, avatarInner: r }) {+function BA({ label: e, panels: t, onSignal: n, avatarInner: r }) {return /* @__PURE__ */ (0, w.jsxs)(Py, {className: `${sh({ padding: "none" })} flex flex-col`,children: [/* @__PURE__ */ (0, w.jsx)("div", {@@ -35096,7 +35237,7 @@ function RA({ label: e, panels: t, onSignal: n, avatarInner: r }) {}), t.map((e) => /* @__PURE__ */ (0, w.jsx)(zy, {id: e.id,className: "px-4 pt-3.5 pb-4",- children: /* @__PURE__ */ (0, w.jsx)(LA, {+ children: /* @__PURE__ */ (0, w.jsx)(zA, {...e.props,onSignal: n,avatarInner: r@@ -35104,7 +35245,7 @@ function RA({ label: e, panels: t, onSignal: n, avatarInner: r }) {}, e.id))]});}-function zA({ data: e, onSignal: t, navigate: n }) {+function VA({ data: e, onSignal: t, navigate: n }) {let r = e.analysis;if (!r?.headline) return null;let i = r.confidence || {}, a = [...(r.explore || []).map((e) => ({@@ -35119,7 +35260,7 @@ function zA({ data: e, onSignal: t, navigate: n }) {act: () => n(e.route)}))];return /* @__PURE__ */ (0, w.jsxs)("section", {- className: SA,+ className: wA,"aria-label": "口味总结",children: [/* @__PURE__ */ (0, w.jsxs)("header", {@@ -35145,7 +35286,7 @@ function zA({ data: e, onSignal: t, navigate: n }) {r.points?.length ? /* @__PURE__ */ (0, w.jsx)("div", {className: "inline-grid w-full gap-3 sm:grid-cols-2",children: r.points.map((e) => /* @__PURE__ */ (0, w.jsxs)("div", {- className: `flex min-w-0 flex-col gap-1 ${CA}`,+ className: `flex min-w-0 flex-col gap-1 ${TA}`,children: [/* @__PURE__ */ (0, w.jsx)("span", {className: "text-caption-1-regular text-text-secondary",children: e.label@@ -35160,7 +35301,7 @@ function zA({ data: e, onSignal: t, navigate: n }) {children: a.map((e) => /* @__PURE__ */ (0, w.jsxs)("button", {type: "button",onClick: e.act,- className: `flex w-full min-w-0 cursor-pointer items-center gap-3 ${CA} text-left outline-none hover:bg-background-primary-hover focus-visible:ring-2 focus-visible:ring-border-focus-ring`,+ className: `flex w-full min-w-0 cursor-pointer items-center gap-3 ${TA} text-left outline-none hover:bg-background-primary-hover focus-visible:ring-2 focus-visible:ring-border-focus-ring`,children: [/* @__PURE__ */ (0, w.jsxs)("span", {className: "flex min-w-0 grow flex-col gap-1",children: [/* @__PURE__ */ (0, w.jsx)("b", {@@ -35179,15 +35320,15 @@ function zA({ data: e, onSignal: t, navigate: n }) {shell: "plain",icon: ap,title: "还没有可探索的入口",- children: EA+ children: OA})]});}-function BA({ onboarding: e, done: t }) {+function HA({ onboarding: e, done: t }) {let [n, r] = (0, C.useState)(() => {try {- return localStorage.getItem(NA) === "1";+ return localStorage.getItem(FA) === "1";} catch {return !1;}@@ -35203,11 +35344,11 @@ function BA({ onboarding: e, done: t }) {children: [/* @__PURE__ */ (0, w.jsx)("p", {className: "text-body-2-regular text-text-secondary",- children: kA+ children: jA}),/* @__PURE__ */ (0, w.jsx)("p", {className: "text-body-2-regular text-text-secondary",- children: AA+ children: MA}),/* @__PURE__ */ (0, w.jsxs)("ul", {className: "flex list-disc flex-col gap-1 pl-5 text-body-2-regular text-text-secondary",@@ -35237,7 +35378,7 @@ function BA({ onboarding: e, done: t }) {}),/* @__PURE__ */ (0, w.jsx)("p", {className: "text-body-2-regular text-text-secondary",- children: jA+ children: NA}),/* @__PURE__ */ (0, w.jsx)("span", {className: "self-start",@@ -35246,7 +35387,7 @@ function BA({ onboarding: e, done: t }) {size: "small",onClick: () => {try {- localStorage.setItem(NA, "1");+ localStorage.setItem(FA, "1");} catch {}r(!0);},@@ -35257,7 +35398,7 @@ function BA({ onboarding: e, done: t }) {})});}-function VA({ busy: e, onRefresh: t, onImport: n }) {+function UA({ busy: e, onRefresh: t, onImport: n }) {let r = (0, C.useRef)(null), [i, a] = (0, C.useState)(!1), o = (e) => {a(!1), e();};@@ -35267,7 +35408,7 @@ function VA({ busy: e, onRefresh: t, onImport: n }) {"data-variant": "primary",children: [/* @__PURE__ */ (0, w.jsx)(X, {leadingIcon: zf,- title: wA,+ title: EA,onClick: t,...Z(e),children: "读取浏览器历史"@@ -35292,7 +35433,7 @@ function VA({ busy: e, onRefresh: t, onImport: n }) {className: "flex w-52 flex-col gap-1 outline-none",children: [/* @__PURE__ */ (0, w.jsxs)("button", {type: "button",- className: xA,+ className: CA,onClick: () => o(t),children: [/* @__PURE__ */ (0, w.jsx)(zf, {"aria-hidden": !0,@@ -35300,7 +35441,7 @@ function VA({ busy: e, onRefresh: t, onImport: n }) {}), "读取浏览器历史"]}), /* @__PURE__ */ (0, w.jsxs)("button", {type: "button",- className: xA,+ className: CA,onClick: () => o(n),children: [/* @__PURE__ */ (0, w.jsx)(lp, {"aria-hidden": !0,@@ -35310,15 +35451,15 @@ function VA({ busy: e, onRefresh: t, onImport: n }) {})})] });}-function HA({ sources: e, window: t, toast: n }) {+function WA({ sources: e, window: t, toast: n }) {let r = dt({- mutationFn: (e) => Bk(e, t),+ mutationFn: (e) => Hk(e, t),onSuccess: (e) => {- ph.setQueryData(Nk(t), e.dashboard), n("已移除口味数据源");+ ph.setQueryData(Fk(t), e.dashboard), n("已移除口味数据源");}});return /* @__PURE__ */ (0, w.jsxs)("section", {- className: SA,+ className: wA,"aria-label": "数据源",children: [/* @__PURE__ */ (0, w.jsx)("h3", {@@ -35332,7 +35473,7 @@ function HA({ sources: e, window: t, toast: n }) {e.length ? /* @__PURE__ */ (0, w.jsx)("div", {className: "inline-grid w-full gap-2 sm:grid-cols-2",children: e.map((e) => /* @__PURE__ */ (0, w.jsxs)("div", {- className: `flex min-w-0 items-center gap-3 ${CA}`,+ className: `flex min-w-0 items-center gap-3 ${TA}`,children: [/* @__PURE__ */ (0, w.jsx)("span", {className: "inline-grid size-8 shrink-0 place-items-center rounded-lg text-text-secondary",@@ -35364,7 +35505,7 @@ function HA({ sources: e, window: t, toast: n }) {onClick: () => {r.isPending || c({title: "移除口味数据源",- body: MA,+ body: PA,confirmLabel: "移除口味数据源",onConfirm: () => r.mutateAsync(e.source_key)});@@ -35376,29 +35517,29 @@ function HA({ sources: e, window: t, toast: n }) {shell: "plain",icon: Vf,title: "还没有数据源",- children: TA+ children: DA})]});}-function UA(e) {+function GA(e) {let { onSignal: t, navigate: r, toast: i, avatarInner: a, onboarding: o } = e, [s, c] = (0, C.useState)("all"), [l, u] = (0, C.useState)("browser"), [d, f] = (0, C.useState)(!1), [p, m] = (0, C.useState)(null), h = (0, C.useRef)(null), g = ut({- queryKey: Nk(s),- queryFn: ({ signal: e }) => Ik(s, e),+ queryKey: Fk(s),+ queryFn: ({ signal: e }) => Rk(s, e),placeholderData: L}), _ = ut({- queryKey: Pk,- queryFn: ({ signal: e }) => Lk(e),- refetchInterval: (e) => Wk(e.state.data)+ queryKey: Ik,+ queryFn: ({ signal: e }) => zk(e),+ refetchInterval: (e) => Kk(e.state.data)}), v = dt({- mutationFn: () => zk(s),+ mutationFn: () => Vk(s),onSuccess: () => {- f(!0), m(null), ph.invalidateQueries({ queryKey: Pk });+ f(!0), m(null), ph.invalidateQueries({ queryKey: Ik });}}), y = dt({- mutationFn: (e) => Vk(e),+ mutationFn: (e) => Uk(e),onSuccess: (e) => {- ph.setQueryData(Nk("all"), e.dashboard), c("all"), i("已导入口味数据");+ ph.setQueryData(Fk("all"), e.dashboard), c("all"), i("已导入口味数据");}}), b = _.data?.status === "running";(0, C.useEffect)(() => {@@ -35456,12 +35597,12 @@ function UA(e) {onSelectionChange: (e) => {e !== null && c(String(e));},- children: Fk.map(([e, t]) => /* @__PURE__ */ (0, w.jsx)($w, {+ children: Lk.map(([e, t]) => /* @__PURE__ */ (0, w.jsx)($w, {id: e,children: t}, e))}),- /* @__PURE__ */ (0, w.jsx)(VA, {+ /* @__PURE__ */ (0, w.jsx)(UA, {busy: b || v.isPending || y.isPending,onRefresh: S,onImport: () => h.current?.click()@@ -35477,7 +35618,7 @@ function UA(e) {]})]}),- /* @__PURE__ */ (0, w.jsx)(BA, {+ /* @__PURE__ */ (0, w.jsx)(HA, {onboarding: o,done: !!(E.history_sources || T.updated_at)}),@@ -35510,27 +35651,27 @@ function UA(e) {/* @__PURE__ */ (0, w.jsxs)("div", {className: _S,children: [- /* @__PURE__ */ (0, w.jsx)(PA, {+ /* @__PURE__ */ (0, w.jsx)(IA, {accent: 0,icon: Yf,term: "浏览记录",figure: Number(E.history_visits || 0).toLocaleString(),- detail: `${E.history_sources || 0} 个数据源 · ${Gk(E.range_start)}—${Gk(E.range_end)}`+ detail: `${E.history_sources || 0} 个数据源 · ${qk(E.range_start)}—${qk(E.range_end)}`}),- /* @__PURE__ */ (0, w.jsx)(PA, {+ /* @__PURE__ */ (0, w.jsx)(IA, {accent: 1,icon: np,term: "口味维度",figure: A.length.toLocaleString(),detail: A[0]?.name || "尚无主维度"}),- /* @__PURE__ */ (0, w.jsx)(PA, {+ /* @__PURE__ */ (0, w.jsx)(IA, {accent: 2,icon: ap,term: "浏览候选",figure: j.length.toLocaleString()}),- /* @__PURE__ */ (0, w.jsx)(PA, {+ /* @__PURE__ */ (0, w.jsx)(IA, {accent: 3,icon: Vf,term: "私有导出",@@ -35540,7 +35681,7 @@ function UA(e) {]}),/* @__PURE__ */ (0, w.jsxs)("section", {- className: `${SA} md:flex-row md:gap-6`,+ className: `${wA} md:flex-row md:gap-6`,"aria-label": "浏览器画像",children: [/* @__PURE__ */ (0, w.jsxs)("div", {className: "flex shrink-0 flex-col gap-2 pb-5 md:w-72 md:pr-6 md:pb-0",@@ -35549,31 +35690,31 @@ function UA(e) {className: "text-caption-1-regular text-text-secondary",children: "浏览器画像"}),- /* @__PURE__ */ (0, w.jsx)(mA, {+ /* @__PURE__ */ (0, w.jsx)(gA, {rows: A,label: "主要口味维度"}),/* @__PURE__ */ (0, w.jsx)("small", {className: "text-caption-1-regular text-text-secondary",- children: T.updated_at ? `更新于 ${Gk(T.updated_at)}` : "尚未采集浏览记录"+ children: T.updated_at ? `更新于 ${qk(T.updated_at)}` : "尚未采集浏览记录"})]}), /* @__PURE__ */ (0, w.jsx)("div", {className: "min-w-0 grow",- children: A.length ? /* @__PURE__ */ (0, w.jsx)(hA, {+ children: A.length ? /* @__PURE__ */ (0, w.jsx)(_A, {rows: A,label: "口味维度排名"}) : /* @__PURE__ */ (0, w.jsx)(lh, {shell: "plain",icon: ap,title: "暂无口味维度",- children: DA+ children: kA})})]}),- /* @__PURE__ */ (0, w.jsx)(vA, { activity: T.activity }),- /* @__PURE__ */ (0, w.jsx)(yA, { flows: T.creator_flows }),- /* @__PURE__ */ (0, w.jsx)(RA, {+ /* @__PURE__ */ (0, w.jsx)(bA, { activity: T.activity }),+ /* @__PURE__ */ (0, w.jsx)(xA, { flows: T.creator_flows }),+ /* @__PURE__ */ (0, w.jsx)(BA, {label: "浏览器口味维度",onSignal: t,avatarInner: a,@@ -35615,7 +35756,7 @@ function UA(e) {rows: j,kind: "",visual: "none",- empty: OA+ empty: AA}}]@@ -35629,26 +35770,26 @@ function UA(e) {/* @__PURE__ */ (0, w.jsxs)("div", {className: _S,children: [- /* @__PURE__ */ (0, w.jsx)(PA, {+ /* @__PURE__ */ (0, w.jsx)(IA, {accent: 0,icon: Gf,term: "Peach 看过",figure: Number(E.peach_items || 0).toLocaleString(),- detail: Kk(E.peach_seconds || 0)+ detail: Jk(E.peach_seconds || 0)}),- /* @__PURE__ */ (0, w.jsx)(PA, {+ /* @__PURE__ */ (0, w.jsx)(IA, {accent: 1,icon: cp,term: "喜欢",figure: Number(E.liked || 0).toLocaleString()}),- /* @__PURE__ */ (0, w.jsx)(PA, {+ /* @__PURE__ */ (0, w.jsx)(IA, {accent: 2,icon: sp,term: "不合口味",figure: Number(E.disliked || 0).toLocaleString()}),- /* @__PURE__ */ (0, w.jsx)(PA, {+ /* @__PURE__ */ (0, w.jsx)(IA, {accent: 3,icon: np,term: "有标签",@@ -35657,7 +35798,7 @@ function UA(e) {]}),/* @__PURE__ */ (0, w.jsxs)("section", {- className: `${SA} md:flex-row md:gap-6`,+ className: `${wA} md:flex-row md:gap-6`,"aria-label": "Peach 观看",children: [/* @__PURE__ */ (0, w.jsxs)("div", {className: "flex shrink-0 flex-col gap-0.5 pb-5 md:w-72 md:pr-6 md:pb-0",@@ -35677,18 +35818,18 @@ function UA(e) {]}), /* @__PURE__ */ (0, w.jsxs)("div", {className: "flex min-w-0 grow flex-col",- children: [/* @__PURE__ */ (0, w.jsx)(WA, {+ children: [/* @__PURE__ */ (0, w.jsx)(KA, {term: "有标签",value: M,rest: D.untagged || 0- }), /* @__PURE__ */ (0, w.jsx)(WA, {+ }), /* @__PURE__ */ (0, w.jsx)(KA, {term: "有身份",value: N,rest: D.unidentified || 0})]})]}),- /* @__PURE__ */ (0, w.jsx)(RA, {+ /* @__PURE__ */ (0, w.jsx)(BA, {label: "Peach 口味维度",onSignal: t,avatarInner: a,@@ -35729,19 +35870,19 @@ function UA(e) {})]}),- /* @__PURE__ */ (0, w.jsx)(zA, {+ /* @__PURE__ */ (0, w.jsx)(VA, {data: T,onSignal: t,navigate: r}),- /* @__PURE__ */ (0, w.jsx)(HA, {+ /* @__PURE__ */ (0, w.jsx)(WA, {sources: T.sources || [],window: s,toast: i})] });}-function WA({ term: e, value: t, rest: n }) {+function KA({ term: e, value: t, rest: n }) {let r = Math.max(t + n, 1);return /* @__PURE__ */ (0, w.jsxs)("div", {className: "flex flex-col gap-1.5 border-b border-separator-border py-3 last:border-b-0",@@ -35763,16 +35904,16 @@ function WA({ term: e, value: t, rest: n }) {}//#endregion//#region src/react/entry.tsx-var GA = null;-function KA() {- return GA?.isConnected || (GA = document.createElement("div"), GA.className = "peach-react", GA.dataset.reactOverlays = "", document.body.append(GA)), GA;+var qA = null;+function JA() {+ return qA?.isConnected || (qA = document.createElement("div"), qA.className = "peach-react", qA.dataset.reactOverlays = "", document.body.append(qA)), qA;}-function qA(e) {+function YA(e) {return (t, n) => {let r = (0, Of.createRoot)(t), i = (t) => r.render(/* @__PURE__ */ (0, w.jsx)(D, {client: ph,children: /* @__PURE__ */ (0, w.jsx)(bc, {- getContainer: KA,+ getContainer: JA,children: /* @__PURE__ */ (0, w.jsx)(e, { ...t })})}));@@ -35782,51 +35923,51 @@ function qA(e) {};};}-var JA = {+var XA = {activity: {prefetch: (e, t) => bh(t),- mount: qA(Lh)+ mount: YA(Lh)},"avatar-picker": {prefetch: async () => {},- mount: qA(jb)+ mount: YA(jb)},"cover-crop": {prefetch: async () => {},- mount: qA(Hb)+ mount: YA(Hb)},configuration: {prefetch: (e, t) => vD(t),- mount: qA(pO)+ mount: YA(hO)},"follow-manage": {prefetch: (e, t) => Qx(t),- mount: qA(fT)+ mount: YA(fT)},"library-processing": {prefetch: (e, t) => gT(t),- mount: qA((e) => e.mode === "notice" ? /* @__PURE__ */ (0, w.jsx)(HT, { ...e }) : /* @__PURE__ */ (0, w.jsx)(RT, { ...e }))+ mount: YA((e) => e.mode === "notice" ? /* @__PURE__ */ (0, w.jsx)(HT, { ...e }) : /* @__PURE__ */ (0, w.jsx)(RT, { ...e }))},"quality-goals": {prefetch: (e, t) => KT(t),- mount: qA(YT)+ mount: YA(YT)},review: {prefetch: (e, t) => TE(t),- mount: qA(XE)+ mount: YA(XE)},scraping: {prefetch: (e, t) => oD(t),- mount: qA(pD)+ mount: YA(pD)},stats: {- prefetch: (e, t) => _O(t),- mount: qA(YO)+ prefetch: (e, t) => yO(t),+ mount: YA(ZO)},taste: {- prefetch: (e, t) => Rk("all", t),- mount: qA(UA)+ prefetch: (e, t) => Bk("all", t),+ mount: YA(GA)}};//#endregion-export { JA as pages };+export { XA as pages };diff --git a/web/index.html b/web/index.htmlindex 5a95011cf..601dcdc3e 100644--- a/web/index.html+++ b/web/index.html@@ -234,6 +234,8 @@<main id="main" tabindex="-1"><div id="libraryProcessingNotice"></div>+ <!-- 订阅源发现的新作(ADR-0042)。只在首页那几条目录路径上出现,由 app.js 按路径开合。 -->+ <section class="feednew" id="feedNew" aria-label="新作 · 未入库" hidden></section><dialog class="stage" id="stage" aria-label="作品详情" hidden></dialog><div class="combo" id="combo"></div><section class="index" id="index" hidden></section>