Peach: Local-first video metadata scraper and media manager.
feat: 配置面板提供自动更新设置
longmeidao622d6063d032
diff --git a/README.en.md b/README.en.mdindex 8a46454ca..3ba679f05 100644--- a/README.en.md+++ b/README.en.md@@ -66,6 +66,7 @@ The test package is accessible only on the same computer and needs no Python, GiData lives separately from the program in `%LOCALAPPDATA%\Peach\peach-data`.Management → Configuration → Check for updates compares the installed version with the latest GitHub prerelease.+Automatic updates can check every 6 hours, daily, or weekly and are off by default. Standalone packages can download automatically and wait for restart confirmation; source installations support automatic checks.Standalone packages download and install the update in the app and restore the previous version if installation fails;you can also exit the tray and extract a complete new package over it, keeping the data directory.Configuration also offers uninstall, with optional removal of Peach data; original media is preserved.diff --git a/README.md b/README.mdindex 3fda2d02b..ec2d32542 100644--- a/README.md+++ b/README.md@@ -68,6 +68,8 @@ Peach 处于 **pre-1.0** 阶段,界面目前只有中文。「管理 → 配置 → 检查更新」比对 GitHub 上的最新测试版,独立包可以在页面里下载并安装,失败时恢复旧版;也可以退出托盘后手动完整解压新版,保留数据目录。配置页提供卸载,可选是否一并删除 Peach 数据,原始媒体保留。+配置页的「自动更新」可按每 6 小时、每天或每周检查新版本,默认关闭。独立测试包可自动下载,下载完成后确认重启安装;源码运行支持自动检查。+FFmpeg 与 ffprobe 需另装;缺少它们时可浏览和播放浏览器兼容格式,转码、探测与缩略图不可用。测试包未签名;下载校验、配置与问题反馈见 [Windows 测试版](docs/TESTING_DESKTOP.md)。diff --git a/docs/REUSE.md b/docs/REUSE.mdindex 1de6a2127..020e57729 100644--- a/docs/REUSE.md+++ b/docs/REUSE.md@@ -19,6 +19,10 @@首页进度 Banner 与数据管理复用 `LibraryProcessing`、`watchJob` 和 `/api/library-processing`,启动只提交一次,状态查询接续托盘首次处理。首页在完成后收起,失败跳转数据管理;数据管理持续读取阶段与真实计数。Geist Banner 取证与 Peach 差异见 `docs/reference-snapshots/vercel-geist-library-banner.md`。## 独立测试包在线更新+- 2026-09-08 自动检查只读 POC:临时设置触发 GitHub 查询,取得 v0.30.0、35,633,626 字节的 Windows ZIP 与 SHA-256;未下载或安装。桌面 1280×720 与手机 390×844 的设置预览通过,开关联动、频率菜单和保存回执正常。++- 自动更新设置复用 APScheduler 3.11.3(MIT,项目已有依赖,Python 3.12+ 与 Windows/macOS)、共享 HTTPX 发行查询、filelock 与原子 JSON 写入,安装继续走 `standalone_update`。按 [interval trigger](https://apscheduler.readthedocs.io/en/3.x/modules/triggers/interval.html) 每分钟检查是否到期;本机持久时间与文件锁协调多个服务,关闭、6/24/168 小时间隔与源码下载限制由 Peach 管理。默认关闭,下载仅准备安装,重启仍需确认;没有新增依赖或安装框架。设置保存在 state 目录的 `automatic-updates.json`。+- 版本与资产信息复用 GitHub Releases REST API,测试通道包含预发布版本;查询复用项目 HTTPX 0.28.1,下载用其流式读取,ZIP 解压使用 Python 3.12+ 标准库,互斥复用 FileLock。没有新增依赖。- 2026-09-06 真实只读 POC:GitHub 返回 v0.16.0、Windows ZIP 35,489,963 字节和 SHA-256 digest;仅发布记录中已上传的完整独立包可进入更新。- Peach 维护安装策略与进度:下载校验后在程序同卷暂存,用户确认重启,复制出来的包内助手等待原托盘退出,再切换完整目录;失败保留或恢复旧目录。配置、数据库与媒体不作为更新包内容写入。diff --git a/docs/STATUS.md b/docs/STATUS.mdindex dd57dbd39..f45c87ec3 100644--- a/docs/STATUS.md+++ b/docs/STATUS.md@@ -8,7 +8,7 @@- BoardUI:只读预览 18984,状态演示 `/state-preview`;生产未切换。验收见 `BOARD_UI.md`。-- 设置与反馈已部署;预览 18976。骨架桌面及 390px 验收通过,生产浏览器超时。+- 设置与反馈已部署;预览 18976。骨架桌面及 390px 验收通过,生产浏览器超时。自动更新设置未部署。- 女优头像 545 张:2026-09-06 经用户批准换上 54 张 Gfriends 正脸照,脸宽中位数 148px → 320px;被顶掉的整套留在 `avatars-superseded/`,挑图与换源判据见 `SOURCING.md`。- 小图显示、资料骨架、官网图标、X 原色及自动播放开关已实现;桌面和手机预览通过,生产浏览器取证受客户端限制。请求共用 Chrome UA。diff --git a/frontend/src/islands/automatic-updates.tsx b/frontend/src/islands/automatic-updates.tsxnew file mode 100644index 000000000..8a897b498--- /dev/null+++ b/frontend/src/islands/automatic-updates.tsx@@ -0,0 +1,46 @@+import { useEffect, useLayoutEffect, useRef, useState } from 'preact/hooks';+import { fieldsetTitle, selectFieldHtml, wireSelectField, setActionBusy } from '@peach/legacy/ui';+import { apiSend, errorMessage } from '../api';++export interface AutomaticUpdateState { mode: string; interval_hours: number; available: boolean; download_available: boolean; error?: string }++export function AutomaticUpdateSettings({ initial, receipt }: { initial: AutomaticUpdateState; receipt(message: string): void }) {+ const [mode, setMode] = useState(initial.mode);+ const [hours, setHours] = useState(initial.interval_hours);+ const [error, setError] = useState(initial.error || '');+ const options = useRef<HTMLDivElement>(null);+ const button = useRef<HTMLButtonElement>(null);+ const busy = useRef(false);+ const lifetime = useRef(new AbortController());+ useEffect(() => () => lifetime.current.abort(), []);+ useLayoutEffect(() => {+ const root = options.current!;+ root.innerHTML = selectFieldHtml([['6','每 6 小时'],['24','每天'],['168','每周']],String(initial.interval_hours),{label:'检查频率',className:'configselect',attr:'data-fixed-width'});+ const field = wireSelectField(root.firstElementChild!);+ const change = () => setHours(Number(field.value));+ field.addEventListener('change', change);+ return () => { field.removeEventListener('change', change); root.replaceChildren(); };+ }, []);+ async function save() {+ if (busy.current) return;+ busy.current = true; setActionBusy(button.current, true); setError('');+ try {+ await apiSend<AutomaticUpdateState>('/api/configuration/automatic-updates',{mode,interval_hours:hours},'POST',lifetime.current.signal);+ if (!lifetime.current.signal.aborted) receipt('已保存自动更新设置');+ } catch (cause) { if (!lifetime.current.signal.aborted) setError(errorMessage(cause)); }+ finally { busy.current = false; setActionBusy(button.current, false); }+ }+ return <form class="configfieldset" data-geist-fieldset onSubmit={event => { event.preventDefault(); void save(); }}>+ <div class="geist-fieldset-content">+ <div dangerouslySetInnerHTML={{__html:fieldsetTitle('automaticUpdatesTitle','自动更新')}} />+ <div class="configoptions" role="group" aria-labelledby="automaticUpdatesTitle">+ <label class="configtoggle"><span>自动检查新版本</span><input class="ptoggle" type="checkbox" role="switch" checked={mode !== 'off'} disabled={!initial.available} onChange={event => setMode(event.currentTarget.checked ? 'check' : 'off')} /></label>+ <label class="configtoggle"><span>自动下载更新</span><input class="ptoggle" type="checkbox" role="switch" checked={mode === 'download'} disabled={!initial.available || !initial.download_available || mode === 'off'} onChange={event => setMode(event.currentTarget.checked ? 'download' : 'check')} /></label>+ </div>+ <div ref={options} />+ <p class="confighelp">{!initial.available ? '自动更新需要由托盘管理的服务。' : initial.download_available ? '开启后一分钟内开始检查。下载完成后,在此确认重启安装。' : '开启后一分钟内开始检查。源码运行请前往发布页获取新版本。'}</p>+ {error && <p class="configbad" role="alert">{error}</p>}+ </div>+ <footer class="geist-fieldset-footer" data-geist-fieldset-footer><button ref={button} type="submit" class="geist-button" disabled={!initial.available}>保存自动更新</button></footer>+ </form>;+}diff --git a/frontend/src/islands/configuration.tsx b/frontend/src/islands/configuration.tsxindex 64f31430d..666e680c7 100644--- a/frontend/src/islands/configuration.tsx+++ b/frontend/src/islands/configuration.tsx@@ -14,6 +14,7 @@ import { fieldsetTitle, noteHtml, setActionBusy, selectFieldHtml, wireSelectFielimport { ApiError, apiGet, apiSend, errorMessage } from '../api';import { AccessSettings, type AccessState } from './access-settings';import { ReleaseUpdates, type ReleaseState, type UpdateJob } from './release-updates';+import { AutomaticUpdateSettings, type AutomaticUpdateState } from './automatic-updates';import { PeachProxy, type PeachProxyState } from './peach-proxy';import { StartupSettings, UninstallSettings, type StartupState, type UninstallState } from './desktop-settings';import { CloudDriveGuide } from './clouddrive-guide';@@ -37,6 +38,7 @@ export interface ConfigurationData {peach_proxy?: PeachProxyState;updates?: ReleaseState;update_job?: UpdateJob;+ automatic_updates?: AutomaticUpdateState;access?: AccessState;editable: boolean;/** 不能编辑时给用户看的原因,可编辑时为空。 */@@ -370,6 +372,7 @@ export function Configuration({ receipt, data, error }: ConfigurationProps & Sta{data.peach_proxy ? <PeachProxy initial={data.peach_proxy} receipt={receipt} /> : null}{data.access ? <AccessSettings initial={data.access} receipt={receipt} /> : null}<h2 class="configgroup">更新与维护</h2>+ {data.automatic_updates ? <AutomaticUpdateSettings initial={data.automatic_updates} receipt={receipt} /> : null}{data.updates ? <ReleaseUpdates initial={data.updates} initialJob={data.update_job} /> : null}<Facts facts={data.facts} />{data.uninstall ? <UninstallSettings uninstall={data.uninstall} /> : null}diff --git a/frontend/src/islands/release-updates.tsx b/frontend/src/islands/release-updates.tsxindex 2b93596a0..e7726dcd9 100644--- a/frontend/src/islands/release-updates.tsx+++ b/frontend/src/islands/release-updates.tsx@@ -10,6 +10,7 @@ export interface ReleaseState {state: string;message: string;release_url: string;+ checked_at?: number;}export interface UpdateJob {state: string; progress: number; message?: string; downloaded?: number; total?: number; version?: string}@@ -35,7 +36,6 @@ export function ReleaseUpdates({ initial, initialJob }: { initial: ReleaseState;void confirmModal({title:'更新已准备好',body:`Peach ${job.version || ''} 将在重启后安装。`,confirmLabel:'立即重启',cancelLabel:'稍后',onConfirm:restart});}, [job.state]);useEffect(() => {- if (!active.has(job.state)) return;const controller = new AbortController();let timer: ReturnType<typeof setTimeout>;let failures = 0;@@ -45,13 +45,15 @@ export function ReleaseUpdates({ initial, initialJob }: { initial: ReleaseState;if (!controller.signal.aborted) {setJob(result); failures = 0;if (result.state === 'complete') setData(current => ({...current,current_version:result.version || current.current_version,state:'current',message:'已是最新测试版。'}));+ const automatic = await apiGet<{result?: ReleaseState}>('/api/configuration/automatic-updates',controller.signal);+ if (!controller.signal.aborted && automatic.result) setData(automatic.result);}} catch {if (++failures >= 120 && !controller.signal.aborted) setError('尚未连接到 Peach,请检查托盘后刷新页面。');}- if (!controller.signal.aborted && failures < 120) timer = setTimeout(poll,1000);+ if (!controller.signal.aborted && failures < 120) timer = setTimeout(poll,active.has(job.state) ? 1000 : 30000);};- timer = setTimeout(poll,1000);+ timer = setTimeout(poll,active.has(job.state) ? 1000 : 30000);return () => { controller.abort(); clearTimeout(timer); };}, [job.state]);const download = async (button: HTMLButtonElement) => {@@ -91,6 +93,7 @@ export function ReleaseUpdates({ initial, initialJob }: { initial: ReleaseState;<dt>更新通道</dt><dd>{data.channel}</dd><dt>最新版本</dt><dd>{data.latest_version || (data.state === 'unchecked' ? '尚未检查' : '未取得')}</dd></dl>+ {data.checked_at ? <p class="confighelp">检查于 {new Date(data.checked_at * 1000).toLocaleString()}</p> : null}{data.state === 'available' && !error ? <div role="status" dangerouslySetInnerHTML={{__html:noteHtml(data.message,{label:'有可用更新'})}} /> : <p class={error || data.state === 'error' ? 'configbad' : 'confighelp'} role={error || data.state === 'error' ? 'alert' : 'status'}>{error || data.message}</p>}diff --git a/frontend/test/automatic-updates.test.tsx b/frontend/test/automatic-updates.test.tsxnew file mode 100644index 000000000..e10947f18--- /dev/null+++ b/frontend/test/automatic-updates.test.tsx@@ -0,0 +1,39 @@+import { render } from 'preact';+import { act } from 'preact/test-utils';+import { afterEach, expect, it, vi } from 'vitest';+import { AutomaticUpdateSettings } from '../src/islands/automatic-updates';++// @ts-expect-error 遗留组件使用正式实现验证控件。+vi.mock('@peach/legacy/ui', () => import('../../web/js/ui-components.js'));+const host = document.createElement('div');+afterEach(() => { render(null, host); host.remove(); vi.unstubAllGlobals(); });+const initial = {mode:'off',interval_hours:24,available:true,download_available:true};++it('开关互相约束,保存服务端成功后才回执,关闭可持久保存', async () => {+ const receipt = vi.fn();+ const fetch = vi.fn(async (_url: string, _init: RequestInit) => ({ok:true,status:200,json:async () => initial}));+ vi.stubGlobal('fetch', fetch); document.body.append(host);+ await act(() => render(<AutomaticUpdateSettings initial={initial} receipt={receipt} />,host));+ const controls = host.querySelectorAll<HTMLInputElement>('[role="switch"]');+ expect(controls[1]!.disabled).toBe(true);+ await act(() => controls[0]!.click());+ expect(controls[1]!.disabled).toBe(false);+ await act(() => controls[1]!.click());+ await act(() => host.querySelector('form')!.requestSubmit());+ expect(JSON.parse(fetch.mock.calls[0]![1].body as string)).toEqual({mode:'download',interval_hours:24});+ await vi.waitFor(() => expect(receipt).toHaveBeenCalledWith('已保存自动更新设置'));+ await act(() => controls[0]!.click());+ await act(() => host.querySelector('form')!.requestSubmit());+ expect(JSON.parse(fetch.mock.calls[1]![1].body as string).mode).toBe('off');+ await vi.waitFor(() => expect(receipt).toHaveBeenCalledTimes(2));+});++it('源码运行禁用自动下载,失败原因留在表单且不报成功', async () => {+ const receipt = vi.fn();+ vi.stubGlobal('fetch', vi.fn(async () => ({ok:false,status:400,json:async () => ({detail:'设置正在保存'})})));+ await act(() => render(<AutomaticUpdateSettings initial={{...initial,mode:'check',download_available:false}} receipt={receipt} />,host));+ expect(host.querySelectorAll<HTMLInputElement>('[role="switch"]')[1]!.disabled).toBe(true);+ await act(() => host.querySelector('form')!.requestSubmit());+ await vi.waitFor(() => expect(host.querySelector('[role="alert"]')?.textContent).toContain('设置正在保存'));+ expect(receipt).not.toHaveBeenCalled();+});diff --git a/scripts/test_runner.py b/scripts/test_runner.pyindex 41ca002ca..408e0d8fb 100644--- a/scripts/test_runner.py+++ b/scripts/test_runner.py@@ -72,7 +72,7 @@ SCOPES: dict[str, tuple[str, ...]] = {"test_version_bump.py", "test_changelog.py", "test_release_due.py","test_restart_windows_tray.py", "test_deploy_windows_tray.py","test_buildinfo.py", "test_versioning.py",- "test_windows_update.py", "test_release_updates.py", "test_standalone_update.py", "test_certs.py", "test_config.py",+ "test_windows_update.py", "test_release_updates.py", "test_automatic_updates.py", "test_standalone_update.py", "test_certs.py", "test_config.py","test_fsutil.py", "test_desktop_settings.py","test_job_status.py", "test_jobs.py", "test_reference_updates.py","test_repo_hygiene.py",diff --git a/src/peach/api.py b/src/peach/api.pyindex 24ef39161..3e27f229f 100644--- a/src/peach/api.py+++ b/src/peach/api.py@@ -163,10 +163,17 @@ def create_app(available=sync is None or not sync.read_only,)contract.follow_scheduler = follow_scheduler+ from .automatic_updates import AutomaticUpdates+ from .routes_configuration import managed_configuration+ automatic_updates = AutomaticUpdates(+ settings.follow_state_root,+ available=managed_configuration() and bool(settings.configured),+ )@asynccontextmanagerasync def lifespan(_app: FastAPI):follow_scheduler.start()+ automatic_updates.start()if mdns is not None:try:await asyncio.to_thread(mdns.start)@@ -177,6 +184,7 @@ def create_app(yieldfinally:follow_scheduler.stop()+ automatic_updates.stop()# 死链检查和资源对账的后台线程是 daemon,本来挡不住进程退出;这里显式收# 一下,免得在途的那一轮在解释器拆卸期间还继续查库、往没人读的状态里写。contract.stop_background_jobs()@@ -211,6 +219,7 @@ def create_app(app.state.follow_media_resolver = follow_media_resolverapp.state.follow_cover_service = follow_cover_serviceapp.state.follow_scheduler = follow_scheduler+ app.state.automatic_updates = automatic_updatesapp.state.stream_sessions = StreamSessionRegistry()app.state.sync = syncdiff --git a/src/peach/automatic_updates.py b/src/peach/automatic_updates.pynew file mode 100644index 000000000..e2cc00e10--- /dev/null+++ b/src/peach/automatic_updates.py@@ -0,0 +1,110 @@+"""本机软件更新偏好与定时检查,复用发行查询、下载事务和 APScheduler。"""+from __future__ import annotations++import json+import time+from pathlib import Path++from apscheduler.schedulers.background import BackgroundScheduler+from filelock import FileLock, Timeout++from . import distribution, release_updates, standalone_update+from .fsutil import atomic_write_text+++class AutomaticUpdates:+ def __init__(self, root: Path, *, available: bool):+ self.path = root / "automatic-updates.json"+ self.available = available+ self.scheduler = BackgroundScheduler(timezone="UTC", daemon=True)++ def read(self) -> dict:+ try:+ data = json.loads(self.path.read_text(encoding="utf-8"))+ if (not isinstance(data, dict) or data.get("mode") not in ("off", "check", "download")+ or type(data.get("interval_hours")) is not int or data["interval_hours"] not in (6, 24, 168)):+ raise ValueError("invalid settings")+ return data+ except FileNotFoundError:+ return {"mode": "off", "interval_hours": 24}+ except (OSError, ValueError):+ return {"mode": "off", "interval_hours": 24, "error": "自动更新设置无法读取,请重新保存。"}++ def snapshot(self) -> dict:+ data = self.read()+ result = data.get("result")+ if isinstance(result, dict):+ if result.get("current_version") == release_updates.snapshot()["current_version"]:+ data["result"] = dict(result, checked_at=data.get("checked_at"))+ else:+ data.pop("result")+ return dict(data, available=self.available, download_available=distribution.standalone())++ def remember(self, result: dict) -> None:+ """手动检查与后台检查共享最近一次结果。"""+ self.path.parent.mkdir(parents=True, exist_ok=True)+ try:+ with FileLock(str(self.path) + ".lock", timeout=0):+ data = self.read()+ data.pop("error", None)+ self.write(dict(data, checked_at=time.time(), result=result))+ except Timeout:+ pass++ def write(self, data: dict) -> None:+ atomic_write_text(self.path, json.dumps(data, ensure_ascii=False))++ def save(self, body: dict) -> dict:+ if not self.available:+ raise ValueError("自动更新需要由托盘管理的服务")+ mode, hours = body.get("mode"), body.get("interval_hours")+ if mode not in ("off", "check", "download"):+ raise ValueError("请选择自动更新方式")+ if type(hours) is not int or hours not in (6, 24, 168):+ raise ValueError("请选择检查频率")+ if mode == "download" and not distribution.standalone():+ raise ValueError("自动下载仅适用于 Windows 独立测试包")+ self.path.parent.mkdir(parents=True, exist_ok=True)+ with FileLock(str(self.path) + ".lock", timeout=0):+ current = self.read()+ if current.get("mode") == mode and current.get("interval_hours") == hours and not current.get("error"):+ return self.snapshot()+ self.write({"mode": mode, "interval_hours": hours})+ return self.snapshot()++ def tick(self) -> None:+ if not self.available or self.read()["mode"] == "off":+ return+ try:+ with FileLock(str(self.path) + ".lock", timeout=0):+ data = self.read()+ if data["mode"] == "off":+ return+ now = time.time()+ last = data.get("checked_at", 0)+ if isinstance(last, (int, float)) and 0 <= now - last < data["interval_hours"] * 3600:+ return+ # 先落检查时间;进程中断后也按频率重试,多服务共用这一份记录。+ self.write(dict(data, checked_at=now))+ result = release_updates.check()+ data.pop("error", None)+ data = dict(data, checked_at=now, result=result)+ self.write(data)+ if data["mode"] == "download" and distribution.standalone() and result["state"] == "available":+ job = standalone_update.public()+ if job["state"] not in standalone_update.ACTIVE | {"ready"}:+ try:+ standalone_update.start()+ except (ValueError, Timeout) as exc:+ self.write(dict(data, error=str(exc)))+ except Timeout:+ return++ def start(self) -> None:+ if self.available:+ self.scheduler.add_job(self.tick, "interval", seconds=60, max_instances=1, coalesce=True)+ self.scheduler.start()++ def stop(self) -> None:+ if self.scheduler.running:+ self.scheduler.shutdown(wait=False)diff --git a/src/peach/routes_configuration.py b/src/peach/routes_configuration.pyindex 8a9702cf7..d00855949 100644--- a/src/peach/routes_configuration.py+++ b/src/peach/routes_configuration.py@@ -108,7 +108,27 @@ def read_configuration(request: Request, _args=Depends(require_auth)):config = settings_file.load_config()if not config.present:raise HTTPException(409, "请先完成首次设置")- return snapshot(config)+ result = snapshot(config)+ result["automatic_updates"] = request.app.state.automatic_updates.snapshot()+ if result["automatic_updates"].get("result"):+ result["updates"] = result["automatic_updates"]["result"]+ return result++[email protected]("/api/configuration/automatic-updates")+def read_automatic_updates(request: Request, _args=Depends(require_auth)):+ local_only(request)+ return request.app.state.automatic_updates.snapshot()++[email protected]("/api/configuration/automatic-updates")+def save_automatic_updates(request: Request, body: dict = Body(...), _args=Depends(require_auth)):+ local_only(request)+ same_origin(request)+ try:+ return request.app.state.automatic_updates.save(body)+ except (ValueError, OSError, Timeout) as exc:+ raise HTTPException(400, str(exc)) from exc@router.post("/api/configuration/peach-proxy")@@ -151,7 +171,9 @@ def uninstall(request: Request, body: dict = Body(...), _args=Depends(require_au@router.get("/api/configuration/updates")def check_updates(request: Request, _args=Depends(require_auth)):local_only(request)- return release_updates.check()+ result = release_updates.check()+ request.app.state.automatic_updates.remember(result)+ return result@router.get("/api/configuration/update-status")diff --git a/tests/test_automatic_updates.py b/tests/test_automatic_updates.pynew file mode 100644index 000000000..7ccb2445b--- /dev/null+++ b/tests/test_automatic_updates.py@@ -0,0 +1,79 @@+"""自动更新的持久设置、跨服务互斥和安装边界。"""+from pathlib import Path+import tempfile+import unittest+from unittest.mock import patch++from filelock import FileLock+from peach.automatic_updates import AutomaticUpdates+++class AutomaticUpdateTests(unittest.TestCase):+ def setUp(self):+ self.temp = tempfile.TemporaryDirectory()+ self.addCleanup(self.temp.cleanup)+ self.root = Path(self.temp.name).resolve()+ self.updates = AutomaticUpdates(self.root, available=True)++ def test_settings_roundtrip_disable_and_validate_installation(self):+ self.assertEqual(self.updates.snapshot()["mode"], "off")+ self.updates.save({"mode": "check", "interval_hours": 6})+ self.assertEqual(AutomaticUpdates(self.root, available=True).read()["mode"], "check")+ for body in ({"mode": [], "interval_hours": 24}, {"mode": "check", "interval_hours": True},+ {"mode": "check", "interval_hours": 1}):+ with self.assertRaises(ValueError):+ self.updates.save(body)+ with patch("peach.distribution.standalone", return_value=False), self.assertRaises(ValueError):+ self.updates.save({"mode": "download", "interval_hours": 24})+ self.updates.save({"mode": "off", "interval_hours": 24})+ with patch("peach.release_updates.check") as check:+ self.updates.tick()+ check.assert_not_called()++ def test_two_services_share_due_time_and_respect_file_lock(self):+ self.updates.save({"mode": "check", "interval_hours": 24})+ other = AutomaticUpdates(self.root, available=True)+ with patch("peach.release_updates.check", return_value={"state": "current"}) as check, patch(+ "peach.automatic_updates.time.time", return_value=200000):+ with FileLock(str(self.updates.path) + ".lock", timeout=0):+ other.tick()+ check.assert_not_called()+ self.updates.tick()+ other.tick()+ check.assert_called_once()+ with patch("peach.release_updates.check", return_value={"state": "error"}) as check, patch(+ "peach.automatic_updates.time.time", return_value=300000):+ other.tick()+ self.updates.tick()+ check.assert_called_once()+ self.assertEqual(self.updates.read()["result"]["state"], "error")++ def test_download_prepares_once_and_never_requests_restart(self):+ with patch("peach.distribution.standalone", return_value=True), patch(+ "peach.release_updates.check", return_value={"state": "available"}), patch(+ "peach.standalone_update.public", return_value={"state": "idle"}), patch(+ "peach.standalone_update.start") as start, patch("peach.standalone_update.request_restart") as restart:+ self.updates.save({"mode": "download", "interval_hours": 24})+ self.updates.tick()+ self.updates.tick()+ start.assert_called_once()+ restart.assert_not_called()+ for state in ("ready", "downloading", "installing"):+ with patch("peach.distribution.standalone", return_value=True), patch(+ "peach.release_updates.check", return_value={"state": "available"}), patch(+ "peach.standalone_update.public", return_value={"state": state}), patch(+ "peach.standalone_update.start") as start:+ self.updates.write({"mode": "download", "interval_hours": 24})+ self.updates.tick()+ start.assert_not_called()++ def test_unmanaged_and_corrupt_settings_fail_closed(self):+ other = AutomaticUpdates(self.root, available=False)+ with self.assertRaises(ValueError):+ other.save({"mode": "check", "interval_hours": 24})+ self.updates.path.write_text('[]', encoding="utf-8")+ self.assertIn("error", self.updates.snapshot())+ with patch("peach.release_updates.check") as check:+ self.updates.tick()+ other.tick()+ check.assert_not_called()diff --git a/tests/test_onboarding.py b/tests/test_onboarding.pyindex 87217dd25..00d03f55a 100644--- a/tests/test_onboarding.py+++ b/tests/test_onboarding.py@@ -661,6 +661,24 @@ class SetupPageTests(_Case):class StandaloneConfigurationTests(_Case):+ def test_automatic_update_settings_roundtrip_and_access_boundaries(self):+ from peach.automatic_updates import AutomaticUpdates+ path = "/api/configuration/automatic-updates"+ headers = {"X-Token": "test-token"}+ with self.client() as client:+ client.app.state.automatic_updates = AutomaticUpdates(self.root, available=True)+ self.assertEqual(client.get(path).status_code, 401)+ self.assertEqual(client.post(path, headers=dict(headers, Origin="https://evil.example"),+ json={"mode": "check", "interval_hours": 24}).status_code, 403)+ saved = client.post(path, headers=headers, json={"mode": "download", "interval_hours": 6})+ self.assertEqual(saved.status_code, 200, saved.text)+ self.assertEqual(client.get(path, headers=headers).json()["mode"], "download")+ self.assertEqual(client.get("/api/configuration", headers=headers).json()["automatic_updates"]["interval_hours"], 6)+ self.assertEqual(client.post(path, headers=headers, json={"mode": "off", "interval_hours": 24}).status_code, 200)+ with self.client(address="192.0.2.9") as client:+ self.assertEqual(client.get(path, headers=headers).status_code, 403)+ self.assertEqual(client.post(path, headers=headers, json={}).status_code, 403)+def test_release_update_endpoints_require_local_authenticated_access(self):with self.client() as client, mock.patch("peach.release_updates.check", return_value={"state": "current"}) as check:self.assertEqual(client.get("/api/configuration/updates").status_code, 401)@@ -723,6 +741,7 @@ class StandaloneConfigurationTests(_Case):from peach.api import create_appfrom peach.config import PeachSettingsapp = create_app(PeachSettings(configured=True, token=token, mdns_name="peach-writer",+ follow_state_root=self.root / "state",db_path=self.config.data_root / "database" / "ledger.db"))if server:@app.middleware("http")diff --git a/web/dist/peach-ui.js b/web/dist/peach-ui.jsindex 97db43df4..79b1d9fc4 100644--- a/web/dist/peach-ui.js+++ b/web/dist/peach-ui.js@@ -1844,22 +1844,25 @@ function Tn({ initial: e, initialJob: t }) {onConfirm: g}));}, [i.state]), H(() => {- if (!wn.has(i.state)) return;let e = new AbortController(), t, n = 0, o = async () => {try {let t = await K("/api/configuration/update-status", e.signal);- e.signal.aborted || (a(t), n = 0, t.state === "complete" && r((e) => ({- ...e,- current_version: t.version || e.current_version,- state: "current",- message: "已是最新测试版。"- })));+ if (!e.signal.aborted) {+ a(t), n = 0, t.state === "complete" && r((e) => ({+ ...e,+ current_version: t.version || e.current_version,+ state: "current",+ message: "已是最新测试版。"+ }));+ let i = await K("/api/configuration/automatic-updates", e.signal);+ !e.signal.aborted && i.result && r(i.result);+ }} catch {++n >= 120 && !e.signal.aborted && s("尚未连接到 Peach,请检查托盘后刷新页面。");}- !e.signal.aborted && n < 120 && (t = setTimeout(o, 1e3));+ !e.signal.aborted && n < 120 && (t = setTimeout(o, wn.has(i.state) ? 1e3 : 3e4));};- return t = setTimeout(o, 1e3), () => {+ return t = setTimeout(o, wn.has(i.state) ? 1e3 : 3e4), () => {e.abort(), clearTimeout(t);};}, [i.state]);@@ -1912,6 +1915,10 @@ function Tn({ initial: e, initialJob: t }) {/* @__PURE__ */ J("dd", { children: n.latest_version || (n.state === "unchecked" ? "尚未检查" : "未取得") })]}),+ n.checked_at ? /* @__PURE__ */ J("p", {+ class: "confighelp",+ children: ["检查于 ", (/* @__PURE__ */ new Date(n.checked_at * 1e3)).toLocaleString()]+ }) : null,n.state === "available" && !o ? /* @__PURE__ */ J("div", {role: "status",dangerouslySetInnerHTML: { __html: p(n.message, { label: "有可用更新" }) }@@ -2000,8 +2007,103 @@ function Tn({ initial: e, initialJob: t }) {});}//#endregion-//#region src/islands/peach-proxy.tsx+//#region src/islands/automatic-updates.tsxfunction En({ initial: e, receipt: t }) {+ let [n, r] = V(e.mode), [i, a] = V(e.interval_hours), [o, s] = V(e.error || ""), c = W(null), l = W(null), u = W(!1), f = W(new AbortController());+ H(() => () => f.current.abort(), []), U(() => {+ let t = c.current;+ t.innerHTML = g([+ ["6", "每 6 小时"],+ ["24", "每天"],+ ["168", "每周"]+ ], String(e.interval_hours), {+ label: "检查频率",+ className: "configselect",+ attr: "data-fixed-width"+ });+ let n = b(t.firstElementChild), r = () => a(Number(n.value));+ return n.addEventListener("change", r), () => {+ n.removeEventListener("change", r), t.replaceChildren();+ };+ }, []);+ async function p() {+ if (!u.current) {+ u.current = !0, v(l.current, !0), s("");+ try {+ await q("/api/configuration/automatic-updates", {+ mode: n,+ interval_hours: i+ }, "POST", f.current.signal), f.current.signal.aborted || t("已保存自动更新设置");+ } catch (e) {+ f.current.signal.aborted || s(G(e));+ } finally {+ u.current = !1, v(l.current, !1);+ }+ }+ }+ return /* @__PURE__ */ J("form", {+ class: "configfieldset",+ "data-geist-fieldset": !0,+ onSubmit: (e) => {+ e.preventDefault(), p();+ },+ children: [/* @__PURE__ */ J("div", {+ class: "geist-fieldset-content",+ children: [+ /* @__PURE__ */ J("div", { dangerouslySetInnerHTML: { __html: d("automaticUpdatesTitle", "自动更新") } }),+ /* @__PURE__ */ J("div", {+ class: "configoptions",+ role: "group",+ "aria-labelledby": "automaticUpdatesTitle",+ children: [/* @__PURE__ */ J("label", {+ class: "configtoggle",+ children: [/* @__PURE__ */ J("span", { children: "自动检查新版本" }), /* @__PURE__ */ J("input", {+ class: "ptoggle",+ type: "checkbox",+ role: "switch",+ checked: n !== "off",+ disabled: !e.available,+ onChange: (e) => r(e.currentTarget.checked ? "check" : "off")+ })]+ }), /* @__PURE__ */ J("label", {+ class: "configtoggle",+ children: [/* @__PURE__ */ J("span", { children: "自动下载更新" }), /* @__PURE__ */ J("input", {+ class: "ptoggle",+ type: "checkbox",+ role: "switch",+ checked: n === "download",+ disabled: !e.available || !e.download_available || n === "off",+ onChange: (e) => r(e.currentTarget.checked ? "download" : "check")+ })]+ })]+ }),+ /* @__PURE__ */ J("div", { ref: c }),+ /* @__PURE__ */ J("p", {+ class: "confighelp",+ children: e.available ? e.download_available ? "开启后一分钟内开始检查。下载完成后,在此确认重启安装。" : "开启后一分钟内开始检查。源码运行请前往发布页获取新版本。" : "自动更新需要由托盘管理的服务。"+ }),+ o && /* @__PURE__ */ J("p", {+ class: "configbad",+ role: "alert",+ children: o+ })+ ]+ }), /* @__PURE__ */ J("footer", {+ class: "geist-fieldset-footer",+ "data-geist-fieldset-footer": !0,+ children: /* @__PURE__ */ J("button", {+ ref: l,+ type: "submit",+ class: "geist-button",+ disabled: !e.available,+ children: "保存自动更新"+ })+ })]+ });+}+//#endregion+//#region src/islands/peach-proxy.tsx+function Dn({ initial: e, receipt: t }) {let [n, r] = V(e), [i, a] = V(e.mode), [o, s] = V(""), [c, l] = V(""), u = W(!1), f = W(null), p = W(null), m = W(new AbortController());H(() => () => m.current.abort(), []), U(() => {let t = f.current;@@ -2092,7 +2194,7 @@ function En({ initial: e, receipt: t }) {}//#endregion//#region src/islands/desktop-settings.tsx-function Dn({ label: e, checked: t, disabled: n, change: r }) {+function On({ label: e, checked: t, disabled: n, change: r }) {return /* @__PURE__ */ J("label", {class: "configcheck",children: [/* @__PURE__ */ J("span", {@@ -2112,7 +2214,7 @@ function Dn({ label: e, checked: t, disabled: n, change: r }) {}), /* @__PURE__ */ J("span", { children: e })]});}-function On({ label: e, checked: t, disabled: n, change: r }) {+function kn({ label: e, checked: t, disabled: n, change: r }) {return /* @__PURE__ */ J("label", {class: "configtoggle",children: [/* @__PURE__ */ J("span", { children: e }), /* @__PURE__ */ J("input", {@@ -2125,7 +2227,7 @@ function On({ label: e, checked: t, disabled: n, change: r }) {})]});}-function kn({ startup: e, receipt: t }) {+function An({ startup: e, receipt: t }) {let [n, r] = V(e.enabled), [i, a] = V(e.silent), [o, s] = V(e.desktop), [c, l] = V(""), u = W(!1), f = W(null), p = e.available && !e.desktop_message;async function m() {if (!u.current) {@@ -2158,7 +2260,7 @@ function kn({ startup: e, receipt: t }) {role: "group","aria-labelledby": "startupTitle",children: [- /* @__PURE__ */ J(On, {+ /* @__PURE__ */ J(kn, {label: "开机后启动 Peach",checked: n,disabled: !e.available,@@ -2166,7 +2268,7 @@ function kn({ startup: e, receipt: t }) {}),/* @__PURE__ */ J("div", {class: "configoption",- children: [/* @__PURE__ */ J(On, {+ children: [/* @__PURE__ */ J(kn, {label: "静默启动",checked: i,disabled: !e.available || !n,@@ -2178,7 +2280,7 @@ function kn({ startup: e, receipt: t }) {}),/* @__PURE__ */ J("div", {class: "configoption",- children: [/* @__PURE__ */ J(On, {+ children: [/* @__PURE__ */ J(kn, {label: "在桌面创建快捷方式",checked: o,disabled: !p,@@ -2213,7 +2315,7 @@ function kn({ startup: e, receipt: t }) {})]});}-function An({ data: e }) {+function jn({ data: e }) {let t = W(null);return U(() => {let n = t.current, r = document.createElement("details");@@ -2227,7 +2329,7 @@ function An({ data: e }) {return n.replaceChildren(r), y(n, "details", "uninstall-data"), () => n.replaceChildren();}, [e]), /* @__PURE__ */ J("div", { ref: t });}-function jn({ uninstall: e }) {+function Mn({ uninstall: e }) {let [t, n] = V(!1), [r, i] = V("");async function a() {await l({@@ -2259,13 +2361,13 @@ function jn({ uninstall: e }) {children: "卸载会退出 Peach、移除程序、开机自启和桌面图标。原始媒体文件保留。"})]}),- /* @__PURE__ */ J(Dn, {+ /* @__PURE__ */ J(On, {label: "完全卸载:同时删除设置、本地数据库、观看记录、凭据和缓存",checked: t,disabled: !e.full_available || !!r,change: n}),- /* @__PURE__ */ J(An, { data: e }),+ /* @__PURE__ */ J(jn, { data: e }),e.message && /* @__PURE__ */ J("p", {class: "confighelp",children: e.message@@ -2291,7 +2393,7 @@ function jn({ uninstall: e }) {}//#endregion//#region src/islands/clouddrive-guide.tsx-var Mn = [+var Nn = [{name: "机械硬盘,或内存 8 GB 以内",cache: "10–20 GiB",@@ -2311,7 +2413,7 @@ var Mn = [task: "2 个起步"}];-function Nn() {+function Pn() {let e = W(null);return U(() => {e.current && y(e.current, "details", "clouddrive-guide");@@ -2363,7 +2465,7 @@ function Nn() {scope: "col",children: "同时处理视频"})- ] }) }), /* @__PURE__ */ J("tbody", { children: Mn.map((e) => /* @__PURE__ */ J("tr", { children: [+ ] }) }), /* @__PURE__ */ J("tbody", { children: Nn.map((e) => /* @__PURE__ */ J("tr", { children: [/* @__PURE__ */ J("th", {scope: "row",children: e.name@@ -2407,7 +2509,7 @@ function Nn() {}//#endregion//#region src/library-icon-picker.tsx-var Pn = [+var Fn = [["", "自动识别"],["hard-drive", "磁盘"],["database", "资料库"],@@ -2451,12 +2553,12 @@ var Pn = [["star", "收藏"],["tags", "主题"]];-function Fn(e) {+function In(e) {let t = e === "local" ? "" : s[e];return t ? [t, "自动识别"] : ["hard-drive", "默认"];}-function In({ value: e, label: t, kind: n = "local", onChange: r }) {- let [i, a] = V(e), o = W(null), s = W(null), [c, l] = Fn(n), u = (e) => /* @__PURE__ */ J("span", {+function Ln({ value: e, label: t, kind: n = "local", onChange: r }) {+ let [i, a] = V(e), o = W(null), s = W(null), [c, l] = In(n), u = (e) => /* @__PURE__ */ J("span", {"aria-hidden": "true",dangerouslySetInnerHTML: { __html: _(e || c) }}), d = (e, t) => e ? t : l;@@ -2475,7 +2577,7 @@ function In({ value: e, label: t, kind: n = "local", onChange: r }) {let r = t.getBoundingClientRect();t.style.left = `${Math.max(8, Math.min(innerWidth - r.width - 8, n.left))}px`, t.style.top = `${n.bottom + r.height + 8 <= innerHeight ? n.bottom + 4 : Math.max(8, n.top - r.height - 4)}px`;},- children: [u(e), /* @__PURE__ */ J("span", { children: d(e, Pn.find(([t]) => t === e)?.[1] || l) })]+ children: [u(e), /* @__PURE__ */ J("span", { children: d(e, Fn.find(([t]) => t === e)?.[1] || l) })]}), /* @__PURE__ */ J("dialog", {ref: o,class: "board-icon-popover",@@ -2490,7 +2592,7 @@ function In({ value: e, label: t, kind: n = "local", onChange: r }) {role: "radiogroup","aria-label": "候选图标",class: "board-icon-grid",- children: Pn.map(([e, n]) => /* @__PURE__ */ J("label", {+ children: Fn.map(([e, n]) => /* @__PURE__ */ J("label", {title: d(e, n),class: i === e ? "selected" : "",children: [/* @__PURE__ */ J("input", {@@ -2524,18 +2626,18 @@ function In({ value: e, label: t, kind: n = "local", onChange: r }) {}//#endregion//#region src/islands/configuration.tsx-var Ln = "/api/configuration", Rn = "/api/pick-folder", zn = 8e3, Bn = (e, t) => K(Ln, t), Vn = ({ html: e, class: t }) => /* @__PURE__ */ J("div", {+var Rn = "/api/configuration", zn = "/api/pick-folder", Bn = 8e3, Vn = (e, t) => K(Rn, t), Hn = ({ html: e, class: t }) => /* @__PURE__ */ J("div", {class: t,dangerouslySetInnerHTML: { __html: e }-}), Hn = (e) => !(e instanceof ot) || e.status !== 400 ? null : e.body?.errors ?? null;-function Un({ facts: e }) {+}), Un = (e) => !(e instanceof ot) || e.status !== 400 ? null : e.body?.errors ?? null;+function Wn({ facts: e }) {return /* @__PURE__ */ J("section", {class: "configfieldset","data-geist-fieldset": !0,"aria-labelledby": "configFactsTitle",children: /* @__PURE__ */ J("div", {class: "geist-fieldset-content",- children: [/* @__PURE__ */ J(Vn, { html: d("configFactsTitle", "运行信息") }), /* @__PURE__ */ J("dl", {+ children: [/* @__PURE__ */ J(Hn, { html: d("configFactsTitle", "运行信息") }), /* @__PURE__ */ J("dl", {class: "configfacts",children: e.map((e) => /* @__PURE__ */ J(L, { children: [/* @__PURE__ */ J("dt", { children: e.term }), /* @__PURE__ */ J("dd", { children: [e.value, e.download_url ? /* @__PURE__ */ J("span", {class: "confighelp",@@ -2556,7 +2658,7 @@ function Un({ facts: e }) {})});}-function Wn({ data: e }) {+function Gn({ data: e }) {let [t, n] = V(e.media_sources), [r, i] = V(""), a = W(null);H(() => () => a.current?.abort(), []);let o = async (e) => {@@ -2564,7 +2666,7 @@ function Wn({ data: e }) {let t = new AbortController();a.current = t, v(e, !0), i("");try {- let e = await K(Ln, t.signal);+ let e = await K(Rn, t.signal);t.signal.aborted || n(e.media_sources);} catch (e) {t.signal.aborted || i(G(e));@@ -2578,7 +2680,7 @@ function Wn({ data: e }) {children: [/* @__PURE__ */ J("div", {class: "geist-fieldset-content",children: [- /* @__PURE__ */ J(Vn, { html: d("configMountsTitle", "挂载状态") }),+ /* @__PURE__ */ J(Hn, { html: d("configMountsTitle", "挂载状态") }),/* @__PURE__ */ J("dl", {class: "configfacts",children: t.map((e) => /* @__PURE__ */ J(L, { children: [/* @__PURE__ */ J("dt", { children: [/* @__PURE__ */ J("span", {@@ -2615,7 +2717,7 @@ function Wn({ data: e }) {})]}) : null;}-function Gn({ value: e, label: t, onChange: n }) {+function Kn({ value: e, label: t, onChange: n }) {let r = W(null), i = W(null), a = W(n);return a.current = n, U(() => {let n = r.current;@@ -2641,7 +2743,7 @@ function Gn({ value: e, label: t, onChange: n }) {class: "configsourcecontrol"});}-function Kn({ data: e, receipt: t }) {+function qn({ data: e, receipt: t }) {let n = e.media_sources?.filter((e) => ["local","115",@@ -2651,7 +2753,7 @@ function Kn({ data: e, receipt: t }) {O !== null && (ee.current[O]?.focus(), k(null));}, [O]), H(() => {if (!E) return;- let e = setTimeout(() => location.assign(E.url), zn);+ let e = setTimeout(() => location.assign(E.url), Bn);return () => clearTimeout(e);}, [E]);let N = (e, t) => {@@ -2670,7 +2772,7 @@ function Kn({ data: e, receipt: t }) {if (t.getAttribute("aria-busy") !== "true") {v(t, !0);try {- let { path: t } = await q(Rn, { initial: r[e] ?? "" });+ let { path: t } = await q(zn, { initial: r[e] ?? "" });t && (N(e, t), F(e, ""));} catch (t) {F(e, G(t));@@ -2706,7 +2808,7 @@ function Kn({ data: e, receipt: t }) {if (n.preventDefault(), !A.current) {A.current = !0, v(M.current, !0), T("");try {- let n = await q(Ln, {+ let n = await q(Rn, {revision: j.current,media_dirs: r,...e.media_sources ? { media_sources: r.map((e, t) => ({@@ -2721,7 +2823,7 @@ function Kn({ data: e, receipt: t }) {});j.current = n.revision, x([]), C(""), t("已保存配置"), D(n);} catch (e) {- let t = Hn(e);+ let t = Un(e);t ? (x(t.media_dirs ?? []), C(t.port ?? "")) : (x([]), C(""), T(G(e)));} finally {A.current = !1, v(M.current, !1);@@ -2732,7 +2834,7 @@ function Kn({ data: e, receipt: t }) {children: [/* @__PURE__ */ J("div", {class: "geist-fieldset-content",children: [- /* @__PURE__ */ J(Vn, { html: d("configTitle", "这台电脑") }),+ /* @__PURE__ */ J(Hn, { html: d("configTitle", "这台电脑") }),/* @__PURE__ */ J("div", {class: "configfield",children: [@@ -2801,7 +2903,7 @@ function Kn({ data: e, receipt: t }) {})] }),/* @__PURE__ */ J("div", {class: "configsourcelabel",- children: ["媒体库图标", /* @__PURE__ */ J(In, {+ children: ["媒体库图标", /* @__PURE__ */ J(Ln, {label: `媒体库图标 ${n + 1}`,value: f[n] || "",kind: a[n] || "local",@@ -2813,7 +2915,7 @@ function Kn({ data: e, receipt: t }) {}),/* @__PURE__ */ J("div", {class: "configsourcelabel",- children: ["媒体来源", /* @__PURE__ */ J(Gn, {+ children: ["媒体来源", /* @__PURE__ */ J(Kn, {label: `媒体来源 ${n + 1}`,value: a[n] || "local",onChange: (e) => {@@ -2848,7 +2950,7 @@ function Kn({ data: e, receipt: t }) {onClick: te,children: "添加文件夹"}),- a.some((e) => e === "115" || e === "pikpak") ? /* @__PURE__ */ J(Nn, {}) : null,+ a.some((e) => e === "115" || e === "pikpak") ? /* @__PURE__ */ J(Pn, {}) : null,a.some((e) => e === "115" || e === "pikpak") ? e.mount_dependencies?.filter((e) => !e.available).map((e) => /* @__PURE__ */ J("p", {class: "confighelp",children: [@@ -2923,7 +3025,7 @@ function Kn({ data: e, receipt: t }) {})]}), /* @__PURE__ */ J("span", { children: "保存后扫描并补全资料" })]}),- w ? /* @__PURE__ */ J(Vn, { html: p(w, {+ w ? /* @__PURE__ */ J(Hn, { html: p(w, {variant: "error",label: "没有保存"}) }) : null@@ -2940,8 +3042,8 @@ function Kn({ data: e, receipt: t }) {})]});}-function qn({ receipt: e, data: t, error: n }) {- return n || !t ? /* @__PURE__ */ J(Vn, {+function Jn({ receipt: e, data: t, error: n }) {+ return n || !t ? /* @__PURE__ */ J(Hn, {class: "configpage",html: p(n || "没有读到配置", {variant: "error",@@ -2954,7 +3056,7 @@ function qn({ receipt: e, data: t, error: n }) {class: "configgroup",children: "通用"}) : null,- t.startup ? /* @__PURE__ */ J(kn, {+ t.startup ? /* @__PURE__ */ J(An, {startup: t.startup,receipt: e}) : null,@@ -2962,19 +3064,19 @@ function qn({ receipt: e, data: t, error: n }) {class: "configgroup",children: "媒体"}),- t.editable ? /* @__PURE__ */ J(Kn, {+ t.editable ? /* @__PURE__ */ J(qn, {data: t,receipt: e- }) : /* @__PURE__ */ J(Vn, { html: p(t.notice, {+ }) : /* @__PURE__ */ J(Hn, { html: p(t.notice, {variant: "secondary",label: "只读"}) }),- /* @__PURE__ */ J(Wn, { data: t }),+ /* @__PURE__ */ J(Gn, { data: t }),t.peach_proxy || t.access ? /* @__PURE__ */ J("h2", {class: "configgroup",children: "网络与访问"}) : null,- t.peach_proxy ? /* @__PURE__ */ J(En, {+ t.peach_proxy ? /* @__PURE__ */ J(Dn, {initial: t.peach_proxy,receipt: e}) : null,@@ -2986,34 +3088,38 @@ function qn({ receipt: e, data: t, error: n }) {class: "configgroup",children: "更新与维护"}),+ t.automatic_updates ? /* @__PURE__ */ J(En, {+ initial: t.automatic_updates,+ receipt: e+ }) : null,t.updates ? /* @__PURE__ */ J(Tn, {initial: t.updates,initialJob: t.update_job}) : null,- /* @__PURE__ */ J(Un, { facts: t.facts }),- t.uninstall ? /* @__PURE__ */ J(jn, { uninstall: t.uninstall }) : null+ /* @__PURE__ */ J(Wn, { facts: t.facts }),+ t.uninstall ? /* @__PURE__ */ J(Mn, { uninstall: t.uninstall }) : null]});}//#endregion//#region node_modules/@preact/signals-core/dist/signals-core.module.js-var Jn = Symbol.for("preact-signals");-function Yn() {+var Yn = Symbol.for("preact-signals");+function Xn() {if (Z > 1) Z--;else {var e, t = !1;for ((function() {- var e = rr;- for (rr = void 0; e !== void 0;) {+ var e = ir;+ for (ir = void 0; e !== void 0;) {var t = e.S;if (t.v === e.v) for (var n = t.t; n !== void 0; n = n.x) n.i === e.i && (n.i = t.i);e = e.o;}- })(); $n !== void 0;) {- var n = $n;- for ($n = void 0, er++; n !== void 0;) {+ })(); er !== void 0;) {+ var n = er;+ for (er = void 0, tr++; n !== void 0;) {var r = n.u;- if (n.u = void 0, n.f &= -3, !(8 & n.f) && sr(n)) try {+ if (n.u = void 0, n.f &= -3, !(8 & n.f) && cr(n)) try {n.c();} catch (n) {t ||= (e = n, !0);@@ -3021,30 +3127,30 @@ function Yn() {n = r;}}- if (er = 0, Z--, t) throw e;+ if (tr = 0, Z--, t) throw e;}}-function Xn(e) {+function Zn(e) {if (Z > 0) return e();- nr = ++tr, Z++;+ rr = ++nr, Z++;try {return e();} finally {- Yn();+ Xn();}}-var Zn, X = void 0;-function Qn(e) {- var t = X, n = Zn;- X = void 0, Zn = void 0;+var Qn, X = void 0;+function $n(e) {+ var t = X, n = Qn;+ X = void 0, Qn = void 0;try {return e();} finally {- X = t, Zn = n;+ X = t, Qn = n;}}-var $n = void 0, Z = 0, er = 0, tr = 0, nr = 0, rr = void 0, ir = 0;-function ar(e) {+var er = void 0, Z = 0, tr = 0, nr = 0, rr = 0, ir = void 0, ar = 0;+function or(e) {if (X !== void 0) {var t = e.n;if (t === void 0 || t.t !== X) return t = {@@ -3063,11 +3169,11 @@ function ar(e) {function Q(e, t) {this.v = e, this.i = 0, this.n = void 0, this.t = void 0, this.l = 0, this.W = t?.watched, this.Z = t?.unwatched, this.name = t?.name;}-Q.prototype.brand = Jn, Q.prototype.h = function() {+Q.prototype.brand = Yn, Q.prototype.h = function() {return !0;}, Q.prototype.S = function(e) {var t = this, n = this.t;- n !== e && e.e === void 0 && (e.x = n, this.t = e, n === void 0 ? Qn(function() {+ n !== e && e.e === void 0 && (e.x = n, this.t = e, n === void 0 ? $n(function() {var e;(e = t.W) == null || e.call(t);}) : n.e = e);@@ -3075,16 +3181,16 @@ Q.prototype.brand = Jn, Q.prototype.h = function() {var t = this;if (this.t !== void 0) {var n = e.e, r = e.x;- n !== void 0 && (n.x = r, e.e = void 0), r !== void 0 && (r.e = n, e.x = void 0), e === this.t && (this.t = r, r === void 0 && Qn(function() {+ n !== void 0 && (n.x = r, e.e = void 0), r !== void 0 && (r.e = n, e.x = void 0), e === this.t && (this.t = r, r === void 0 && $n(function() {var e;(e = t.Z) == null || e.call(t);}));}}, Q.prototype.subscribe = function(e) {var t = this;- return gr(function() {+ return _r(function() {var n = t.value;- Qn(function() {+ $n(function() {return e(n);});}, { name: "sub" });@@ -3096,41 +3202,41 @@ Q.prototype.brand = Jn, Q.prototype.h = function() {return this.value;}, Q.prototype.peek = function() {var e = this;- return Qn(function() {+ return $n(function() {return e.value;});}, Object.defineProperty(Q.prototype, "value", {get: function() {- var e = ar(this);+ var e = or(this);return e !== void 0 && (e.i = this.i), this.v;},set: function(e) {if (e !== this.v) {- if (er > 100) throw Error("Cycle detected");+ if (tr > 100) throw Error("Cycle detected");(function(e) {- Z !== 0 && er === 0 && e.l !== nr && (e.l = nr, rr = {+ Z !== 0 && tr === 0 && e.l !== rr && (e.l = rr, ir = {S: e,v: e.v,i: e.i,- o: rr+ o: ir});- })(this), this.v = e, this.i++, ir++, Z++;+ })(this), this.v = e, this.i++, ar++, Z++;try {for (var t = this.t; t !== void 0; t = t.x) t.t.N();} finally {- Yn();+ Xn();}}}});-function or(e, t) {+function sr(e, t) {return new Q(e, t);}-function sr(e) {+function cr(e) {for (var t = e.s; t !== void 0; t = t.n) if (t.S.i !== t.i || !t.S.h() || t.S.i !== t.i) return !0;return !1;}-function cr(e) {+function lr(e) {for (var t = e.s; t !== void 0; t = t.n) {var n = t.S.n;if (n !== void 0 && (t.r = n), t.S.n = t, t.i = -1, t.n === void 0) {@@ -3139,55 +3245,55 @@ function cr(e) {}}}-function lr(e) {+function ur(e) {for (var t = e.s, n = void 0; t !== void 0;) {var r = t.p;t.i === -1 ? (t.S.U(t), r !== void 0 && (r.n = t.n), t.n !== void 0 && (t.n.p = r)) : n = t, t.S.n = t.r, t.r !== void 0 && (t.r = void 0), t = r;}e.s = n;}-function ur(e, t) {- Q.call(this, void 0, t), this.x = e, this.s = void 0, this.g = ir - 1, this.f = 4;+function dr(e, t) {+ Q.call(this, void 0, t), this.x = e, this.s = void 0, this.g = ar - 1, this.f = 4;}-ur.prototype = new Q(), ur.prototype.h = function() {+dr.prototype = new Q(), dr.prototype.h = function() {if (this.f &= -3, 1 & this.f) return !1;- if ((36 & this.f) == 32 || (this.f &= -5, this.g === ir)) return !0;- if (this.g = ir, this.f |= 1, this.i > 0 && !sr(this)) return this.f &= -2, !0;+ if ((36 & this.f) == 32 || (this.f &= -5, this.g === ar)) return !0;+ if (this.g = ar, this.f |= 1, this.i > 0 && !cr(this)) return this.f &= -2, !0;var e = X;try {- cr(this), X = this;+ lr(this), X = this;var t = this.x();(16 & this.f || this.v !== t || this.i === 0) && (this.v = t, this.f &= -17, this.i++);} catch (e) {this.v = e, this.f |= 16, this.i++;}- return X = e, lr(this), this.f &= -2, !0;-}, ur.prototype.S = function(e) {+ return X = e, ur(this), this.f &= -2, !0;+}, dr.prototype.S = function(e) {if (this.t === void 0) {this.f |= 36;for (var t = this.s; t !== void 0; t = t.n) t.S.S(t);}Q.prototype.S.call(this, e);-}, ur.prototype.U = function(e) {+}, dr.prototype.U = function(e) {if (this.t !== void 0 && (Q.prototype.U.call(this, e), this.t === void 0)) {this.f &= -33;for (var t = this.s; t !== void 0; t = t.n) t.S.U(t);}-}, ur.prototype.N = function() {+}, dr.prototype.N = function() {if (!(2 & this.f)) {this.f |= 6;for (var e = this.t; e !== void 0; e = e.x) e.t.N();}-}, Object.defineProperty(ur.prototype, "value", { get: function() {+}, Object.defineProperty(dr.prototype, "value", { get: function() {if (1 & this.f) throw Error("Cycle detected");- var e = ar(this);+ var e = or(this);if (this.h(), e !== void 0 && (e.i = this.i), 16 & this.f) throw this.v;return this.v;} });-function dr(e, t) {- return new ur(e, t);+function fr(e, t) {+ return new dr(e, t);}-function fr(e) {+function pr(e) {var t = e.m;if (e.m = void 0, typeof t == "function") {Z++;@@ -3196,24 +3302,24 @@ function fr(e) {try {t();} catch (t) {- throw e.f &= -2, e.f |= 8, pr(e), t;+ throw e.f &= -2, e.f |= 8, mr(e), t;} finally {- X = n, Yn();+ X = n, Xn();}}}-function pr(e) {+function mr(e) {for (var t = e.s; t !== void 0; t = t.n) t.S.U(t);- e.x = void 0, e.s = void 0, fr(e);+ e.x = void 0, e.s = void 0, pr(e);}-function mr(e) {+function hr(e) {if (X !== this) throw Error("Out-of-order effect");- lr(this), X = e, this.f &= -2, 8 & this.f && pr(this), Yn();+ ur(this), X = e, this.f &= -2, 8 & this.f && mr(this), Xn();}-function hr(e, t) {- this.x = e, this.m = void 0, this.s = void 0, this.u = void 0, this.f = 32, this.name = t?.name, Zn && Zn.push(this);+function gr(e, t) {+ this.x = e, this.m = void 0, this.s = void 0, this.u = void 0, this.f = 32, this.name = t?.name, Qn && Qn.push(this);}-hr.prototype.c = function() {+gr.prototype.c = function() {var e = this.S();try {if (8 & this.f || this.x === void 0) return;@@ -3222,20 +3328,20 @@ hr.prototype.c = function() {} finally {e();}-}, hr.prototype.S = function() {+}, gr.prototype.S = function() {if (1 & this.f) throw Error("Cycle detected");- this.f |= 1, this.f &= -9, fr(this), cr(this), Z++;+ this.f |= 1, this.f &= -9, pr(this), lr(this), Z++;var e = X;- return X = this, mr.bind(this, e);-}, hr.prototype.N = function() {- 2 & this.f || (this.f |= 2, this.u = $n, $n = this);-}, hr.prototype.d = function() {- this.f |= 8, 1 & this.f || pr(this);-}, hr.prototype.dispose = function() {+ return X = this, hr.bind(this, e);+}, gr.prototype.N = function() {+ 2 & this.f || (this.f |= 2, this.u = er, er = this);+}, gr.prototype.d = function() {+ this.f |= 8, 1 & this.f || mr(this);+}, gr.prototype.dispose = function() {this.d();};-function gr(e, t) {- var n = new hr(e, t);+function _r(e, t) {+ var n = new gr(e, t);try {n.c();} catch (e) {@@ -3246,35 +3352,35 @@ function gr(e, t) {}//#endregion//#region node_modules/@preact/signals/dist/signals.module.js-var _r, vr, yr = typeof window < "u" && !!window.__PREACT_SIGNALS_DEVTOOLS__, br = [];-gr(function() {- _r = this.N;+var vr, yr, br = typeof window < "u" && !!window.__PREACT_SIGNALS_DEVTOOLS__, xr = [];+_r(function() {+ vr = this.N;})();-function xr(e, t) {+function Sr(e, t) {S[e] = t.bind(null, S[e] || function() {});}-function Sr(e) {- if (vr) {- var t = vr;- vr = void 0, t();+function Cr(e) {+ if (yr) {+ var t = yr;+ yr = void 0, t();}- vr = e && e.S();+ yr = e && e.S();}-function Cr(e) {- var t = this, n = e.data, r = Tr(n);+function wr(e) {+ var t = this, n = e.data, r = Er(n);r.name = "ReactiveDom", r.value = n;var i = Qe(function() {for (var e = t, n = t.__v; n = n.__;) if (n.__c) {n.__c.__$f |= 4;break;}- var i = dr(function() {+ var i = fr(function() {var e = r.value.value;return e === 0 ? 0 : !0 === e ? "" : e || "";- }), a = dr(function() {+ }), a = fr(function() {return !Array.isArray(i.value) && !w(i.value);- }), o = gr(function() {- if (this.N = Or, a.value) {+ }), o = _r(function() {+ if (this.N = kr, a.value) {var t = i.value;e.__v && e.__v.__e && e.__v.__e.nodeType === 3 && (e.__v.__e.data = t);}@@ -3285,14 +3391,14 @@ function Cr(e) {}, []), a = i[0], o = i[1];return a.value ? o.peek() : o.value;}-Cr.displayName = "ReactiveTextNode", Object.defineProperties(Q.prototype, {+wr.displayName = "ReactiveTextNode", Object.defineProperties(Q.prototype, {constructor: {configurable: !0,value: void 0},type: {configurable: !0,- value: Cr+ value: wr},props: {configurable: !0,@@ -3307,7 +3413,7 @@ Cr.displayName = "ReactiveTextNode", Object.defineProperties(Q.prototype, {configurable: !0,value: 1}-}), xr("__b", function(e, t) {+}), Sr("__b", function(e, t) {if (typeof t.type == "string") {var n, r = t.props;for (var i in r) if (i !== "children") {@@ -3316,26 +3422,26 @@ Cr.displayName = "ReactiveTextNode", Object.defineProperties(Q.prototype, {}}e(t);-}), xr("__r", function(e, t) {+}), Sr("__r", function(e, t) {if (e(t), t.type !== L) {- Sr();+ Cr();var n, r = t.__c;r && (r.__$f &= -2, (n = r.__$u) === void 0 && (r.__$u = n = function(e, t) {var n;- return gr(function() {+ return _r(function() {n = this;}, { name: t }), n.c = e, n;}(function(e) {return function() {var t;- yr && ((t = this.y) == null || t.call(this)), e.__$f |= 1, e.setState({});+ br && ((t = this.y) == null || t.call(this)), e.__$f |= 1, e.setState({});};- }(r), typeof t.type == "function" ? t.type.displayName || t.type.name : ""))), Sr(n);+ }(r), typeof t.type == "function" ? t.type.displayName || t.type.name : ""))), Cr(n);}-}), xr("__e", function(e, t, n, r) {- Sr(), e(t, n, r);-}), xr("diffed", function(e, t) {- Sr();+}), Sr("__e", function(e, t, n, r) {+ Cr(), e(t, n, r);+}), Sr("diffed", function(e, t) {+ Cr();var n;if (typeof t.type == "string" && (n = t.__e)) {var r = t.__np, i = t.props, a = n.U;@@ -3345,25 +3451,25 @@ Cr.displayName = "ReactiveTextNode", Object.defineProperties(Q.prototype, {}if (r) for (var c in a || (a = {}, n.U = a), r) {var l = a[c], u = r[c];- l === void 0 ? (l = wr(n, c, u, i), a[c] = l) : l.o(u, i);+ l === void 0 ? (l = Tr(n, c, u, i), a[c] = l) : l.o(u, i);}}e(t);});-function wr(e, t, n, r) {- var i = t in e && e.ownerSVGElement === void 0, a = or(n);+function Tr(e, t, n, r) {+ var i = t in e && e.ownerSVGElement === void 0, a = sr(n);return {o: function(e, t) {a.value = e, r = t;},- d: gr(function() {- this.N = Or;+ d: _r(function() {+ this.N = kr;var n = a.value.value;r[t] !== n && (r[t] = n, i ? e[t] = n : n != null && (!1 !== n || t[4] === "-") ? e.setAttribute(t, n) : e.removeAttribute(t));})};}-xr("unmount", function(e, t) {+Sr("unmount", function(e, t) {if (typeof t.type == "string") {var n = t.__e;if (n) {@@ -3387,7 +3493,7 @@ xr("unmount", function(e, t) {}}e(t);-}), xr("__h", function(e, t, n, r) {+}), Sr("__h", function(e, t, n, r) {r < 3 && (t.__$f |= 2), e(t, n, r);}), se.prototype.shouldComponentUpdate = function(e, t) {if (this.__R) return !0;@@ -3401,44 +3507,44 @@ xr("unmount", function(e, t) {for (var s in this.props) if (!(s in e)) return !0;return !1;};-function Tr(e, t) {+function Er(e, t) {return Qe(function() {- return or(e, t);+ return sr(e, t);}, []);}-var Er = function(e) {+var Dr = function(e) {queueMicrotask(function() {queueMicrotask(e);});};-function Dr() {- Xn(function() {- for (var e; e = br.shift();) _r.call(e);+function Or() {+ Zn(function() {+ for (var e; e = xr.shift();) vr.call(e);});}-function Or() {- br.push(this) === 1 && (S.requestAnimationFrame || Er)(Dr);+function kr() {+ xr.push(this) === 1 && (S.requestAnimationFrame || Dr)(Or);}//#endregion//#region src/state/quality-goals.ts-var kr = "/api/quality-goals?limit=200", Ar = {+var Ar = "/api/quality-goals?limit=200", jr = {data: null,error: ""-}, jr = or(Ar), Mr = 0, Nr = dr(() => jr.value);-dr(() => jr.value.data?.total ?? null);-function Pr() {- Mr += 1, jr.value = Ar;+}, Mr = sr(jr), Nr = 0, Pr = fr(() => Mr.value);+fr(() => Mr.value.data?.total ?? null);+function Fr() {+ Nr += 1, Mr.value = jr;}-async function Fr(e) {- let t = Mr += 1;+async function Ir(e) {+ let t = Nr += 1;try {- let n = await K(kr, e);- return t === Mr && (jr.value = {+ let n = await K(Ar, e);+ return t === Nr && (Mr.value = {data: n,error: ""}), n;} catch (n) {- throw !e?.aborted && t === Mr && (jr.value = {+ throw !e?.aborted && t === Nr && (Mr.value = {data: null,error: G(n)}), n;@@ -3446,9 +3552,9 @@ async function Fr(e) {}//#endregion//#region src/islands/quality-goals.tsx-var Ir = (e, t) => Fr(t), Lr = (e) => e.has_cover ? `/cover?code=${encodeURIComponent(e.code ?? "")}` : `/poster?id=${e.id}&c=4`;-function Rr({ openItem: t, javTitleHtml: n, javDisplayName: a, srcBadge: o }) {- let { data: s, error: c } = Nr.value;+var Lr = (e, t) => Ir(t), Rr = (e) => e.has_cover ? `/cover?code=${encodeURIComponent(e.code ?? "")}` : `/poster?id=${e.id}&c=4`;+function zr({ openItem: t, javTitleHtml: n, javDisplayName: a, srcBadge: o }) {+ let { data: s, error: c } = Pr.value;if (c) return /* @__PURE__ */ J("div", {class: "qualitylist",dangerouslySetInnerHTML: { __html: p(c, {@@ -3467,7 +3573,7 @@ function Rr({ openItem: t, javTitleHtml: n, javDisplayName: a, srcBadge: o }) {"aria-label": `打开 ${a(s)}`,onClick: () => t(s.id),children: /* @__PURE__ */ J("img", {- src: Lr(s),+ src: Rr(s),alt: "",loading: "lazy",onError: (e) => e.currentTarget.remove()@@ -3501,8 +3607,8 @@ function Rr({ openItem: t, javTitleHtml: n, javDisplayName: a, srcBadge: o }) {}//#endregion//#region src/islands/scraping.tsx-var zr = (e, t) => K("/api/scraping", t);-function Br({ value: e, onChange: t }) {+var Br = (e, t) => K("/api/scraping", t);+function Vr({ value: e, onChange: t }) {let n = W(null), r = W(t);return r.current = t, U(() => {let t = n.current;@@ -3516,7 +3622,7 @@ function Br({ value: e, onChange: t }) {class: "scraping-network"});}-function Vr({ source: e, toast: t }) {+function Hr({ source: e, toast: t }) {let [r, i] = V(e), [a, o] = V(e.network), [s, c] = V(""), [l, u] = V(""), [f, m] = V("paste"), [h, g] = V(""), [_, y] = V(!1), [b, x] = V(""), [S, C] = V([]), w = W(null), T = W(null);U(() => {T.current?.querySelectorAll("footer button").forEach((e) => v(e, _));@@ -3587,7 +3693,7 @@ function Vr({ source: e, toast: t }) {}),/* @__PURE__ */ J("div", {class: "scraping-label",- children: ["连接方式", /* @__PURE__ */ J(Br, {+ children: ["连接方式", /* @__PURE__ */ J(Vr, {value: a,onChange: o})]@@ -3698,7 +3804,7 @@ function Vr({ source: e, toast: t }) {})});}-function Hr({ data: e, error: t, toast: n }) {+function Ur({ data: e, error: t, toast: n }) {let [r, i] = V(""), [a, o] = V(!1), [s, c] = V(""), l = W(null);U(() => v(l.current, a), [a]);let u = W(new AbortController()), f = W(0);@@ -3765,7 +3871,7 @@ function Hr({ data: e, error: t, toast: n }) {]})}),- e?.sources.map((e) => /* @__PURE__ */ J(Vr, {+ e?.sources.map((e) => /* @__PURE__ */ J(Hr, {source: e,toast: n}, e.source))@@ -3774,12 +3880,12 @@ function Hr({ data: e, error: t, toast: n }) {}//#endregion//#region src/state/index.ts-var Ur = { "quality-goals": {- refresh: Fr,- reset: Pr-} }, Wr = () => Object.keys(Ur);-async function Gr(e) {- let t = Ur[e];+var Wr = { "quality-goals": {+ refresh: Ir,+ reset: Fr+} }, Gr = () => Object.keys(Wr);+async function Kr(e) {+ let t = Wr[e];if (!t) throw Error(`未登记的共享 store:${String(e)}`);try {return await t.refresh(), !0;@@ -3789,24 +3895,24 @@ async function Gr(e) {}//#endregion//#region src/review-evidence.ts-var Kr = (e = "") => /^https?:\/\//i.test(e) ? e : "";-function qr(e = "") {- let n = Kr(e) || (e.startsWith("/") && !e.startsWith("//") ? e : "");+var qr = (e = "") => /^https?:\/\//i.test(e) ? e : "";+function Jr(e = "") {+ let n = qr(e) || (e.startsWith("/") && !e.startsWith("//") ? e : "");return `<div class="reviewimage" data-review-picture><span class="reviewimageempty"${n ? " hidden" : ""}>未取得来源图片</span>${n ? `<img src="${t(n)}" alt="来源候选图片" loading="lazy">` : ""}</div>`;}-function Jr(e) {- let n = Kr(e.profile_url), r = (e.preview_assets || []).slice(0, 6), i = Math.max(0, Number(e.video_count || e.videos || 0));+function Yr(e) {+ let n = qr(e.profile_url), r = (e.preview_assets || []).slice(0, 6), i = Math.max(0, Number(e.video_count || e.videos || 0));return `<section class="reviewidentityevidence"><h5>候选身份:${t(e.babepedia_name || "未标注")}</h5><div class="reviewevidenceactions">${n ? `<a class="geist-button externallink" href="${t(n)}" target="_blank" rel="noopener noreferrer">来源资料<svg class="externalmark" viewBox="0 0 24 24" aria-hidden="true"><use href="#i-external-link" /></svg></a>` : ""}<button type="button" class="geist-button" data-entity-kind="creator" data-entity-name="${t(e.creator || "")}">查看全部 ${i.toLocaleString()} 部作品</button></div>- ${qr(e.preview_url)}+ ${Jr(e.preview_url)}<p>通过后记录身份判断。</p>${r.length ? `<h5>本地作品样本</h5><div class="reviewevidencesamples">${r.map((e) => `<div class="reviewevidencesample"><button class="geist-button" type="button" data-review-open-item="${e.id}"><span data-middle-truncate title="${t(e.name)}">${t(e.name)}</span></button><button class="geist-button" type="button" data-review-reveal="${e.id}" aria-label="打开 ${t(e.name)} 的文件位置">文件位置</button></div>`).join("")}</div>` : "<p>暂无本地作品样本,打开全部作品核对。</p>"}</section>`;}-function Yr(e) {+function Xr(e) {for (let t of e.querySelectorAll("[data-review-picture] img")) {let e = () => {t.hidden = !0;@@ -3818,7 +3924,7 @@ function Yr(e) {}//#endregion//#region src/review-bulk.ts-var Xr = () => ({+var Zr = () => ({busy: !1,category: "",filter: "",@@ -3829,7 +3935,7 @@ var Xr = () => ({assets: /* @__PURE__ */ new Map(),errors: /* @__PURE__ */ new Map()});-function Zr(e) {+function Qr(e) {let t = e?.querySelector(".reviewbulktoolbar");if (!e || !t || t.offsetParent === null) return;e.style.setProperty("--review-controls-height", `${t.getBoundingClientRect().height}px`);@@ -3843,7 +3949,7 @@ function Zr(e) {let i = r[0].getBoundingClientRect(), a = r[r.length - 1].getBoundingClientRect();e.style.setProperty("--review-pane-left", `${i.left}px`), e.style.setProperty("--review-pane-width", `${i.width}px`), e.style.setProperty("--review-pane-height", `${a.bottom - i.top}px`);}-function Qr(e, t) {+function $r(e, t) {let n = [["candidates",t ? "按候选数量" : "全部待复核",@@ -3859,7 +3965,7 @@ function Qr(e, t) {"list-filter"]), n;}-function $r(e, t) {+function ei(e, t) {let n = /* @__PURE__ */ new Map();for (let r of e) {let e, i;@@ -3876,11 +3982,11 @@ function $r(e, t) {}return [...n.values()];}-function ei(e, t, n, r, i) {+function ti(e, t, n, r, i) {let a = e.anchor === null ? -1 : t.indexOf(e.anchor), o = t.indexOf(n);r && a >= 0 && o >= 0 ? t.slice(Math.min(a, o), Math.max(a, o) + 1).forEach((t) => e.selected.add(t)) : i ? e.selected.add(n) : e.selected.delete(n), e.anchor = n;}-async function ti(e, t, n, r) {+async function ni(e, t, n, r) {let i = [], a = 0;for (let o of e) {if (!r()) break;@@ -3900,17 +4006,17 @@ async function ti(e, t, n, r) {failures: i};}-function ni(e) {+function ri(e) {return e.length ? [...new Set(e.flatMap((e) => e.candidates?.map((e) => e.source || "") || []))].filter((t) => t && e.every((e) => e.candidates?.filter((e) => e.source === t).length === 1)) : [];}-function ri(e, t) {+function ii(e, t) {let n = e.querySelector(".reviewlist");if (!n || !t.rows.length || t.locked) return;let r = t.state, i = [...n.querySelectorAll("[data-review-key]")];t.category !== void 0 && r.category !== t.category && (r.category = t.category, r.filter = "", r.groupBy = "candidates", r.anchor = null);- let a = t.catalog || t.rows, o = Qr(a, t.metadata);+ let a = t.catalog || t.rows, o = $r(a, t.metadata);o.some((e) => e[0] === r.groupBy) || (r.groupBy = "candidates", r.filter = "");- let s = $r(a, r.groupBy);+ let s = ei(a, r.groupBy);s.some((e) => e.key === r.filter) || (r.filter = "");let l = () => [...n.querySelectorAll("[data-review-key]")].filter((e) => !e.closest("[hidden]")), u = () => l().filter((e) => r.selected.has(e.dataset.reviewKey)), d = () => t.rows.filter((e) => u().some((t) => t.dataset.reviewKey === e.item_key)), f = (e) => !e.querySelector("[data-review-status=\"approved\"]")?.disabled, p = (e, t = "") => {let n = document.createElement("button");@@ -4004,7 +4110,7 @@ function ri(e, t) {e.className = "reviewpickname", e.append(...n.childNodes), n.classList.add("reviewpickheading"), n.append(i, e);} else e.prepend(i);let o = (e, n) => {- ei(r, l().map((e) => e.dataset.reviewKey), t, e, n), P();+ ti(r, l().map((e) => e.dataset.reviewKey), t, e, n), P();};if (i.addEventListener("mousedown", (e) => {e.shiftKey && e.preventDefault();@@ -4018,7 +4124,7 @@ function ri(e, t) {else if (n.key === "ArrowDown" || n.key === "ArrowUp") {n.preventDefault();let i = l(), a = i[i.indexOf(e) + (n.key === "ArrowDown" ? 1 : -1)];- a && (r.anchor === null && (r.anchor = t), ei(r, i.map((e) => e.dataset.reviewKey), a.dataset.reviewKey, !0, !0), P(), a.querySelector(".reviewpickitem input")?.focus());+ a && (r.anchor === null && (r.anchor = t), ti(r, i.map((e) => e.dataset.reviewKey), a.dataset.reviewKey, !0, !0), P(), a.querySelector(".reviewpickitem input")?.focus());}}}), N.push(() => {@@ -4047,14 +4153,14 @@ function ri(e, t) {function P() {let e = u();C.textContent = e.length === l().length ? "清空当前选择" : r.filter ? "全选当前分类" : "全选本页", A.hidden = !e.length, E.textContent = `已选 ${e.length} 项`, w.disabled = !e.length || e.some((e) => !f(e)), T.disabled = !e.length;- let n = ni(d());+ let n = ri(d());D.hidden = !t.metadata || !d().some((e) => (e.candidates?.length || 0) > 1);let i = e.length && !n.length ? "所选项目无共同来源" : "统一选择来源", a = JSON.stringify([i, n]);if (a !== te) {te = a, D.innerHTML = g([["", i], ...n.map((e) => [e, e])], "", { label: "统一选择来源" });let e = b(D.firstElementChild);e.disabled = !n.length, e.addEventListener("change", () => {- if (!(r.busy || !ni(d()).includes(e.value))) {+ if (!(r.busy || !ri(d()).includes(e.value))) {for (let n of u()) {let i = t.rows.find((e) => e.item_key === n.dataset.reviewKey).candidates.find((t) => t.source === e.value);n.querySelectorAll("input[type=\"radio\"]").forEach((e) => {@@ -4087,7 +4193,7 @@ function ri(e, t) {e instanceof KeyboardEvent && e.key === "Tab" || (e.preventDefault(), e.stopImmediatePropagation());};e.addEventListener("click", c, !0), e.addEventListener("keydown", c, !0);- let l = 0, d = await ti(a, async (e) => {+ let l = 0, d = await ni(a, async (e) => {try {return await t.submit(e);} finally {@@ -4104,9 +4210,9 @@ function ri(e, t) {let f = e.parentElement;t.refresh(), f?.querySelector(".reviewbulktoolbar button")?.focus({ preventScroll: !0 });}- P(), Zr(e);+ P(), Qr(e);}-function ii(e, t, n = 1) {+function ai(e, t, n = 1) {let r = (e, t) => Array.from({ length: t - e + 1 }, (t, n) => e + n);if (n * 2 + 5 >= t) return r(1, t);let i = Math.max(e - n, 1), a = Math.min(e + n, t), o = i > 2, s = a < t - 2;@@ -4126,15 +4232,15 @@ function ii(e, t, n = 1) {t];}-function ai(e, t) {+function oi(e, t) {return Math.max(1, Math.ceil(e / t));}-function oi(e, t) {+function si(e, t) {return Math.min(Math.max(1, Math.floor(e) || 1), t);}-function si(e, t, n) {+function ci(e, t, n) {if (t <= 1) return "";- let r = ii(e, t).map((t) => t === "…" ? "<li class=\"board-page-dots\" aria-hidden=\"true\">…</li>" : `<li><button type="button" class="board-page" data-page="${t}" aria-label="第 ${t} 页"${t === e ? " aria-current=\"page\"" : ""}>${t}</button></li>`).join("");+ let r = ai(e, t).map((t) => t === "…" ? "<li class=\"board-page-dots\" aria-hidden=\"true\">…</li>" : `<li><button type="button" class="board-page" data-page="${t}" aria-label="第 ${t} 页"${t === e ? " aria-current=\"page\"" : ""}>${t}</button></li>`).join("");return `<nav class="board-pagination" aria-label="${n}"><button type="button" class="geist-button" data-page="${e - 1}"${e <= 1 ? " disabled" : ""}><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-chevron-left"></use></svg>上一页</button><ul>${r}</ul>@@ -4143,10 +4249,10 @@ function si(e, t, n) {}//#endregion//#region src/native-image.ts-function ci(e, t, n, r) {+function li(e, t, n, r) {return e > 0 && t > 0 && e === n && t === r;}-function li(e, t, n, r, i = 1) {+function ui(e, t, n, r, i = 1) {let a = Number.isFinite(i) && i > 0 ? i : 1;e /= a, t /= a;let o = [@@ -4163,7 +4269,7 @@ function li(e, t, n, r, i = 1) {}//#endregion//#region src/entity-skeleton.ts-function ui(e, t) {+function di(e, t) {return `<section data-skeleton="entity/${e}" role="status" aria-label="正在读取资料"><span class="sr-only">正在读取资料</span><div aria-hidden="true"><div class="entityhero"><div class="entityportrait ${e === "studio" || e === "agency" ? "square " : ""}skeleton"></div>@@ -4175,7 +4281,7 @@ function ui(e, t) {}//#endregion//#region src/board-skeleton.ts-function di(e) {+function fi(e) {let t = (e = "60%") => `<i class="skeleton" style="width:${e}"></i>`, n = () => `<div class="board-skeleton-row">${t("36%")}${t("24%")}</div>`, r = "";if (e === "/stats" || e === "/taste") r = `${e === "/taste" ? `<div class="board-skeleton-row">${t("26%")}${t("32%")}</div>` : ""}<div class="metricstrip board-skeleton-metrics">${Array.from({ length: 4 }, () => `<div class="tastesummary">${t()}<b class="skeleton"></b><small class="board-stat-footer">${t("48%")}</small></div>`).join("")}</div><div class="board-skeleton-chart"><div class="board-skeleton-ring skeleton"></div><div>${n().repeat(4)}</div></div><div class="board-skeleton-section">${t("32%")}${n().repeat(5)}</div>`;else if (e === "/follow-manage") r = `<div class="board-skeleton-section">${t("20%")}<div class="skeleton board-skeleton-input"></div>${t("72%")}</div><div class="board-skeleton-row">${t("24%")}${t("40%")}</div><div class="board-skeleton-section">${n().repeat(6)}</div><div class="board-skeleton-row">${t("30%")}${t("30%")}</div>`;@@ -4185,7 +4291,7 @@ function di(e) {}//#endregion//#region src/catalog-onboarding.ts-var fi = [+var pi = ["loc","creator","performer",@@ -4202,16 +4308,16 @@ var fi = ["jav","thumb"];-function pi() {+function mi() {let e = (e) => Array(64).fill(e).join("");return {tiers: "<div class=\"tier catalog-placeholder\" aria-hidden=\"true\">" + e("<span class=\"av\"><span class=\"ring\"></span><span class=\"nm\"> </span></span>") + "</div><div class=\"tier catalog-placeholder\" aria-hidden=\"true\">" + e("<span class=\"brandpill\"><span class=\"mk\"></span><span class=\"placeholder-name\"> </span></span>") + "</div>",tags: "<span class=\"catalog-placeholder placeholder-tags\" aria-hidden=\"true\">" + e("<span class=\"pill\"> </span>") + "</span>"};}-async function mi(e, t) {+async function hi(e, t) {let n = new URLSearchParams();- for (let t of fi) e[t] && n.set(t, e[t]);+ for (let t of pi) e[t] && n.set(t, e[t]);let [r, i] = await Promise.all([t("/api/facets?" + n), t("/api/items?" + n + "&limit=5")]), a = [...new Set([...r.creators || [],...r.tagperformers || [],@@ -4222,7 +4328,7 @@ async function mi(e, t) {return r.set("q", e), r.set("limit", "1"), (await t("/api/items?" + r)).total > 0 ? e : "";}))).filter(Boolean);}-function hi({ kind: e = "catalog", filtered: t = !1, jav: n = !1, configurable: r = !1, online: i = !1 } = {}) {+function gi({ kind: e = "catalog", filtered: t = !1, jav: n = !1, configurable: r = !1, online: i = !1 } = {}) {let a = r ? "<a class=\"geist-button primary\" href=\"/configuration\">添加内容</a>" : "", o = "<a class=\"geist-button\" href=\"/follow-manage\">添加来源</a>";return t || n ? u("search", n ? "还没有符合条件的 JAV 作品" : "没有符合条件的内容", n ? "已扫描但尚未补充发行资料的视频可在全部内容中查看。" : "清除筛选或搜索条件后查看全部内容。", { actions: "<a class=\"geist-button primary\" href=\"/?loc=&thumb=0\">查看全部内容</a>" }) : e === "catalog" ? u("play", "还没有视频", "添加媒体文件夹或关注来源,开始建立你的馆藏。", { actions: a + o }) : u(e === "tags" ? "tags" : "user-round", "还没有" + ({tags: "标签",@@ -4235,7 +4341,7 @@ function hi({ kind: e = "catalog", filtered: t = !1, jav: n = !1, configurable:}//#endregion//#region src/sidebar.ts-function gi(e) {+function _i(e) {return ["/","/unseen",@@ -4245,28 +4351,28 @@ function gi(e) {"/junk-files"].includes(e) || /^\/(item|mix|parts|editions)\//.test(e) || /^\/playlists\/\d+\/\d+$/.test(e) || /^\/(performers|studios|creators|series|agencies)\/.+/.test(e);}-function _i(e, t) {+function vi(e, t) {return e.dataset.surface === t && e.querySelector(".dnav") ? !1 : (e.dataset.surface = t, e.replaceChildren(), !0);}-function vi(e) {+function yi(e) {let t = /* @__PURE__ */ new Map();for (let n of e) for (let e of new Set(n.tags || [])) t.set(e, (t.get(e) || 0) + 1);return [...t].sort((e, t) => t[1] - e[1]).slice(0, 30);}//#endregion//#region src/resource-sync.ts-var $ = (e = 0) => Number(e).toLocaleString(), yi = {+var $ = (e = 0) => Number(e).toLocaleString(), bi = {local: "本地磁盘",115: "115",pikpak: "PikPak"};-function bi(e, t) {+function xi(e, t) {let n = e.cache || {files: 0,bytes: 0}, r = !!(e.missing || n.files);return `<div class="resourcepanel" data-geist-fieldset><div class="resourcesources">${(e.sources || []).map((e) => `<article>- <div class="resourcesourcetitle"><b>${yi[e.location] || "媒体来源"}</b><span class="${e.online ? "online" : "offline"}">${e.online ? "可访问" : "离线,已跳过"}</span></div>+ <div class="resourcesourcetitle"><b>${bi[e.location] || "媒体来源"}</b><span class="${e.online ? "online" : "offline"}">${e.online ? "可访问" : "离线,已跳过"}</span></div><strong>${e.online ? `${$(e.missing)} 项` : "—"}</strong><small>${e.online ? `找不到文件 · 已检查 ${$(e.checked)} 项` : `馆藏中有 ${$(e.total)} 项`}</small>${e.unreadable ? `<small>${$(e.unreadable)} 项读取失败,已跳过</small>` : ""}</article>`).join("")}</div>@@ -4277,60 +4383,60 @@ function bi(e, t) {}//#endregion//#region src/jav-artwork.ts-function xi(e) {+function Si(e) {return ["small","sleeve","preview"].includes(String(e)) ? "small" : "big";}-function Si(e) {+function Ci(e) {return {- javLayout: xi(e.javLayout),- javImage: Ci(e.javLayout === "preview" ? "thumbnail" : e.javImage)+ javLayout: Si(e.javLayout),+ javImage: wi(e.javLayout === "preview" ? "thumbnail" : e.javImage)};}-function Ci(e) {+function wi(e) {return e === "thumbnail" ? "thumbnail" : "cover";}-function wi(e, t) {- return e.is_jav && e.code && e.has_cover && (Ci(t) === "cover" || !e.has_thumb) ? "cover" : e.has_thumb ? "thumbnail" : "";-}function Ti(e, t) {+ return e.is_jav && e.code && e.has_cover && (wi(t) === "cover" || !e.has_thumb) ? "cover" : e.has_thumb ? "thumbnail" : "";+}+function Ei(e, t) {e.querySelectorAll("img[data-jav-image]").forEach((e) => {- let n = e.dataset.javCover || "", r = e.dataset.javThumb || "", i = !!(n && (Ci(t) === "cover" || !r)), a = i ? n : r;+ let n = e.dataset.javCover || "", r = e.dataset.javThumb || "", i = !!(n && (wi(t) === "cover" || !r)), a = i ? n : r;e.classList.toggle("cover", i), e.classList.toggle("whole", i && e.dataset.javImageLayout !== "big"), e.classList.toggle("front", i && e.dataset.javImageLayout === "big"), e.removeAttribute("style"), a && e.getAttribute("src") !== a && (e.src = a);});}//#endregion//#region src/islands.ts-var Ei = {+var Di = {"library-processing": {load: dt,component: ft},scraping: {- load: zr,- component: Hr+ load: Br,+ component: Ur},"quality-goals": {- load: Ir,- component: Rr+ load: Lr,+ component: zr},configuration: {- load: Bn,- component: qn+ load: Vn,+ component: Jn}-}, Di = () => Object.keys(Ei), Oi = /* @__PURE__ */ new Map();-async function ki(e, t, n, r = {}) {- let i = Ei[e];+}, Oi = () => Object.keys(Di), ki = /* @__PURE__ */ new Map();+async function Ai(e, t, n, r = {}) {+ let i = Di[e];if (!i) throw Error(`未注册的 island:${String(e)}`);- Ai(t);+ ji(t);let a = {controller: new AbortController(),painted: !1};- Oi.set(t, a);+ ki.set(t, a);let o;try {o = {@@ -4344,9 +4450,9 @@ async function ki(e, t, n, r = {}) {error: G(e)};}- if (Oi.get(t) !== a) return;+ if (ki.get(t) !== a) return;if (r.isCurrent && !r.isCurrent()) {- Oi.delete(t);+ ki.delete(t);return;}t.textContent = "", a.painted = !0;@@ -4356,9 +4462,9 @@ async function ki(e, t, n, r = {}) {};Oe(ae(i.component, s), t);}-function Ai(e) {- let t = Oi.get(e);- t && (t.controller.abort(), Oi.delete(e), t.painted && Oe(null, e));+function ji(e) {+ let t = ki.get(e);+ t && (t.controller.abort(), ki.delete(e), t.painted && Oe(null, e));}//#endregion-export { _t as TASTE_GUIDE_KEY, hn as activityChartsHtml, di as boardPageSkeleton, je as boundedPreference, hi as catalogEmptyHtml, mi as catalogSuggestions, oi as clampPage, ht as cleanupSkeletonHtml, pt as cloudLocations, mt as cloudPreferenceLocations, Xr as createReviewSelection, ln as creatorSankeyHtml, Ie as distributionChart, pi as emptyCatalogLayout, ui as entitySkeletonHtml, lt as followJobProgress, $r as groupReviewRows, Jr as identityEvidenceHtml, Ct as initBoardControls, Di as islandNames, wi as javImageKind, Fe as jobProgressHtml, ci as matchesFaceSource, xt as mountBoardStatePreview, ki as mountIsland, Ne as mountNumberSetting, li as nativeImageFit, Ci as normalizeJavImage, xi as normalizeJavLayout, Si as normalizeJavPreferences, ai as pageCount, si as paginationHtml, ke as preferredDirection, Re as radarChart, fn as radialCardHtml, Le as rankedChart, Gr as refreshStore, bi as resourceScanHtml, qr as reviewImageHtml, gi as sidebarHasCatalogContent, vn as sidebarSectionHtml, vi as sidebarTagCounts, Pe as statCardBody, Wr as storeNames, St as syncBoardRange, Ti as syncJavImages, Me as syncNumberSetting, _i as syncSidebarSurface, gt as tasteHistoryGuideHtml, xn as transitionTheme, Ai as unmountIsland, Zr as updateReviewSticky, ct as watchJob, gn as wireActivityCharts, un as wireCreatorSankey, Ot as wireExpandableRanks, Dt as wireGrowingCharts, pn as wireRadialCards, Yr as wireReviewPictures, ri as wireReviewSelection, yn as wireSidebarGroups, vt as wireTasteHistoryGuide };+export { _t as TASTE_GUIDE_KEY, hn as activityChartsHtml, fi as boardPageSkeleton, je as boundedPreference, gi as catalogEmptyHtml, hi as catalogSuggestions, si as clampPage, ht as cleanupSkeletonHtml, pt as cloudLocations, mt as cloudPreferenceLocations, Zr as createReviewSelection, ln as creatorSankeyHtml, Ie as distributionChart, mi as emptyCatalogLayout, di as entitySkeletonHtml, lt as followJobProgress, ei as groupReviewRows, Yr as identityEvidenceHtml, Ct as initBoardControls, Oi as islandNames, Ti as javImageKind, Fe as jobProgressHtml, li as matchesFaceSource, xt as mountBoardStatePreview, Ai as mountIsland, Ne as mountNumberSetting, ui as nativeImageFit, wi as normalizeJavImage, Si as normalizeJavLayout, Ci as normalizeJavPreferences, oi as pageCount, ci as paginationHtml, ke as preferredDirection, Re as radarChart, fn as radialCardHtml, Le as rankedChart, Kr as refreshStore, xi as resourceScanHtml, Jr as reviewImageHtml, _i as sidebarHasCatalogContent, vn as sidebarSectionHtml, yi as sidebarTagCounts, Pe as statCardBody, Gr as storeNames, St as syncBoardRange, Ei as syncJavImages, Me as syncNumberSetting, vi as syncSidebarSurface, gt as tasteHistoryGuideHtml, xn as transitionTheme, ji as unmountIsland, Qr as updateReviewSticky, ct as watchJob, gn as wireActivityCharts, un as wireCreatorSankey, Ot as wireExpandableRanks, Dt as wireGrowingCharts, pn as wireRadialCards, Xr as wireReviewPictures, ii as wireReviewSelection, yn as wireSidebarGroups, vt as wireTasteHistoryGuide };