Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

feat(library): 统一扫描采集并导入已有 NFO 资料

longmeidao4dc5c8d45074
diff --git a/README.en.md b/README.en.md
index ddfb7376e..5c9f29a6d 100644
--- a/README.en.md
+++ b/README.en.md
@@ -41,6 +41,8 @@ First-run setup offers an optional browser-history import guide. Completed impor
Tray-managed services let you adjust media sources under Manage → Configuration on the host computer, including through its LAN hostname. Setup and configuration provide download links when dependencies are not detected, with mount drivers shown for the host operating system.
+In Data Management, Scan and enrich scans folders, detects existing NFO files and local posters, and fetches missing metadata. Same-name NFO files, `movie.nfo` in single-movie folders, and episode NFO files are supported. Metadata retains its original source and enters the review queue before updating the catalog. Local custom tags are preserved; folders containing multiple videos do not share `movie.nfo`.
+
Follow sources include FANBOX, Patreon, SubscribeStar, Kemono, Pawchive, Coomer, the Rule34 family and F95zone. Availability depends on the site and your access rights. See [source collection](docs/SOURCING.md) for supported workflows and boundaries.
## Quick start
diff --git a/README.md b/README.md
index f34992701..79f52504a 100644
--- a/README.md
+++ b/README.md
@@ -37,6 +37,8 @@ CloudDrive · 115 与 CloudDrive · PikPak 按本机文件夹接入;先在 Clo
托盘管理的服务可在本机通过「管理 → 配置」调整媒体来源;使用局域网域名打开也能进入。首启页和配置页检测缺失依赖时提供下载链接,挂载驱动提示按操作系统显示。
+在「数据管理」点击「扫描并补全资料」,可统一扫描文件夹、识别已有 NFO 和本地海报,并采集缺失资料。支持同名 NFO、单影片目录的 `movie.nfo` 和单集 NFO;资料保留原始出处,在「复核资料」确认后写入馆藏。已有本地标签会保留,目录中有多部影片时不会共用 `movie.nfo`。
+
首次设置可选择进入浏览器历史记录导入指南;完成导入后指南隐藏,点击「跳过」会在当前浏览器记住选择,折叠仍保留指南。需要补充记录时使用「口味」页的读取或导入按钮。设置中的「SFW 模式」会模糊、降低饱和度并压暗图片和视频,停止悬停预览,文字保持可见。数据管理中的「网盘与本地数据库」仅在配置网盘后显示;空文件夹清理也支持本地磁盘。
关注来源包括 FANBOX、Patreon、SubscribeStar,以及 Kemono、Pawchive、Coomer、Rule34 系列与 F95zone。来源可用性受站点和使用者权限限制;采集边界与支持情况见 [来源采集](docs/SOURCING.md)。
diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md
index 514e31199..052fe860f 100644
--- a/docs/HANDOFF.md
+++ b/docs/HANDOFF.md
@@ -4,7 +4,7 @@
## 界面、媒体与复核的既定判据
-- 后台任务、进度容器与断线恢复见 `docs/REUSE.md`。
+- 后台任务、断线恢复与 NFO 边车兼容范围见 `docs/REUSE.md`。
页面密度、控件、提示与响应式的实现门槛见 `.claude/skills/peach-web-ui/SKILL.md`,这里只留代码看不出来的判据。
diff --git a/docs/REUSE.md b/docs/REUSE.md
index 3c81ce4eb..704e9e124 100644
--- a/docs/REUSE.md
+++ b/docs/REUSE.md
@@ -235,6 +235,8 @@ Python、npm 与 GitHub Actions 的版本由 `.github/dependabot.yml` 每周检
## 当前替换队列
+本地库导入复用 Kodi/Jellyfin NFO 协议(2026-09-06 核对 [Kodi](https://kodi.wiki/view/NFO_files/Movies)、[Jellyfin](https://jellyfin.org/docs/general/server/metadata/nfo/)),XML 解析复用 Python 3.12+ 标准库 ElementTree(PSF,无新增依赖),图片复用项目固定版 Pillow。只适配影片、单集与音乐视频的字段;整剧、音乐专辑、播放记录及远端图片引用保留在原文件,不作为影片资料套用。拒绝 DTD、超大输入与越目录图片引用。同名边车优先,`movie.nfo` 和通用海报只用于单影片目录。真实 JavBoss NFO 与同番号 R18 JSON 的只读 POC 已取得:本地保留原标题、演员和自定义标签,远端能补厂牌、导演、发行商、时长和图片出处。网络复用现有 R18 JSON 入口、SourceTransport 与封面解析器;独立包无需另装 Go。Javinizer-Go 仍服务多来源离线查询,本适配不新增站点 HTML 解析器。候选按资产 ID 与路径定位,批准时复核目标;时长证据不覆盖媒体探测时长。
+
已完成:共享 Media/Job/HTTP 边界、feedparser、Pillow、Beautiful Soup、FTS5、可安全导入的批处理脚本和按任务范围终止进程。
1. Video.js 已接管详情播放;`MediaEngine.stream_plan` 已让 115/PikPak 原生 MP4 使用 HLS 临时短片段,仍需补自适应码率、多路清单和生产验收。CloudDrive 的虚拟盘固定块预取仍属于来源层成本。
diff --git a/docs/STATUS.md b/docs/STATUS.md
index cb8db4a11..cd731fca2 100644
--- a/docs/STATUS.md
+++ b/docs/STATUS.md
@@ -8,7 +8,7 @@
## 运行态
-- 测试包可本机访问,首页含无缩略图视频;mDNS 待办。
+- 测试包本机可访问,含无缩略图视频;mDNS 待办。
- JAV 封面、大小独立设置。
diff --git a/frontend/src/islands.ts b/frontend/src/islands.ts
index e80a4935c..865b1406e 100644
--- a/frontend/src/islands.ts
+++ b/frontend/src/islands.ts
@@ -23,6 +23,8 @@ import type { QualityGoalsProps } from './islands/quality-goals';
import type { QualityGoalsData } from './state/quality-goals';
import { Scraping, loadScraping } from './islands/scraping';
import type { ScrapingData, ScrapingProps } from './islands/scraping';
+import { LibraryProcessing, loadLibraryProcessing } from './islands/library-processing';
+import type { LibraryProcessingData, LibraryProcessingProps } from './islands/library-processing';
/* 跨岛共享状态的入口一起从这里出去。遗留层拿到的是一个 bundle,它有两种用法:
* `mountIsland` 挂一屏,`refreshStore` 告诉已经挂着的那屏「数据变了」。
@@ -44,6 +46,7 @@ export interface IslandState<D> {
/** 每个 island 的 props 与首屏数据类型。新增 island 时在这里登记,注册表随之要求实现。 */
export interface IslandContracts {
+ 'library-processing': { props: LibraryProcessingProps; data: LibraryProcessingData };
'scraping': { props: ScrapingProps; data: ScrapingData };
'quality-goals': { props: QualityGoalsProps; data: QualityGoalsData };
configuration: { props: ConfigurationProps; data: ConfigurationData };
@@ -60,6 +63,7 @@ interface IslandDefinition<N extends IslandName> {
}
const REGISTRY: { [N in IslandName]: IslandDefinition<N> } = {
+ 'library-processing': { load: loadLibraryProcessing, component: LibraryProcessing },
'scraping': { load: loadScraping, component: Scraping },
'quality-goals': { load: loadQualityGoals, component: QualityGoals },
configuration: { load: loadConfiguration, component: Configuration },
diff --git a/frontend/src/islands/library-processing.tsx b/frontend/src/islands/library-processing.tsx
new file mode 100644
index 000000000..75c8fb00e
--- /dev/null
+++ b/frontend/src/islands/library-processing.tsx
@@ -0,0 +1,75 @@
+import { useEffect, useLayoutEffect, useRef, useState } from 'preact/hooks';
+import { apiGet, apiSend, errorMessage } from '../api';
+import { fieldsetTitle, loadingDotsHtml, noteHtml, progressHtml, setActionBusy } from '@peach/legacy/ui';
+import { watchJob } from '../jobs';
+import type { JobState } from '../jobs';
+import type { IslandState } from '../islands';
+
+export interface LibraryProcessingData extends JobState {
+ stage?: string; scanned?: number; identified?: number; candidates?: number; covers?: number;
+ issues?: { asset_id: number | null; message: string }[];
+}
+export interface LibraryProcessingProps { toast(message: string): void; onComplete?(): void }
+export const loadLibraryProcessing = (_props: LibraryProcessingProps, signal: AbortSignal) =>
+ apiGet<LibraryProcessingData>('/api/library-processing', signal);
+
+export function LibraryProcessing({ data, error, toast, onComplete }: LibraryProcessingProps & IslandState<LibraryProcessingData>) {
+ const [state, setState] = useState<LibraryProcessingData>(data || { status: 'idle' });
+ const [problem, setProblem] = useState(error);
+ const [submitting, setSubmitting] = useState(false);
+ const [receipt, setReceipt] = useState(false);
+ const lifetime = useRef(new AbortController());
+ const generation = useRef(0);
+ const button = useRef<HTMLButtonElement>(null);
+ const busy = submitting || state.status === 'running';
+ useLayoutEffect(() => setActionBusy(button.current, busy), [busy]);
+ async function follow() {
+ const epoch = ++generation.current;
+ await watchJob<LibraryProcessingData>({
+ read: signal => apiGet('/api/library-processing', signal),
+ active: () => !lifetime.current.signal.aborted && generation.current === epoch,
+ render: next => {
+ setState(next); setProblem('');
+ if (next.status === 'complete') { setReceipt(true); toast('已完成扫描与资料采集'); }
+ if (next.status === 'complete' || next.status === 'failed') onComplete?.();
+ },
+ disconnected: () => setProblem('连接中断,正在重新读取处理进度'),
+ });
+ }
+ useEffect(() => {
+ if (state.status === 'running') void follow();
+ return () => lifetime.current.abort();
+ }, []);
+ async function start() {
+ if (busy) return;
+ setSubmitting(true); setProblem(''); setReceipt(false);
+ try {
+ const next = await apiSend<LibraryProcessingData>('/api/library-processing', {}, 'POST', lifetime.current.signal);
+ if (lifetime.current.signal.aborted) return;
+ setState(next); setSubmitting(false); await follow();
+ } catch (cause) {
+ if (!lifetime.current.signal.aborted) { setProblem(errorMessage(cause)); setSubmitting(false); }
+ }
+ }
+ return <>
+ <div class="geist-fieldset-content library-processing">
+ <div dangerouslySetInnerHTML={{ __html: fieldsetTitle('cleanupScrapingTitle', '扫描与采集') }} />
+ <p>扫描媒体文件夹,导入已有资料,采集缺失信息。</p>
+ <div aria-live="polite">
+ {state.status === 'running' && <>
+ <div dangerouslySetInnerHTML={{ __html: loadingDotsHtml(state.stage || '正在处理') }} />
+ {!!state.total && <div dangerouslySetInnerHTML={{ __html: progressHtml(`已处理 ${state.checked || 0} / ${state.total} 个视频`, state.checked || 0, state.total) }} />}
+ </>}
+ {(problem || state.status === 'failed') && <div role="alert" dangerouslySetInnerHTML={{ __html: noteHtml(problem || state.error || '处理未完成,请重试', { variant: 'error' }) }} />}
+ {state.status === 'failed' && !!state.issues?.length && <ul>{state.issues.slice(0, 20).map(issue =>
+ <li>{issue.asset_id ? <a href={`/item/${issue.asset_id}`}>查看视频</a> : null}{issue.asset_id ? ':' : ''}{issue.message}</li>)}</ul>}
+ {receipt && <p>已扫描 {state.scanned || 0} 个文件,识别 {state.identified || 0} 个番号,生成 {state.candidates || 0} 组待复核资料。</p>}
+ </div>
+ </div>
+ <footer class="geist-fieldset-footer" data-geist-fieldset-footer>
+ <a class="geist-button" href="/scraping">采集来源</a>
+ {!!state.candidates && <a class="geist-button" href="/review">复核资料</a>}
+ <button ref={button} type="button" class="geist-button primary" onClick={() => void start()}>{state.status === 'failed' ? '重试未完成项' : '扫描并补全资料'}</button>
+ </footer>
+ </>;
+}
diff --git a/frontend/src/legacy/ui.d.ts b/frontend/src/legacy/ui.d.ts
index 2dcf56ec6..4411da08e 100644
--- a/frontend/src/legacy/ui.d.ts
+++ b/frontend/src/legacy/ui.d.ts
@@ -14,6 +14,8 @@ export declare function emptyStateHtml(
/** Geist Fieldset 的标题:放在框体里的 h3,不用原生 legend。 */
export declare function fieldsetTitle(id: string, title: string): string;
+export declare function loadingDotsHtml(label?: string, options?: { className?: string }): string;
+export declare function progressHtml(label: string, value: number, max?: number): string;
export declare function selectFieldHtml(items: string[][], current: string,
options?: { label?: string; attr?: string; className?: string }): string;
diff --git a/frontend/src/management.ts b/frontend/src/management.ts
index f30c74493..90c898512 100644
--- a/frontend/src/management.ts
+++ b/frontend/src/management.ts
@@ -13,7 +13,7 @@ export function cloudPreferenceLocations(files: readonly { location: string }[],
/** 首屏复用最终 Fieldset 的排版,静态标题、说明和按钮无需等待接口。 */
export function cleanupSkeletonHtml(): string {
const cards = [
- ['采集来源', '设置采集来源', '下载高清封面,设置代理和 Cookie。'],
+ ['扫描与采集', '扫描并补全资料', '扫描媒体文件夹,导入已有资料,采集缺失信息。'],
['垃圾文件', '查看垃圾文件', ''], ['重复文件', '查看重复文件', ''],
['空文件夹', '删除空文件夹', ''], ['人工复核', '查看候选', ''],
['回收站', '查看回收站', ''], ['高清版', '查看高清版', ''],
@@ -40,7 +40,7 @@ export function tasteHistoryGuideHtml(onboarding: boolean, completed = false, sk
<ul><li>Chrome:在 <a href="https://takeout.google.com/" target="_blank" rel="noreferrer">Google Takeout${external}</a> 选择 Chrome 历史记录,下载 ZIP 后直接导入。</li>
<li>其他浏览器:使用 <a href="https://github.com/purarue/browserexport" target="_blank" rel="noreferrer">browserexport${external}</a> 导出历史记录,再导入导出文件。</li></ul>
<p>需要刷新时再次读取或导入;数据源可在页面底部移除。</p>
- <button type="button" class="taste-guide-skip">跳过</button>
+ <button type="button" class="geist-button taste-guide-skip">跳过</button>
</div></details>`;
}
diff --git a/frontend/test/islands.test.ts b/frontend/test/islands.test.ts
index 66d71baf6..103ddd5d7 100644
--- a/frontend/test/islands.test.ts
+++ b/frontend/test/islands.test.ts
@@ -22,7 +22,7 @@ afterEach(() => {
describe('island 注册表', () => {
it('登记的名字就是遗留路由能挂载的名字', () => {
- expect(islandNames()).toEqual(['scraping', 'quality-goals', 'configuration']);
+ expect(islandNames()).toEqual(['library-processing', 'scraping', 'quality-goals', 'configuration']);
});
it('未注册的名字立刻失败,不是静默什么都不画', async () => {
diff --git a/frontend/test/library-processing.test.tsx b/frontend/test/library-processing.test.tsx
new file mode 100644
index 000000000..e9cb1e63f
--- /dev/null
+++ b/frontend/test/library-processing.test.tsx
@@ -0,0 +1,33 @@
+import { afterEach, expect, it, vi } from 'vitest';
+import { h, render } from 'preact';
+import { act } from 'preact/test-utils';
+import { LibraryProcessing } from '../src/islands/library-processing';
+
+let host: HTMLDivElement;
+afterEach(() => { if(host)render(null, host); document.body.innerHTML=''; vi.unstubAllGlobals(); });
+it('启动只提交一次,进度用 GET 读取并提供复核入口', async () => {
+ const requests: string[]=[];
+ vi.stubGlobal('fetch',vi.fn(async (_url: string, init?: RequestInit) => {
+ const method=init?.method || 'GET'; requests.push(method);
+ return {ok:true,json:async()=>method==='POST'?{status:'running',job_id:'one'}:{status:'complete',job_id:'one',candidates:2}};
+ }));
+ host=document.createElement('div');document.body.append(host);
+ const toast=vi.fn();
+ await act(async()=>render(h(LibraryProcessing,{data:{status:'idle'},error:'',toast}),host));
+ await act(async()=>{host.querySelector('button')!.click();await new Promise(resolve=>setTimeout(resolve,0));});
+ expect(requests).toEqual(['POST','GET']);
+ expect(host.querySelector('a[href="/review"]')).not.toBeNull();
+ expect(toast).toHaveBeenCalledTimes(1);
+});
+it('刷新接续已有任务时只查询,旧完成结果不冒充当前回执', async () => {
+ const fetch=vi.fn(async()=>({ok:true,json:async()=>({status:'failed',error:'来源离线'})}));
+ vi.stubGlobal('fetch',fetch);
+ host=document.createElement('div');document.body.append(host);
+ const toast=vi.fn();
+ await act(async()=>{render(h(LibraryProcessing,{data:{status:'running'},error:'',toast}),host);await new Promise(resolve=>setTimeout(resolve,0));});
+ await act(async()=>{await new Promise(resolve=>setTimeout(resolve,0));});
+ expect(fetch).toHaveBeenCalledTimes(1);
+ expect(host.textContent).toContain('来源离线');
+ expect(host.textContent).toContain('重试未完成项');
+ expect(toast).not.toHaveBeenCalled();
+});
diff --git a/frontend/test/management.test.ts b/frontend/test/management.test.ts
index 399492c7c..a31d61e98 100644
--- a/frontend/test/management.test.ts
+++ b/frontend/test/management.test.ts
@@ -26,7 +26,7 @@ describe('数据管理首屏', () => {
expect(card.querySelector('.geist-fieldset-content > .geist-fieldset-title')).not.toBeNull();
expect(card.querySelector('.geist-fieldset-footer > button')?.textContent).not.toBe('');
}
- expect(cards[0]?.querySelector('p')?.textContent).toBe('下载高清封面,设置代理和 Cookie。');
+ expect(cards[0]?.querySelector('p')?.textContent).toBe('扫描媒体文件夹,导入已有资料,采集缺失信息。');
expect(cards[0]?.querySelector('.skeleton')).toBeNull();
expect(root.querySelectorAll('.cleanup-count-skeleton')).toHaveLength(7);
expect(root.querySelector('#resource-sync')).toBeNull();
@@ -39,6 +39,8 @@ describe('浏览器历史引导', () => {
root.innerHTML = tasteHistoryGuideHtml(true);
expect(root.querySelector('details')?.open).toBe(true);
expect(root.querySelector('.taste-guide-skip')?.textContent).toBe('跳过');
+ expect(root.querySelector('.taste-guide-skip')?.classList.contains('geist-button')).toBe(true);
+ expect(root.querySelector('.taste-guide-skip')?.hasAttribute('disabled')).toBe(false);
root.innerHTML = tasteHistoryGuideHtml(false);
expect(root.querySelector('details')?.open).toBe(false);
expect(root.querySelector('.taste-guide-skip')).not.toBeNull();
diff --git a/frontend/test/stubs/legacy-ui.ts b/frontend/test/stubs/legacy-ui.ts
index 500de049e..26b505c08 100644
--- a/frontend/test/stubs/legacy-ui.ts
+++ b/frontend/test/stubs/legacy-ui.ts
@@ -14,6 +14,9 @@ export const emptyStateHtml = (
export const fieldsetTitle = (id: string, title: string): string =>
`<h3 class="geist-fieldset-title" id="${id}">${title}</h3>`;
+export const loadingDotsHtml = (label: string): string => `<span>${label}</span>`;
+export const progressHtml = (label: string, value: number, max: number): string =>
+ `<progress aria-label="${label}" value="${value}" max="${max}"></progress>`;
export const MEDIA_SOURCE_ICONS: Record<string,string> = {local:'hard-drive','115':'fixture-115',pikpak:'fixture-pikpak'};
export const selectOptionIconHtml = (mark?: string): string => mark ? `<i data-source-icon="${mark}"></i>` : '';
diff --git a/src/peach/cli.py b/src/peach/cli.py
index 645749a69..c6e02ef10 100644
--- a/src/peach/cli.py
+++ b/src/peach/cli.py
@@ -466,6 +466,16 @@ def _scan(args: argparse.Namespace) -> int:
return 0
+def _process_library(args: argparse.Namespace) -> int:
+ from .library_processing import process_library
+ _require_readable_settings()
+ config = settings_file.active()
+ result = process_library(config, args.db, config.directory('generated'),
+ config.directory('generated') / 'covers', location=args.location,
+ report=lambda state: print(f"{state['stage']}:{state['checked']}/{state['total']}", flush=True))
+ return 0 if result['status'] == 'complete' else 1
+
+
def _create_data_tree(config: settings_file.PeachConfig) -> None:
"""建目录、把库迁到最新、生成本机 CA。事情由 `onboarding.create_data_tree` 做,
这里只把它做过的事说出来——托盘的设置页调同一个函数,两条前端不会各做一套。
@@ -623,6 +633,10 @@ def build_parser() -> argparse.ArgumentParser:
help="要扫的目录;省略时取该来源的声明根(本机目录按 [media.mounts] 取)")
scan_parser.add_argument("--db", type=Path, default=DEFAULT_DB)
scan_parser.set_defaults(handler=_scan)
+ process_parser = commands.add_parser('process', help='扫描文件并补全馆藏资料')
+ process_parser.add_argument('location', nargs='?', default='configured')
+ process_parser.add_argument('--db', type=Path, default=DEFAULT_DB)
+ process_parser.set_defaults(handler=_process_library)
token = commands.add_parser("token", help="查看局域网访问口令,没有就生成一份")
token.add_argument("--rotate", action="store_true",
diff --git a/src/peach/library_nfo.py b/src/peach/library_nfo.py
new file mode 100644
index 000000000..7bc4e6e1f
--- /dev/null
+++ b/src/peach/library_nfo.py
@@ -0,0 +1,66 @@
+"""Kodi/Jellyfin 影片及单集 NFO 的本地边车适配。"""
+from pathlib import Path
+import xml.etree.ElementTree as ET
+
+from .catalog_rules import release_code_from_text
+from .scan import VIDEO
+
+
+def sidecars(video: Path):
+ files = {path.name.casefold(): path for path in video.parent.iterdir() if path.is_file()}
+ single = sum(path.suffix.lower() in VIDEO for path in files.values()) == 1
+ nfo = files.get((video.stem + '.nfo').casefold())
+ if nfo is None and single:
+ nfo = files.get('movie.nfo')
+ names = [video.stem + '-poster', video.stem]
+ if single:
+ names.extend(['poster', 'folder', 'cover'])
+ posters = [files[name.casefold() + extension] for name in names
+ for extension in ('.jpg', '.jpeg', '.png', '.tbn')
+ if name.casefold() + extension in files]
+ return nfo, posters
+
+
+def read_nfo(path: Path):
+ """保留完整原文;拒绝 DTD,并限制 XML 的输入体积。"""
+ with path.open('rb') as handle:
+ raw = handle.read(1024 * 1024 + 1)
+ # XML 的 UTF-16/32 编码包含零字节;声明检查同样覆盖这些编码。
+ declarations = raw.replace(b'\x00', b'').upper()
+ if len(raw) > 1024 * 1024 or b'<!DOCTYPE' in declarations or b'<!ENTITY' in declarations:
+ raise ValueError('NFO 文件过大或包含实体声明')
+ root = ET.fromstring(raw)
+ if root.tag not in {'movie', 'episodedetails', 'musicvideo'}:
+ raise ValueError('NFO 不是影片或单集资料')
+ def text(*keys):
+ return next(((root.findtext(key) or '').strip() for key in keys
+ if (root.findtext(key) or '').strip()), '')
+ identifiers = [node.text for node in root.findall('uniqueid')
+ if node.get('type', '').lower() in {'javboss', 'jav', 'javid', 'dvdid', 'num'}]
+ identifiers.extend([text('num'), text('sorttitle')])
+ codes = {code for value in identifiers if (code := release_code_from_text(value or ''))}
+ if len(codes) > 1:
+ raise ValueError('NFO 包含多个不同番号')
+ genres = list(dict.fromkeys(node.text.strip() for key in ('genre', 'tag')
+ for node in root.findall(key) if node.text and node.text.strip()))
+ payload = dict(id=next(iter(codes), ''), title=text('title', 'localtitle', 'name'),
+ original_title=text('originaltitle'), maker=text('studio'),
+ series=text('set/name', 'set', 'showtitle'),
+ release_date=text('premiered', 'releasedate', 'aired'),
+ director=text('director'), runtime=text('runtime'),
+ actresses=[{'japanese_name': (node.findtext('name') or '').strip()}
+ for node in root.findall('actor')], genres=genres, local_tags=genres,
+ nfo_kind=root.tag, source_generator=text('generator'),
+ local_art=text('art/poster', 'thumb[@aspect="poster"]', 'thumb'))
+ return payload, raw
+
+
+def local_art(video: Path, payload: dict):
+ """仅读取影片所在目录内的本地图片,远端引用保留在原文。"""
+ value = payload.get('local_art', '')
+ if not value or '://' in value:
+ return None
+ path = (video.parent / value).resolve()
+ if path.is_relative_to(video.parent.resolve()) and path.is_file():
+ return path
+ return None
diff --git a/src/peach/library_processing.py b/src/peach/library_processing.py
new file mode 100644
index 000000000..5d6bf6219
--- /dev/null
+++ b/src/peach/library_processing.py
@@ -0,0 +1,291 @@
+"""扫描、本地资料和缺失元数据采集共用一次有状态的处理任务。"""
+from __future__ import annotations
+
+import hashlib
+import json
+import sqlite3
+import time
+import uuid
+import xml.etree.ElementTree as ET
+from contextlib import closing
+from pathlib import Path
+
+from filelock import FileLock, Timeout
+from PIL import Image
+
+from .catalog_rules import release_code_from_filename, same_release_code
+from .library_nfo import read_nfo, sidecars, local_art
+from .metadata import extract_catalog_evidence, extract_peach_fields, identifies_code, validate_provider_code
+from .platform import root_online, translate_ledger_path
+from .review_csv import read_rows, write_rows
+from .scan import scan_location
+from .jobs import DiskGuard
+
+FIELDS = ('item_key', 'code', 'query', 'asset_id', 'asset_path', 'field', 'field_label', 'current_value',
+ 'candidates_json', 'source_count', 'source_profile', 'policy_version', 'status',
+ 'size_gb', 'videos', 'fetched_at')
+LABELS = dict(title='标题', original_title='原标题', performers='演员', studio='厂牌',
+ series='系列', release_date='发行日期', tags='内容标签')
+
+
+class LibraryMetadataProvider:
+ """复用封面采集的 R18 JSON 入口与按来源配置的传输。"""
+ def __init__(self, secrets_root):
+ from .scraping_access import SourceTransport
+ from .jav_cover_fetch import HostLimitedTransport
+ self.transport = HostLimitedTransport(SourceTransport(secrets_root, max_requests=1000,
+ max_bytes=128 * 1024 * 1024, max_seconds=3600), 2.0)
+
+ def query(self, code, source='r18dev'):
+ from .jav_cover_fetch import R18_DETAIL, _fetch
+ from urllib.parse import quote
+ url = R18_DETAIL.format(code=quote(code))
+ raw = json.loads(_fetch(self.transport, url, referer='https://r18.dev/', limit=2 * 1024 * 1024))
+ if not identifies_code(code, {'content_id': raw.get('content_id')}):
+ raise ValueError('来源返回的番号不匹配')
+ name = lambda key: (raw.get(key) or {}).get('name', '')
+ return dict(id=code, content_id=raw.get('content_id'), source_url=url,
+ title=raw.get('title'), maker=name('maker'), series=name('series'),
+ release_date=raw.get('release_date'),
+ director=raw.get('director'), label=name('label'), runtime=raw.get('runtime_minutes'),
+ cover_url=(raw.get('images') or {}).get('jacket_image'),
+ actresses=[{'japanese_name': row.get('name', '')} for row in raw.get('actresses', [])],
+ genres=[row.get('name', '') for row in raw.get('categories', [])], raw=raw)
+
+ def close(self):
+ self.transport.close()
+
+ def cover(self, code, cover_root):
+ from .jav_cover_fetch import best_cover
+ target = cover_root / (code + '.jpg')
+ if target.is_file():
+ return False
+ candidate, size, data = best_cover(self.transport, code, 0)
+ cover_root.mkdir(parents=True, exist_ok=True)
+ temporary = target.with_suffix('.processing.tmp')
+ temporary.write_bytes(data)
+ temporary.replace(target)
+ _save(target.with_suffix('.scraping.json'), dict(source=candidate.source,
+ source_url=candidate.url, width=size[0], height=size[1],
+ raw_sha256=hashlib.sha256(data).hexdigest(), checked_at=time.time()))
+ return True
+
+
+def state_path(config):
+ return config.directory('state') / 'library-processing.json'
+
+
+def _save(path, payload):
+ path.parent.mkdir(parents=True, exist_ok=True)
+ temporary = path.with_suffix('.tmp')
+ temporary.write_text(json.dumps(payload, ensure_ascii=False), encoding='utf-8')
+ temporary.replace(path)
+
+
+def snapshot(config):
+ try:
+ state = json.loads(state_path(config).read_text(encoding='utf-8'))
+ except (OSError, ValueError):
+ return {'status': 'idle'}
+ if state.get('status') == 'running':
+ try:
+ # 锁覆盖 CLI 与 HTTP;进程退出后系统会释放它。
+ with FileLock(str(state_path(config)) + '.lock', timeout=0):
+ state = json.loads(state_path(config).read_text(encoding='utf-8'))
+ if state.get('status') == 'running':
+ state.update(status='failed', error='处理被中断,请重试。')
+ except Timeout:
+ pass
+ return state
+
+
+def _local_poster(video, code, cover_root, payload=None):
+ target = cover_root / (code + '.jpg')
+ if target.is_file():
+ return False
+ _, posters = sidecars(video)
+ reference = local_art(video, payload or {})
+ if reference:
+ posters.insert(0, reference)
+ if not posters:
+ return False
+ poster = posters[0]
+ if poster.stat().st_size > 32 * 1024 * 1024:
+ return False
+ with Image.open(poster) as image:
+ image.load()
+ cover_root.mkdir(parents=True, exist_ok=True)
+ temporary = target.with_suffix('.processing.tmp')
+ image.convert('RGB').save(temporary, format='JPEG', quality=95)
+ temporary.replace(target)
+ return True
+
+
+def _fields(payload):
+ fields = extract_peach_fields(payload)
+ evidence = extract_catalog_evidence(payload)
+ for key in ('title', 'original_title'):
+ if key in evidence:
+ fields[key] = evidence[key]
+ if payload.get('local_tags'):
+ from .entities import canonicalize_entity_name
+ values = list(dict.fromkeys(canonicalize_entity_name('tag', value) for value in payload['local_tags']))
+ values = [value for value in values if value]
+ if values:
+ fields['tags'] = dict(value=values, display_value='、'.join(values), warnings=[])
+ return fields
+
+
+def process_library(config, db_path, candidate_root, cover_root, *, location='configured',
+ report=lambda state: None, provider_factory=None, job_id=None, active=lambda: True):
+ """登记文件与确定的番号,外部资料保留为可复核候选。"""
+ def require_writer():
+ if config.replication.enabled:
+ from .sync import writer_device
+ device_path = config.directory('state') / 'device-id'
+ device = device_path.read_text(encoding='utf-8').strip() if device_path.is_file() else ''
+ if not device or writer_device(Path(db_path), config.shared_root / 'database' / 'ledger.db') != device:
+ raise ValueError('这台电脑是只读端,请在写入端扫描和导入资料')
+ require_writer()
+ path = state_path(config)
+ path.parent.mkdir(parents=True, exist_ok=True)
+ with FileLock(str(path) + '.lock', timeout=0):
+ state = dict(job_id=job_id or uuid.uuid4().hex, status='running', stage='扫描文件',
+ checked=0, total=0, scanned=0, identified=0, candidates=0, covers=0,
+ issues=[], started_at=time.time(), error='')
+ def update(**values):
+ require_writer()
+ if not active():
+ raise InterruptedError('处理任务已停止')
+ state.update(values)
+ _save(path, state)
+ report(dict(state))
+ def issue(asset_id, message):
+ state['issues'].append({'asset_id': asset_id, 'message': message})
+ update()
+ provider = None
+ try:
+ guard = DiskGuard(config.data_root, 1)
+ guard.check(force=True)
+ locations = config.locations if location == 'configured' else {location: config.locations[location]}
+ mounts = {key: tuple(str(value) for value in values) for key, values in config.mounts.items()}
+ online_roots = []
+ for source, roots in locations.items():
+ for root in roots:
+ guard.check()
+ if not root_online(translate_ledger_path(root)):
+ issue(None, f'{source} 来源离线')
+ continue
+ online_roots.append(translate_ledger_path(root).resolve())
+ result = scan_location(db_path, source, root, declared_roots=config.locations,
+ mounts=mounts, report=lambda line: update(stage='扫描文件'))
+ state['scanned'] += result.files
+ with closing(sqlite3.connect(db_path, timeout=30)) as connection:
+ connection.row_factory = sqlite3.Row
+ rows = [dict(row) for row in connection.execute(
+ "SELECT * FROM asset WHERE medium='video' AND (disposal IS NULL OR disposal<>'trash') "
+ "ORDER BY id") if row['location'] in locations
+ and any(translate_ledger_path(row['path']).resolve().is_relative_to(root) for root in online_roots)]
+ output = candidate_root / 'library-metadata-field-candidates.csv'
+ groups = {row['item_key']: row for row in read_rows(output, missing_ok=True)}
+ for index, row in enumerate(rows):
+ guard.check()
+ update(stage='读取本地资料', checked=index, total=len(rows))
+ video = translate_ledger_path(row['path'])
+ if not video.is_file():
+ issue(row['id'], '媒体文件不可访问')
+ continue
+ code = row['code'] or release_code_from_filename(row['name'])
+ payload = None
+ nfo, _ = sidecars(video)
+ if nfo:
+ try:
+ payload, raw = read_nfo(nfo)
+ if payload['id'] and code and not same_release_code(code, payload['id']):
+ raise ValueError('文件名与 NFO 番号冲突,请复核')
+ code = code or payload['id']
+ except (OSError, ValueError, ET.ParseError) as error:
+ issue(row['id'], str(error))
+ continue
+ if not code and not payload:
+ issue(row['id'], '未识别到番号,请在详情中补充资料')
+ continue
+ if code:
+ try:
+ code = validate_provider_code(code)
+ except ValueError:
+ issue(row['id'], '番号格式无效,请复核影片资料')
+ continue
+ if code and not row['code']:
+ with closing(sqlite3.connect(db_path, timeout=30)) as connection, connection:
+ connection.execute("UPDATE asset SET code=? WHERE id=? AND (code IS NULL OR code='')", (code, row['id']))
+ state['identified'] += 1
+ try:
+ poster_root = cover_root if code else config.directory('generated') / 'posters'
+ state['covers'] += int(_local_poster(video, code or f"{row['id']}_4", poster_root, payload))
+ except (OSError, ValueError):
+ issue(row['id'], '本地封面无法读取')
+ entries = []
+ if payload:
+ evidence_path = config.directory('sources') / 'library-metadata' / (hashlib.sha256(raw).hexdigest() + '.nfo')
+ evidence_path.parent.mkdir(parents=True, exist_ok=True)
+ evidence_path.write_bytes(raw)
+ entries.append(('local_nfo', payload, evidence_path))
+ local_fields = _fields(payload) if payload else {}
+ target_key = f"asset:{row['id']}"
+ missing = [field for field in ('title', 'performers', 'studio', 'release_date', 'tags')
+ if field not in local_fields and f'{target_key}:{field}' not in groups
+ and not row.get({'title': 'catalog_title'}.get(field, field))]
+ if missing and code:
+ update(stage='采集缺失资料')
+ try:
+ if provider is None:
+ provider = provider_factory() if provider_factory else LibraryMetadataProvider(config.directory('secrets') / 'follow')
+ external = provider.query(code, 'r18dev')
+ update(stage='保存资料候选')
+ evidence_path = config.directory('sources') / 'library-metadata' / (code + '-r18dev.json')
+ _save(evidence_path, external)
+ entries.append(('r18dev', external, evidence_path))
+ except Exception:
+ issue(row['id'], '外部资料未取得,请检查采集来源后重试')
+ if code and not (cover_root / (code + '.jpg')).is_file():
+ update(stage='采集缺失封面')
+ try:
+ if provider is None:
+ provider = provider_factory() if provider_factory else LibraryMetadataProvider(config.directory('secrets') / 'follow')
+ state['covers'] += int(provider.cover(code, cover_root))
+ except Exception:
+ issue(row['id'], '封面未取得,请检查采集来源后重试')
+ update(stage='保存资料候选')
+ for source, document, evidence_path in entries:
+ for field, value in _fields(document).items():
+ key = f'{target_key}:{field}'
+ identity = hashlib.sha256(json.dumps([source, value['value']], ensure_ascii=False, sort_keys=True).encode()).hexdigest()
+ candidate = dict(candidate_key=identity, source=source, provider='local-nfo' if source == 'local_nfo' else 'r18-json',
+ value=value['value'], display_value=value.get('display_value', str(value['value'])),
+ warnings=value.get('warnings', []), confidence=0.9 if source == 'local_nfo' else 0.75,
+ source_url=document.get('source_url', ''), raw_snapshot=str(evidence_path),
+ source_kind='local' if source == 'local_nfo' else 'official_mirror', official=False,
+ catalog_evidence=extract_catalog_evidence(document))
+ group = groups.get(key, dict(item_key=key, code=code or '', query=code or row['name'],
+ asset_id=row['id'], asset_path=row['path'], field=field,
+ field_label=LABELS[field], current_value=row.get({'title': 'catalog_title'}.get(field, field)) or '',
+ candidates_json='[]', source_count=0, source_profile='library', policy_version='library-v1',
+ status='candidate', size_gb=round((row['size'] or 0)/1024**3, 2), videos=1, fetched_at=''))
+ choices = [entry for entry in json.loads(group['candidates_json']) if entry['source'] != source]
+ choices.append(candidate)
+ group.update(candidates_json=json.dumps(choices, ensure_ascii=False), source_count=len(choices),
+ fetched_at=time.strftime('%Y-%m-%d %H:%M:%S'))
+ groups[key] = group
+ write_rows(output, FIELDS, groups.values(), atomic=True)
+ update(checked=index + 1, candidates=len(groups))
+ update(status='failed' if state['issues'] else 'complete', stage='处理结束', checked=len(rows),
+ error=f"{len(state['issues'])} 项需要处理,请查看详情并重试。" if state['issues'] else '', completed_at=time.time())
+ except Exception:
+ state.update(status='failed', error='处理被中断,请检查媒体目录后重试。', completed_at=time.time())
+ _save(path, state)
+ raise
+ finally:
+ if provider is not None and hasattr(provider, 'close'):
+ provider.close()
+ return state
diff --git a/src/peach/tray.py b/src/peach/tray.py
index 7c73ee7d1..d67dcf291 100644
--- a/src/peach/tray.py
+++ b/src/peach/tray.py
@@ -745,7 +745,7 @@ class SetupGate:
return True
def start_first_scan(self, config) -> subprocess.Popen | None:
- """消费首扫标记,用子进程跑一遍 `peach scan <来源>`。
+ """消费首扫标记,用子进程跑一遍 `peach process <来源>`。
扫描不能跑在引导服务里——那个进程刚被上面停掉;也不能跑在托盘线程里——
几万个文件要走十几分钟,会把健康轮询和菜单一起卡住。
@@ -765,7 +765,7 @@ class SetupGate:
# 否则 Windows 上这个文件会被托盘一直占着,谁也删不掉它。
with (log_dir / "tray-scan.out.log").open("ab") as handle:
process = self._popen(
- [str(_peach_executable()), "scan", location],
+ [str(_peach_executable()), "process", location],
cwd=str(PROJECT_ROOT), stdin=subprocess.DEVNULL,
stdout=handle, stderr=subprocess.STDOUT, shell=False,
creationflags=subprocess.CREATE_NO_WINDOW if os.name == "nt" else 0,
diff --git a/src/peach/web_catalog.py b/src/peach/web_catalog.py
index 583aa5b6a..95aca3d4b 100644
--- a/src/peach/web_catalog.py
+++ b/src/peach/web_catalog.py
@@ -313,6 +313,7 @@ def q_items(contract: WebContract, args):
for r in rows:
r["cost"] = COST.get(r["location"], "metered")
r["has_thumb"] = contract.has_snapshot(r["snapshot_path"])
+ r['has_local_poster'] = (contract.poster_root / f"{r['id']}_4.jpg").is_file()
r["has_cover"] = contract.has_cover(r.get("code"))
# 卡片上的出镜者称谓、规范番号、版本徽章与详情页使用同一份投影。
attach_jav_display_fields(r, r.get("tags", ()), r.pop("_entity_kinds", ()))
@@ -713,6 +714,7 @@ def q_item(contract: WebContract, aid):
d["studio"] = d["entities"]["studio"][0]
d["cost"] = COST.get(d["location"], "metered")
d["has_thumb"] = contract.has_snapshot(d["snapshot_path"])
+ d['has_local_poster'] = (contract.poster_root / f"{d['id']}_4.jpg").is_file()
# 身份格的厂牌位和顶栏小圆片同一条判据:没装标识就不输出 `<img>`。规范厂牌走
# `entity_refs`,非规范的那条只有扁平 `studio` 字段,两边都要有标志,否则
# 后者会从「本来能取到图」退化成永远首字母。
@@ -793,6 +795,7 @@ def q_related(contract: WebContract, aid, limit=24):
for d in picked:
d["cost"] = COST.get(d["location"], "metered")
d["has_thumb"] = contract.has_snapshot(d["snapshot_path"])
+ d['has_local_poster'] = (contract.poster_root / f"{d['id']}_4.jpg").is_file()
d["has_cover"] = contract.has_cover(d.get("code"))
attach_jav_display_fields(
d, related_tags.get(d["id"], ()), d.pop("_entity_kinds", ()),
diff --git a/src/peach/web_library_processing.py b/src/peach/web_library_processing.py
new file mode 100644
index 000000000..6ec4e7a92
--- /dev/null
+++ b/src/peach/web_library_processing.py
@@ -0,0 +1,30 @@
+"""统一处理任务的启动与只读状态查询。"""
+from . import settings_file
+from .library_processing import process_library, snapshot
+
+
+def q_library_processing(contract, _args):
+ live = contract.library_processing_job.snapshot()
+ return live if live and live.get('status') == 'running' else snapshot(settings_file.active())
+
+
+def w_library_processing(contract, _body):
+ config = settings_file.active()
+ if not config.configured or not config.locations:
+ raise ValueError('请先添加媒体文件夹')
+ if contract.db_path.resolve() != (config.directory('database') / 'ledger.db').resolve():
+ raise ValueError('当前馆藏与媒体配置不一致')
+ previous = snapshot(config)
+ if previous.get('status') == 'running':
+ return previous
+ def work(job_id):
+ try:
+ result = process_library(config, contract.db_path, contract.candidate_root, contract.cover_root,
+ job_id=job_id,
+ active=lambda: (contract.library_processing_job.snapshot() or {}).get('job_id') == job_id,
+ report=lambda state: contract.library_processing_job.update(job_id, **{
+ key: value for key, value in state.items() if key != 'job_id'}))
+ contract.library_processing_job.update(job_id, **{key: value for key, value in result.items() if key != 'job_id'})
+ finally:
+ contract.cache_bust()
+ return contract.library_processing_job.start(work, restart=True, initial={'stage': '准备处理'})
diff --git a/src/peach/web_review.py b/src/peach/web_review.py
index 8f24ae498..7d30c45ec 100644
--- a/src/peach/web_review.py
+++ b/src/peach/web_review.py
@@ -72,7 +72,7 @@ CANDIDATE_PREFIX = {
ADDITIONAL_CANDIDATE_FILES = {
# 分区文件先于通用批次读取;同一个 item_key 出现时,窄范围的刷新证据应覆盖
# 通用批次里的旧候选,而不是被 seen 去重静默吞掉。
- "metadata_fields": ("japanese-title-candidates.csv", "fc2-metadata-field-candidates.csv"),
+ "metadata_fields": ("library-metadata-field-candidates.csv", "japanese-title-candidates.csv", "fc2-metadata-field-candidates.csv"),
}
# 每类候选的稳定主键列。缺这一列的行直接跳过并计数,绝不退化成行号——
# 行号会在 CSV 重排后把历史决定悄悄挪到别的条目上。
@@ -270,7 +270,8 @@ def _attach_review_asset_context(connection, rows: list[dict]) -> None:
for row in rows:
code = str(row.get("code") or row.get("query") or "").strip()
- asset = assets_by_code.get(normalise_code_key(code)) if code else None
+ asset = (comparison_assets.get(int(row['asset_id'])) if row.get('asset_path') and str(row.get('asset_id', '')).isdigit()
+ else assets_by_code.get(normalise_code_key(code)) if code else None)
entity_id = str(row.get("entity_id") or "")
if asset is None and entity_id.isdigit():
asset = assets_by_entity.get(int(entity_id))
@@ -636,7 +637,8 @@ def _review_evidence(category: str, row: dict) -> str:
"""给本身没有 reason 列的候选拼一句可判断的证据,别让复核页只剩一个名字。"""
if category == "metadata_fields":
current = str(row.get("current_value") or "").strip() or "尚无"
- return (f"当前值:{current};{row.get('videos') or 0} 个同番号资产;"
+ target = '匹配资产' if row.get('asset_path') else '同番号资产'
+ return (f"当前值:{current};{row.get('videos') or 0} 个{target};"
f"{len(row.get('candidates') or [])} 个来源候选")
if category == "western_identity":
overlap = row.get("token_overlap") or "0"
@@ -748,14 +750,21 @@ def _apply_metadata_candidate(connection, group: dict, candidate: dict, now: str
raise ValueError("该元数据字段没有 Peach 写入映射")
code = str(group.get("code") or "").strip()
query = str(group.get("query") or code).strip()
- assets = connection.execute(
- "SELECT id FROM asset WHERE medium='video' AND (upper(trim(code))=upper(?) "
- "OR upper(trim(code))=upper(?)) AND (disposal IS NULL OR disposal<>'trash')",
- (code, query),
- ).fetchall()
+ if group.get('asset_path'):
+ assets = connection.execute(
+ "SELECT id FROM asset WHERE id=? AND path=? AND medium='video' "
+ "AND (disposal IS NULL OR disposal<>'trash')",
+ (group.get('asset_id'), group['asset_path']),
+ ).fetchall()
+ else:
+ assets = connection.execute(
+ "SELECT id FROM asset WHERE medium='video' AND (upper(trim(code))=upper(?) "
+ "OR upper(trim(code))=upper(?)) AND (disposal IS NULL OR disposal<>'trash')",
+ (code, query),
+ ).fetchall()
asset_ids = sorted({int(row["id"]) for row in assets})
if not asset_ids:
- raise ValueError("当前 ledger 已没有这个番号的可用资产")
+ raise ValueError("当前 ledger 已没有匹配的可用资产")
if len(asset_ids) > REVIEW_APPLY_LIMIT:
raise ValueError(f"同番号资产 {len(asset_ids)} 条,超过单次批准上限 {REVIEW_APPLY_LIMIT}")
source = str(candidate.get("source") or "").strip()
diff --git a/src/peach/web_router.py b/src/peach/web_router.py
index 4506032ce..849f5eded 100644
--- a/src/peach/web_router.py
+++ b/src/peach/web_router.py
@@ -48,6 +48,7 @@ from .web_follow import (
w_follow_status,
)
from .web_links import w_links, w_links_check, w_links_prune
+from .web_library_processing import q_library_processing, w_library_processing
from .web_playlists import q_playlist, q_playlists, w_playlist
from .web_resource_sync import w_purge_missing, w_resource_sync_apply, w_resource_sync_scan
from .web_review import q_review, w_review_auto_apply, w_review_decision
@@ -173,6 +174,7 @@ def _post_empty_trash(contract, _body):
GET_HANDLERS = {
+ "/api/library-processing": q_library_processing,
"/api/scraping": q_scraping,
"/api/scraping/cover": lambda contract, args: contract.scraping_cover_job.snapshot() or {"status": "idle"},
"/api/settings": q_settings,
@@ -209,6 +211,7 @@ GET_HANDLERS = {
}
POST_HANDLERS = {
+ "/api/library-processing": w_library_processing,
"/api/scraping/settings": w_scraping_settings,
"/api/scraping/cover": w_scraping_cover,
"/api/scraping/check": w_scraping_check,
diff --git a/src/peach/web_state.py b/src/peach/web_state.py
index 96045ddef..b3de18afa 100644
--- a/src/peach/web_state.py
+++ b/src/peach/web_state.py
@@ -173,6 +173,7 @@ class WebContract:
self.taste_refresh_job = BackgroundJob("PeachTasteRefreshJob")
self.link_prune_job = BackgroundJob("PeachLinkPruneJob")
self.scraping_cover_job = BackgroundJob("PeachScrapingCoverJob")
+ self.library_processing_job = BackgroundJob("PeachLibraryProcessingJob")
self.resource_apply_job = BackgroundJob("PeachResourceApplyJob")
self.follow_scheduler = None
# 两块后台任务的锁、状态和线程都归 BackgroundJob 管,契约上只留这两个字段。
@@ -241,6 +242,7 @@ class WebContract:
self.resource_scan.stop()
self.follow_job.stop()
self.scraping_cover_job.stop()
+ self.library_processing_job.stop()
self.follow_resolve_job.stop()
self.taste_refresh_job.stop()
self.link_prune_job.stop()
diff --git a/tests/test_metadata_library.py b/tests/test_metadata_library.py
new file mode 100644
index 000000000..1a142043a
--- /dev/null
+++ b/tests/test_metadata_library.py
@@ -0,0 +1,154 @@
+"""既有库边车识别和统一处理的隔离回归。"""
+import json
+import os
+import sqlite3
+import tempfile
+import unittest
+from pathlib import Path
+from unittest.mock import Mock
+from contextlib import closing
+
+from peach.library_nfo import read_nfo, sidecars, local_art
+from peach.library_processing import process_library, _fields, snapshot
+from peach.review_csv import read_rows
+from peach.settings_file import PeachConfig
+from peach.web_review import _apply_metadata_candidate
+from support.ledger import fresh_ledger
+
+
+class LibraryNfoTests(unittest.TestCase):
+ def setUp(self):
+ temporary = tempfile.TemporaryDirectory()
+ self.addCleanup(temporary.cleanup)
+ self.root = Path(temporary.name).resolve()
+
+ def test_javboss_fields_and_original_tags(self):
+ path = self.root / 'sample.nfo'
+ path.write_text('<movie><generator>JavBoss</generator><uniqueid type="javboss">ABW-358</uniqueid>'
+ '<title>作品</title><originaltitle>原題</originaltitle><set><name>系列</name></set>'
+ '<premiered>2023-05-26</premiered><runtime>210</runtime><actor><name>涼森れむ</name></actor>'
+ '<genre>自定义标签</genre><tag>有码</tag></movie>', encoding='utf-8')
+ payload, raw = read_nfo(path)
+ self.assertEqual(payload['id'], 'ABW-358')
+ self.assertEqual(payload['source_generator'], 'JavBoss')
+ self.assertIn('自定义标签', _fields(payload)['tags']['value'])
+ self.assertEqual(payload['runtime'], '210')
+ self.assertEqual(raw, path.read_bytes())
+
+ def test_movie_sidecar_only_when_unambiguous_and_named_file_preferred(self):
+ video = self.root / 'one.mp4'
+ video.touch()
+ common = self.root / 'movie.nfo'
+ common.touch()
+ self.assertEqual(sidecars(video)[0], common)
+ (self.root / 'two.mkv').touch()
+ self.assertIsNone(sidecars(video)[0])
+ named = self.root / 'one.NFO'
+ named.touch()
+ self.assertEqual(sidecars(video)[0], named)
+
+ def test_episode_and_plain_set_without_jav_identity(self):
+ path = self.root / 'episode.nfo'
+ path.write_text('<episodedetails><title>Episode</title><uniqueid type="tmdb">123</uniqueid>'
+ '<set>Collection</set><aired>2024-01-02</aired></episodedetails>', encoding='utf-8')
+ payload, _ = read_nfo(path)
+ self.assertEqual(payload['id'], '')
+ self.assertEqual(payload['series'], 'Collection')
+ self.assertEqual(payload['release_date'], '2024-01-02')
+
+ def test_entity_declarations_rejected_in_utf16(self):
+ path = self.root / 'unsafe.nfo'
+ path.write_bytes('<!DOCTYPE movie [<!ENTITY x "test">]><movie><title>&x;</title></movie>'.encode('utf-16'))
+ with self.assertRaises(ValueError):
+ read_nfo(path)
+
+ def test_art_cannot_escape_media_directory(self):
+ folder = self.root / 'film'
+ folder.mkdir()
+ (self.root / 'outside.jpg').touch()
+ self.assertIsNone(local_art(folder / 'film.mp4', {'local_art': '../outside.jpg'}))
+ self.assertIsNone(local_art(folder / 'film.mp4', {'local_art': 'https://example.com/poster.jpg'}))
+
+ @unittest.skipUnless(os.name == 'nt', '真实声明根使用 Windows 盘符')
+ def test_scan_import_and_explicit_review_use_exact_asset(self):
+ media = self.root / 'media'
+ media.mkdir()
+ video = media / 'film.mp4'
+ video.write_bytes(b'video')
+ (media / 'movie.nfo').write_text('<movie><title>Local title</title><tag>自定义标签</tag></movie>', encoding='utf-8')
+ db = fresh_ledger(self.root)
+ config = PeachConfig(self.root, self.root / 'config.toml', present=True, locations={'local': (str(media),)})
+ factory = Mock()
+ result = process_library(config, db, self.root / 'generated', self.root / 'covers', provider_factory=factory)
+ self.assertEqual(result['status'], 'complete')
+ factory.assert_not_called()
+ groups = read_rows(self.root / 'generated/library-metadata-field-candidates.csv')
+ title = next(row for row in groups if row['field'] == 'title')
+ with closing(sqlite3.connect(db)) as connection, connection:
+ connection.row_factory = sqlite3.Row
+ self.assertIsNone(connection.execute('SELECT catalog_title FROM asset WHERE medium="video"').fetchone()[0])
+ candidate = json.loads(title['candidates_json'])[0]
+ self.assertEqual(_apply_metadata_candidate(connection, title, candidate, '2026-09-06'), 1)
+ self.assertEqual(connection.execute('SELECT catalog_title FROM asset WHERE medium="video"').fetchone()[0], 'Local title')
+ title['asset_path'] = 'moved.mp4'
+ with self.assertRaises(ValueError):
+ _apply_metadata_candidate(connection, title, candidate, '2026-09-06')
+ self.assertEqual(snapshot(config)['status'], 'complete')
+
+ def test_status_reads_do_not_start_processing(self):
+ from peach.web_library_processing import q_library_processing
+ from unittest.mock import patch
+ contract = Mock()
+ contract.library_processing_job.snapshot.return_value = {'status': 'running', 'job_id': 'one'}
+ with patch('peach.web_library_processing.process_library') as worker:
+ self.assertEqual(q_library_processing(contract, {})['job_id'], 'one')
+ worker.assert_not_called()
+
+ def test_reader_cannot_scan_or_create_candidates(self):
+ from peach.settings_file import ReplicationSettings
+ config = PeachConfig(self.root, self.root / 'config.toml', replication=ReplicationSettings(enabled=True))
+ with self.assertRaisesRegex(ValueError, '只读端'):
+ process_library(config, self.root / 'ledger.db', self.root / 'generated', self.root / 'covers')
+ self.assertFalse((self.root / 'generated').exists())
+ self.assertFalse((self.root / 'ledger.db').exists())
+
+ @unittest.skipUnless(os.name == 'nt', '真实声明根使用 Windows 盘符')
+ def test_local_metadata_remote_completion_and_repeat_are_one_pipeline(self):
+ from PIL import Image
+ media = self.root / 'media'
+ media.mkdir()
+ video = media / 'ABW-358.mp4'
+ video.write_bytes(b'video')
+ (media / 'ABW-358.nfo').write_text('<movie><title>Local title</title><sorttitle>ABW-358</sorttitle>'
+ '<premiered>2023-05-26</premiered><actor><name>涼森れむ</name></actor><tag>自定义标签</tag></movie>', encoding='utf-8')
+ Image.new('RGB', (40, 60), 'blue').save(media / 'ABW-358-poster.jpg')
+ db = fresh_ledger(self.root)
+ config = PeachConfig(self.root, self.root / 'config.toml', present=True, locations={'local': (str(media),)})
+ provider = Mock()
+ provider.query.return_value = {'maker': 'Studio', 'id': 'ABW-358', 'director': 'Director', 'runtime': 210}
+ factory = Mock(return_value=provider)
+ result = process_library(config, db, self.root / 'generated', self.root / 'covers', provider_factory=factory)
+ self.assertEqual(result['status'], 'complete')
+ self.assertEqual(result['identified'], 1)
+ self.assertEqual(result['covers'], 1)
+ provider.cover.assert_not_called()
+ provider.query.assert_called_once_with('ABW-358', 'r18dev')
+ groups = read_rows(self.root / 'generated/library-metadata-field-candidates.csv')
+ studio = next(row for row in groups if row['field'] == 'studio')
+ self.assertEqual(json.loads(studio['candidates_json'])[0]['catalog_evidence']['runtime']['value'], 210)
+ second = process_library(config, db, self.root / 'generated', self.root / 'covers', provider_factory=factory)
+ self.assertEqual(second['status'], 'complete')
+ self.assertEqual(second['candidates'], result['candidates'])
+ provider.query.assert_called_once()
+
+ def test_management_controls_keep_credentials_and_empty_sections_visible(self):
+ root = Path(__file__).resolve().parents[1]
+ source = (root / 'web/app.js').read_text(encoding='utf-8')
+ self.assertIn('wireFollowManage(creds)', source)
+ self.assertIn('const sources=[...credentials,...(followData?.sources||[])];', source)
+ self.assertIn('data-srcfilter-config=', source)
+ self.assertNotIn("if(!providers.length){mount.innerHTML='';return}", source)
+ self.assertNotIn("needsAttention?' open':''", source)
+ self.assertIn('还没有内容标签', source)
+ self.assertIn('还没有存储来源', source)
+ self.assertIn("totalVideos?locationRows:catalogEmptyHtml", source)
diff --git a/tests/test_tray.py b/tests/test_tray.py
index ed3607097..69c740ba5 100644
--- a/tests/test_tray.py
+++ b/tests/test_tray.py
@@ -558,7 +558,7 @@ class SetupGateTests(unittest.TestCase):
self.assertEqual(gate.open_url(), "https://peach-writer.local/")
scan = scan_popen.call_args
- self.assertEqual(list(scan.args[0][1:]), ["scan", "local"])
+ self.assertEqual(list(scan.args[0][1:]), ["process", "local"])
self.assertEqual(scan.kwargs["env"]["PEACH_DATA_ROOT"], str(self.data_root))
# 标记只消费一次:下一轮轮询已经不在等待状态,也不会再拉起一次扫描。
self.assertFalse(gate.poll())
diff --git a/web/app.js b/web/app.js
index fe1174a80..a8aae1ce7 100644
--- a/web/app.js
+++ b/web/app.js
@@ -2018,7 +2018,7 @@ function javArtwork(it,layout,eager=false){
const kind=javImageKind(it,appSettings.javImage);
if(!kind)return '<span class="nopic">无预览</span>';
const cover=it.has_cover&&it.code?`/cover?code=${encodeURIComponent(it.code)}`:'';
- const thumb=it.has_thumb?`/poster?id=${it.id}&c=4`:'';
+ const thumb=(it.has_thumb||it.has_local_poster)?`/poster?id=${it.id}&c=4`:'';
const coverHtml=coverImage(it,layout==='big'?'big':'small',eager);
const frame=(coverHtml.match(/ data-c[xy]="[^"]*"/g)||[]).join('');
const image=kind==='cover'?coverHtml
@@ -2095,7 +2095,7 @@ function cardHtml(it,cls){
? javArtwork(it,jav?layout:'small')
: it.follow_thumb_url
? `<img class="poster" src="${esc(it.follow_thumb_url)}" alt="" loading="lazy" referrerpolicy="no-referrer">`
- : (it.has_thumb
+ : (it.has_thumb||it.has_local_poster
? `<img class="poster" src="/poster?id=${it.id}&c=4" alt="" loading="lazy">`
: `<span class="nopic">无预览</span>`);
const fl=[it.feedback==='dislike'&&'dislike',it.feedback==='seen'&&'seen',
@@ -2308,7 +2308,7 @@ function mixFacePoster(it,layout,eager){
const load=eager?'eager':'lazy';
return it.is_jav
? javArtwork(it,jav?layout:'small',eager)
- : (it.has_thumb
+ : (it.has_thumb||it.has_local_poster
? `<img class="poster" src="/poster?id=${it.id}&c=4" alt="" loading="${load}">`
: `<span class="nopic">无预览</span>`);
}
@@ -2915,8 +2915,9 @@ async function openStats(push=true){
/* 一行都没有时整张表不出现,只留 Empty State:Geist Table 的判据是空态渲染在表格
外面,留一张只有列头的空表等于让人对着两个列名找不存在的行。 */
const table=(head,rows,empty)=>rows?`<div class="insighttable"><div class="insighttablehead">${head.map(value=>`<span>${value}</span>`).join('')}</div>${rows}</div>`:empty;
- const tagsTable=`<ol class="insightranking">${d.top_tags.map((t,index)=>`<li><button type="button" class="insightrankrow" data-k="${esc(t.k)}">
- <span class="insightrankpos">${index+1}</span><span>${esc(tagLabel(t.k))}</span><b>${t.n.toLocaleString()}</b></button></li>`).join('')}</ol>`;
+ const tagsTable=d.top_tags.length?`<ol class="insightranking">${d.top_tags.map((t,index)=>`<li><button type="button" class="insightrankrow" data-k="${esc(t.k)}">
+ <span class="insightrankpos">${index+1}</span><span>${esc(tagLabel(t.k))}</span><b>${t.n.toLocaleString()}</b></button></li>`).join('')}</ol>`
+ :emptyStateHtml('tags','还没有内容标签','补全资料或添加标签后,这里会显示馆藏中的内容标签。');
const recentTable=table(['作品','观看证据'],d.recent.map(row=>{
const real=row.duration?Math.min(row.play_seconds/row.duration,1)*100:0;
const reached=(row.max_reached||0)*100;
@@ -2927,9 +2928,10 @@ async function openStats(push=true){
const sourceTable=table(['标签来源','覆盖视频'],d.tag_source.map(row=>`<div class="insighttablerow"><span>${esc(row.k)}</span>
<b>${row.n.toLocaleString()} 条 · ${row.assets.toLocaleString()} 个视频</b></div>`).join(''),
`<div class="insightempty">${emptyStateHtml('tags','还没有标签来源','刮削或手动打标之后,这里会显示每个来源覆盖了多少视频。')}</div>`);
- const storageTable=`<table class="insightdatatable"><thead><tr><th>位置</th><th>已用</th><th>可用</th><th>使用率</th></tr></thead><tbody>${(d.storage_volumes||[]).map(row=>{
+ const storageTable=(d.storage_volumes||[]).length?`<table class="insightdatatable"><thead><tr><th>位置</th><th>已用</th><th>可用</th><th>使用率</th></tr></thead><tbody>${(d.storage_volumes||[]).map(row=>{
const measured=row.total!=null, usedPct=measured?pct(row.used,row.total):0;
- return `<tr><th scope="row"><span>${esc(row.label)}</span><small>${row.root?esc(row.root):'未映射'}</small></th><td>${measured?gb(row.used):'—'}</td><td>${measured?gb(row.free):'—'}</td><td>${measured?usedPct+'%':(row.online?'容量未取得':'离线')}</td></tr>`}).join('')}</tbody></table>`;
+ return `<tr><th scope="row"><span>${esc(row.label)}</span><small>${row.root?esc(row.root):'未映射'}</small></th><td>${measured?gb(row.used):'—'}</td><td>${measured?gb(row.free):'—'}</td><td>${measured?usedPct+'%':(row.online?'容量未取得':'离线')}</td></tr>`}).join('')}</tbody></table>`
+ :emptyStateHtml('hard-drive','还没有存储来源','添加媒体文件夹后,这里会显示存储空间。');
$('#stats').innerHTML=`
<div class="insightpage statsdashboard" data-stats-dashboard>
<header class="insighttoolbar"><p>账本当前快照 · ${totalVideos.toLocaleString()} 个视频 · ${gb(totalBytes)}</p></header>
@@ -2943,7 +2945,7 @@ async function openStats(push=true){
<div id="stats-detail-inventory" role="tabpanel" data-stats-detail="inventory" class="insightdetailbody">
<div class="insightcopy"><span>库存</span><h2>${totalVideos.toLocaleString()}</h2><b>个视频</b>
</div>
- <div class="insightvisual">${locationRows}</div></div>
+ <div class="insightvisual">${totalVideos?locationRows:catalogEmptyHtml({configurable:runtimeConfigurable})}</div></div>
<div id="stats-detail-viewing" role="tabpanel" data-stats-detail="viewing" class="insightdetailbody" hidden>
<div class="insightcopy"><span>观看</span><h2>${cs.played.toLocaleString()}</h2><b>个作品有播放记录</b>
<p>累计 ${hrs(cs.play_seconds)}</p></div>
@@ -3502,10 +3504,10 @@ async function openDataCleanup(push=true){
.map(([key,label])=>`${esc(label)} ${Number(junkCounts[key]).toLocaleString()}`),
...(Number(junk.dismissed_total)>0?[`已忽略 ${Number(junk.dismissed_total).toLocaleString()}`]:[])].join(' · ');
$('#stats').innerHTML=`<div class="cleanuppage"><div class="cleanupgrid">
- <section class="cleanupfieldset" data-geist-fieldset aria-labelledby="cleanupScrapingTitle">
- <div class="geist-fieldset-content">${fieldsetTitle('cleanupScrapingTitle','采集来源')}
- <p>下载高清封面,设置代理和 Cookie。</p></div>
- <footer class="geist-fieldset-footer" data-geist-fieldset-footer><button type="button" data-cleanup-open="scraping">设置采集来源</button></footer>
+ <section class="cleanupfieldset" id="libraryProcessing" data-geist-fieldset aria-labelledby="cleanupScrapingTitle">
+ <div class="geist-fieldset-content">${fieldsetTitle('cleanupScrapingTitle','扫描与采集')}
+ <p>扫描媒体文件夹,导入已有资料,采集缺失信息。</p></div>
+ <footer class="geist-fieldset-footer" data-geist-fieldset-footer><button type="button" disabled>扫描并补全资料</button></footer>
</section>
<section class="cleanupfieldset" data-geist-fieldset aria-labelledby="cleanupJunkTitle">
<div class="geist-fieldset-content">${fieldsetTitle('cleanupJunkTitle','垃圾文件')}
@@ -3538,7 +3540,10 @@ async function openDataCleanup(push=true){
${linkManagerMarkup()}
${cloudLocations(sources.sources||[]).length?resourceSyncMarkup():''}</div>`;
$('#stats').querySelector('[data-cleanup-open="junk"]').onclick=()=>openManage('ads');
- $('#stats').querySelector('[data-cleanup-open="scraping"]').onclick=()=>openScraping();
+ const processingUi=await import('/dist/peach-ui.js');
+ if(!surfaceCurrent(surface))return;
+ await processingUi.mountIsland('library-processing',$('#libraryProcessing'),{toast,onComplete:()=>{if(surfaceCurrent(surface))void paintDataManagementCounts()}},{isCurrent:()=>surfaceCurrent(surface)});
+ if(!surfaceCurrent(surface))return;
$('#stats').querySelector('[data-cleanup-open="duplicates"]').onclick=()=>openDuplicates();
$('#stats').querySelectorAll('[data-cleanup-go]').forEach(button=>
button.onclick=()=>openManage(button.dataset.cleanupGo));
@@ -4928,7 +4933,6 @@ function followSuggestionChips(list){
function followCredentialRow(row){
const [label,kind]=CRED_STATE[row.requirement]||CRED_STATE.none;
const configured=row.present&&!row.missing.length;
- const needsAttention=row.requirement==='required'&&!configured;
const fields=(row.needs||[]).map(name=>`<label class="fcredfield">
<span>${esc(name)}</span>
<input type="password" name="${esc(name)}" autocomplete="off" spellcheck="false"
@@ -4953,7 +4957,7 @@ function followCredentialRow(row){
const mark=`<span class="ficonslot" aria-hidden="true">${sourceIcon(row.provider)}</span>`;
if(!body)return `<div class="frow fcred none">${mark}<b>${esc(row.provider_label)}</b>
<span class="fcstate none">${esc(label)}</span></div>`;
- return `<details class="frow fcred ${esc(kind)}${configured?' ok':''}"${needsAttention?' open':''}>
+ return `<details class="frow fcred ${esc(kind)}${configured?' ok':''}">
<summary>${mark}<b>${esc(row.provider_label)}</b>
<span class="fcstate ${configured?'done':esc(kind)}">${esc(configured?'已配置':label)}</span>
${row.missing.length?`<span class="fcstate missing">缺 ${esc(row.missing.join('、'))}</span>`:''}
@@ -5040,7 +5044,7 @@ function renderFollowManage(credentials){
<span class="fdescpop" id="follow-credential-tooltip" role="tooltip" hidden>存放在<b>运行 Peach 的那台机器</b>上,不是浏览器所在机器;不进 Git、URL、日志或 ledger。NTFS 的访问控制走 ACL,<code>chmod</code> 在那里没有效果;POSIX 上建成 0600。</span></p>
</section>
</div></div>`;
- wireFollowManage();
+ wireFollowManage(creds);
void wireFollowProgress();
if(locked)$('#stats').querySelectorAll(
'#followAdd input,#followAdd button,[data-follow-remove],[data-follow-check],'+
@@ -5117,7 +5121,7 @@ function wireFollowItems(){
});
}
-function wireFollowManage(){
+function wireFollowManage(creds=[]){
void wireResolveProgress();
const root=$('#stats'),form=root.querySelector('#followAdd');
wireScrollers(root);
@@ -5133,7 +5137,7 @@ function wireFollowManage(){
routeFollowManageSort();
};
wireIconSwitch(root,'data-follow-layout',setFollowListLayout);
- renderFollowSrcFilter(root.querySelector('#followSrcFilter'));
+ renderFollowSrcFilter(root.querySelector('#followSrcFilter'),creds);
const tooltipTrigger=root.querySelector('[data-fdesc-tooltip]');
const tooltip=root.querySelector('#follow-credential-tooltip');
if(tooltipTrigger&&tooltip){
@@ -5341,29 +5345,40 @@ function wireFollowManage(){
替用户决定「就是这个」是错的。已经关注的项灰掉但仍显示,免得人以为没查到。 */
/* 来源筛选的常驻控件:挂在「添加关注」面板里,列出全部已关注来源,
默认全选;取消勾选的来源,其查找结果行隐藏、也不进「添加选中」。 */
-function renderFollowSrcFilter(mount){
+function renderFollowSrcFilter(mount,credentials=[]){
if(!mount)return;
closeAnchoredMenu();
- const providers=[...new Set((followData?.sources||[])
+ const sources=[...credentials,...(followData?.sources||[])];
+ const providers=[...new Set(sources
.map(source=>source.provider_label).filter(Boolean))];
/* 下拉里的每一行带上该来源的 favicon:label 只是展示名,图标要靠 provider
查 SOURCE_ICONS,所以另建一张 label→provider 的映射。 */
- const providerIcon=new Map((followData?.sources||[]).filter(source=>source.provider&&source.provider_label)
+ const providerIcon=new Map(sources.filter(source=>source.provider&&source.provider_label)
.map(source=>[source.provider_label,source.provider]));
providers.forEach(provider=>{if(!fsrcProviders.has(provider))fsrcProviders.add(provider)});
- if(!providers.length){mount.innerHTML='';return}
+ const requirements=new Map(credentials.map(row=>[row.provider_label,row]));
const label=()=>{const n=providers.filter(p=>!fsrcUnchecked.has(p)).length;
return n===providers.length?'全部来源':`${n}/${providers.length} 个来源`};
mount.innerHTML=`<button type="button" class="fbtn" data-srcfilter-toggle
aria-expanded="false" aria-haspopup="menu" aria-controls="follow-source-menu"
aria-label="${esc(label())}" title="${esc(label())}">
${icon('list-filter')}<span data-srcfilter-label>${esc(label())}</span></button>
- <div class="popmenu fsrcmenu" id="follow-source-menu" role="menu" data-srcfilter-menu hidden>${providers.map(provider=>
- `<label>${checkboxHtml(`data-srcfilter="${esc(provider)}"${fsrcUnchecked.has(provider)?'':' checked'}`)}
- ${sourceIcon(providerIcon.get(provider)||'')}<span>${esc(provider)}</span></label>`).join('')}</div>`;
+ <div class="popmenu fsrcmenu" id="follow-source-menu" role="menu" data-srcfilter-menu hidden>${providers.map(provider=>{
+ const row=requirements.get(provider);
+ const needsCredentials=row?.requirement==='required'&&(!row.present||(row.missing||[]).length);
+ return `<div class="fsrcoption"><label>${checkboxHtml(`data-srcfilter="${esc(provider)}"${fsrcUnchecked.has(provider)?'':' checked'}`)}
+ ${sourceIcon(providerIcon.get(provider)||'')}<span>${esc(provider)}</span></label>
+ ${needsCredentials?`<button type="button" class="geist-button" data-srcfilter-config="${esc(row.provider)}">需要配置凭据</button>`:''}</div>`;
+ }).join('')||'<p>暂无可用来源</p>'}</div>`;
const toggle=mount.querySelector('[data-srcfilter-toggle]');
const menu=mount.querySelector('[data-srcfilter-menu]');
wireAnchoredMenu(mount,toggle,menu);
+ menu.querySelectorAll('[data-srcfilter-config]').forEach(button=>button.onclick=()=>{
+ closeAnchoredMenu();
+ const form=[...document.querySelectorAll('[data-cred-form]')].find(form=>form.dataset.credForm===button.dataset.srcfilterConfig);
+ const details=form?.closest('details');
+ if(details){details.open=true;details.scrollIntoView({block:'center',behavior:'smooth'});form.querySelector('input')?.focus({preventScroll:true})}
+ });
menu.querySelectorAll('[data-srcfilter]').forEach(input=>input.onchange=()=>{
input.checked?fsrcUnchecked.delete(input.dataset.srcfilter)
:fsrcUnchecked.add(input.dataset.srcfilter);
diff --git a/web/css/04-manage.css b/web/css/04-manage.css
index 32106c4a7..3720b9fb9 100644
--- a/web/css/04-manage.css
+++ b/web/css/04-manage.css
@@ -80,6 +80,12 @@
.taste-history-guide-content{display:grid;gap:12px;padding-top:16px;color:var(--muted);font-size:var(--fs-md);line-height:1.5}
.taste-history-guide-content p,.taste-history-guide-content ul{margin:0}
.taste-history-guide-content ul{padding-left:20px}
+.taste-history-guide-content .taste-guide-skip{width:100%;height:var(--control-h);color:var(--ink)}
+.fsrcoption{display:flex;align-items:center;gap:8px;justify-content:space-between}
+.fsrcoption label{flex:1;min-width:0}
+.fsrcoption .geist-button{font-size:12px;white-space:nowrap}
+.library-processing ul{padding-left:20px}
+.statsdashboard .emptystate{border:0;background:transparent}
.taste-history-guide-content a{color:var(--tungsten);text-decoration:none}
.taste-history-guide-content a:hover{text-decoration:underline;text-underline-offset:3px}
.taste-history-guide-content a svg{width:14px;height:14px;margin-left:4px;vertical-align:-2px;fill:none;stroke:currentColor}
diff --git a/web/dist/peach-ui.js b/web/dist/peach-ui.js
index 7139db336..0aad8ba96 100644
--- a/web/dist/peach-ui.js
+++ b/web/dist/peach-ui.js
@@ -1,21 +1,21 @@
-import { MEDIA_SOURCE_ICONS as e, emptyStateHtml as t, fieldsetTitle as n, noteHtml as r, selectFieldHtml as i, selectOptionIconHtml as a, setActionBusy as o, wireSelectField as s } from "/js/ui-components.js";
-import { LOC as c, fmtDur as l, fmtSize as u } from "/js/core.js";
+import { MEDIA_SOURCE_ICONS as e, emptyStateHtml as t, fieldsetTitle as n, loadingDotsHtml as r, noteHtml as i, progressHtml as a, selectFieldHtml as o, selectOptionIconHtml as s, setActionBusy as c, wireSelectField as l } from "/js/ui-components.js";
+import { LOC as u, fmtDur as d, fmtSize as f } from "/js/core.js";
//#region node_modules/preact/dist/preact.module.js
-var d, f, p, m, h, g, _, v, y, b, x, S, C, w, T, E = {}, D = [], O = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, k = Array.isArray;
-function A(e, t) {
+var p, m, h, g, _, v, y, b, x, S, C, w, T, E, D, O = {}, k = [], ee = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, A = Array.isArray;
+function j(e, t) {
for (var n in t) e[n] = t[n];
return e;
}
-function ee(e) {
+function M(e) {
e && e.parentNode && e.parentNode.removeChild(e);
}
function te(e, t, n) {
var r, i, a, o = {};
for (a in t) a == "key" ? r = t[a] : a == "ref" ? i = t[a] : o[a] = t[a];
- if (arguments.length > 2 && (o.children = arguments.length > 3 ? d.call(arguments, 2) : n), typeof e == "function" && e.defaultProps != null) for (a in e.defaultProps) o[a] === void 0 && (o[a] = e.defaultProps[a]);
- return j(e, o, r, i, null);
+ if (arguments.length > 2 && (o.children = arguments.length > 3 ? p.call(arguments, 2) : n), typeof e == "function" && e.defaultProps != null) for (a in e.defaultProps) o[a] === void 0 && (o[a] = e.defaultProps[a]);
+ return ne(e, o, r, i, null);
}
-function j(e, t, n, r, i) {
+function ne(e, t, n, r, i) {
var a = {
type: e,
props: t,
@@ -27,68 +27,68 @@ function j(e, t, n, r, i) {
__e: null,
__c: null,
constructor: void 0,
- __v: i ?? ++p,
+ __v: i ?? ++h,
__i: -1,
__u: 0
};
- return i == null && f.vnode != null && f.vnode(a), a;
+ return i == null && m.vnode != null && m.vnode(a), a;
}
-function M(e) {
+function N(e) {
return e.children;
}
-function N(e, t) {
+function P(e, t) {
this.props = e, this.context = t;
}
-function P(e, t) {
- if (t == null) return e.__ ? P(e.__, e.__i + 1) : null;
+function F(e, t) {
+ if (t == null) return e.__ ? F(e.__, e.__i + 1) : null;
for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) return n.__e;
- return typeof e.type == "function" ? P(e) : null;
+ return typeof e.type == "function" ? F(e) : null;
}
-function ne(e) {
+function re(e) {
if (e.__P && e.__d) {
- var t = e.__v, n = t.__e, r = [], i = [], a = A({}, t);
- a.__v = t.__v + 1, f.vnode && f.vnode(a), pe(e.__P, a, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [n] : null, r, n ?? P(t), !!(32 & t.__u), i), a.__v = t.__v, a.__.__k[a.__i] = a, he(r, a, i), t.__e = t.__ = null, a.__e != n && re(a);
+ var t = e.__v, n = t.__e, r = [], i = [], a = j({}, t);
+ a.__v = t.__v + 1, m.vnode && m.vnode(a), me(e.__P, a, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [n] : null, r, n ?? F(t), !!(32 & t.__u), i), a.__v = t.__v, a.__.__k[a.__i] = a, ge(r, a, i), t.__e = t.__ = null, a.__e != n && ie(a);
}
}
-function re(e) {
+function ie(e) {
if ((e = e.__) != null && e.__c != null) return e.__e = e.__c.base = null, e.__k.some(function(t) {
if (t != null && t.__e != null) return e.__e = e.__c.base = t.__e;
- }), re(e);
+ }), ie(e);
}
-function ie(e) {
- (!e.__d && (e.__d = !0) && h.push(e) && !ae.__r++ || g != f.debounceRendering) && ((g = f.debounceRendering) || _)(ae);
+function ae(e) {
+ (!e.__d && (e.__d = !0) && _.push(e) && !oe.__r++ || v != m.debounceRendering) && ((v = m.debounceRendering) || y)(oe);
}
-function ae() {
+function oe() {
try {
- for (var e, t = 1; h.length;) h.length > t && h.sort(v), e = h.shift(), t = h.length, ne(e);
+ for (var e, t = 1; _.length;) _.length > t && _.sort(b), e = _.shift(), t = _.length, re(e);
} finally {
- h.length = ae.__r = 0;
+ _.length = oe.__r = 0;
}
}
-function oe(e, t, n, r, i, a, o, s, c, l, u) {
- var d, f, p, m, h, g, _ = r && r.__k || D, v = t.length;
- for (c = se(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && _[p.__i] || E, p.__i = d, g = pe(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && ve(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h == null && m != null && (h = m), 4 & p.__u ? (c = ce(p, c, e), f.__e && (f.__e = null)) : typeof p.type == "function" && g !== void 0 ? c = g : m && (c = m.nextSibling), p.__u &= -7);
+function se(e, t, n, r, i, a, o, s, c, l, u) {
+ var d, f, p, m, h, g, _ = r && r.__k || k, v = t.length;
+ for (c = ce(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && _[p.__i] || O, p.__i = d, g = me(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && ye(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h == null && m != null && (h = m), 4 & p.__u ? (c = le(p, c, e), f.__e && (f.__e = null)) : typeof p.type == "function" && g !== void 0 ? c = g : m && (c = m.nextSibling), p.__u &= -7);
return n.__e = h, c;
}
-function se(e, t, n, r, i) {
+function ce(e, t, n, r, i) {
var a, o, s, c, l, u = n.length, d = u, f = 0;
- for (e.__k = Array(i), a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o == "string" || typeof o == "number" || typeof o == "bigint" || o.constructor == String ? o = e.__k[a] = j(null, o, null, null, null) : k(o) ? o = e.__k[a] = j(M, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = j(o.type, o.props, o.key, o.ref ? o.ref : null, o.__v) : e.__k[a] = o, c = a + f, o.__ = e, o.__b = e.__b + 1, s = null, (l = o.__i = le(o, n, c, d)) != -1 && (d--, (s = n[l]) && (s.__u |= 2)), s == null || s.__v == null ? (l == -1 && (i > u ? f-- : i < u && f++), typeof o.type != "function" && (o.__u |= 4)) : l != c && (l == c - 1 ? f-- : l == c + 1 ? f++ : (l > c ? f-- : f++, o.__u |= 4))) : e.__k[a] = null;
- if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = P(s)), ye(s, s));
+ for (e.__k = Array(i), a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o == "string" || typeof o == "number" || typeof o == "bigint" || o.constructor == String ? o = e.__k[a] = ne(null, o, null, null, null) : A(o) ? o = e.__k[a] = ne(N, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = ne(o.type, o.props, o.key, o.ref ? o.ref : null, o.__v) : e.__k[a] = o, c = a + f, o.__ = e, o.__b = e.__b + 1, s = null, (l = o.__i = ue(o, n, c, d)) != -1 && (d--, (s = n[l]) && (s.__u |= 2)), s == null || s.__v == null ? (l == -1 && (i > u ? f-- : i < u && f++), typeof o.type != "function" && (o.__u |= 4)) : l != c && (l == c - 1 ? f-- : l == c + 1 ? f++ : (l > c ? f-- : f++, o.__u |= 4))) : e.__k[a] = null;
+ if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = F(s)), be(s, s));
return r;
}
-function ce(e, t, n) {
+function le(e, t, n) {
var r, i;
if (typeof e.type == "function") {
- for (r = e.__k, i = 0; r && i < r.length; i++) r[i] && (r[i].__ = e, t = ce(r[i], t, n));
+ for (r = e.__k, i = 0; r && i < r.length; i++) r[i] && (r[i].__ = e, t = le(r[i], t, n));
return t;
}
- e.__e != t && (t && e.type && !t.parentNode && (t = P(e)), t = n.insertBefore(e.__e, t || null));
+ e.__e != t && (t && e.type && !t.parentNode && (t = F(e)), t = n.insertBefore(e.__e, t || null));
do
t &&= t.nextSibling;
while (t != null && t.nodeType == 8);
return t;
}
-function le(e, t, n, r) {
+function ue(e, t, n, r) {
var i, a, o, s = e.key, c = e.type, l = t[n], u = l != null && !(2 & l.__u);
if (l === null && s == null || u && s == l.key && c == l.type) return n;
if (r > +!!u) {
@@ -96,18 +96,18 @@ function le(e, t, n, r) {
}
return -1;
}
-function ue(e, t, n) {
- t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || O.test(t) ? n : n + "px";
+function de(e, t, n) {
+ t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || ee.test(t) ? n : n + "px";
}
-function de(e, t, n, r, i) {
+function fe(e, t, n, r, i) {
var a, o;
n: if (t == "style") {
if (typeof n == "string") e.style.cssText = n;
else {
- if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || ue(e.style, t, "");
- if (n) for (t in n) r && n[t] == r[t] || ue(e.style, t, n[t]);
+ if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || de(e.style, t, "");
+ if (n) for (t in n) r && n[t] == r[t] || de(e.style, t, n[t]);
}
- } else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(S, "$1")), o = t.toLowerCase(), t = o in e || t == "onFocusOut" || t == "onFocusIn" ? o.slice(2) : t.slice(2), e.l ||= {}, e.l[t + a] = n, n ? r ? n[x] = r[x] : (n[x] = C, e.addEventListener(t, a ? T : w, a)) : e.removeEventListener(t, a ? T : w, a);
+ } else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(w, "$1")), o = t.toLowerCase(), t = o in e || t == "onFocusOut" || t == "onFocusIn" ? o.slice(2) : t.slice(2), e.l ||= {}, e.l[t + a] = n, n ? r ? n[C] = r[C] : (n[C] = T, e.addEventListener(t, a ? D : E, a)) : e.removeEventListener(t, a ? D : E, a);
else {
if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t != "popover" && t in e) try {
@@ -117,72 +117,72 @@ function de(e, t, n, r, i) {
typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
}
}
-function fe(e) {
+function pe(e) {
return function(t) {
if (this.l) {
var n = this.l[t.type + e];
- if (t[b] == null) t[b] = C++;
- else if (t[b] < n[x]) return;
- return n(f.event ? f.event(t) : t);
+ if (t[S] == null) t[S] = T++;
+ else if (t[S] < n[C]) return;
+ return n(m.event ? m.event(t) : t);
}
};
}
-function pe(e, t, n, r, i, a, o, s, c, l) {
- var u, d, p, m, h, g, _, v, y, b, x, S, C, w, T, E, O = t.type;
+function me(e, t, n, r, i, a, o, s, c, l) {
+ var u, d, f, p, h, g, _, v, y, b, x, S, C, w, T, E, D = t.type;
if (t.constructor !== void 0) return null;
- 128 & n.__u && (c = !!(32 & n.__u), a = [s = t.__e = n.__e]), (u = f.__b) && u(t);
- n: if (typeof O == "function") {
+ 128 & n.__u && (c = !!(32 & n.__u), a = [s = t.__e = n.__e]), (u = m.__b) && u(t);
+ n: if (typeof D == "function") {
d = o.length;
try {
- if (y = t.props, b = O.prototype && O.prototype.render, x = (u = O.contextType) && r[u.__c], S = u ? x ? x.props.value : u.__ : r, n.__c ? v = (p = t.__c = n.__c).__ = p.__E : (b ? t.__c = p = new O(y, S) : (t.__c = p = new N(y, S), p.constructor = O, p.render = be), x && x.sub(p), p.state || (p.state = {}), p.__n = r, m = p.__d = !0, p.__h = [], p._sb = []), b && p.__s == null && (p.__s = p.state), b && O.getDerivedStateFromProps != null && (p.__s == p.state && (p.__s = A({}, p.__s)), A(p.__s, O.getDerivedStateFromProps(y, p.__s))), h = p.props, g = p.state, p.__v = t, m) b && O.getDerivedStateFromProps == null && p.componentWillMount != null && p.componentWillMount(), b && p.componentDidMount != null && p.__h.push(p.componentDidMount);
+ if (y = t.props, b = D.prototype && D.prototype.render, x = (u = D.contextType) && r[u.__c], S = u ? x ? x.props.value : u.__ : r, n.__c ? v = (f = t.__c = n.__c).__ = f.__E : (b ? t.__c = f = new D(y, S) : (t.__c = f = new P(y, S), f.constructor = D, f.render = xe), x && x.sub(f), f.state || (f.state = {}), f.__n = r, p = f.__d = !0, f.__h = [], f._sb = []), b && f.__s == null && (f.__s = f.state), b && D.getDerivedStateFromProps != null && (f.__s == f.state && (f.__s = j({}, f.__s)), j(f.__s, D.getDerivedStateFromProps(y, f.__s))), h = f.props, g = f.state, f.__v = t, p) b && D.getDerivedStateFromProps == null && f.componentWillMount != null && f.componentWillMount(), b && f.componentDidMount != null && f.__h.push(f.componentDidMount);
else {
- if (b && O.getDerivedStateFromProps == null && y !== h && p.componentWillReceiveProps != null && p.componentWillReceiveProps(y, S), t.__v == n.__v || !p.__e && p.shouldComponentUpdate != null && !1 === p.shouldComponentUpdate(y, p.__s, S)) {
- t.__v != n.__v && (p.props = y, p.state = p.__s, p.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(e) {
+ if (b && D.getDerivedStateFromProps == null && y !== h && f.componentWillReceiveProps != null && f.componentWillReceiveProps(y, S), t.__v == n.__v || !f.__e && f.shouldComponentUpdate != null && !1 === f.shouldComponentUpdate(y, f.__s, S)) {
+ t.__v != n.__v && (f.props = y, f.state = f.__s, f.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(e) {
e && (e.__ = t);
- }), D.push.apply(p.__h, p._sb), p._sb = [], p.__h.length && o.push(p), s = P(n);
+ }), k.push.apply(f.__h, f._sb), f._sb = [], f.__h.length && o.push(f), s = F(n);
break n;
}
- p.componentWillUpdate != null && p.componentWillUpdate(y, p.__s, S), b && p.componentDidUpdate != null && p.__h.push(function() {
- p.componentDidUpdate(h, g, _);
+ f.componentWillUpdate != null && f.componentWillUpdate(y, f.__s, S), b && f.componentDidUpdate != null && f.__h.push(function() {
+ f.componentDidUpdate(h, g, _);
});
}
- if (p.context = S, p.props = y, p.__P = e, p.__e = !1, C = f.__r, w = 0, b) p.state = p.__s, p.__d = !1, C && C(t), u = p.render(p.props, p.state, p.context), D.push.apply(p.__h, p._sb), p._sb = [];
+ if (f.context = S, f.props = y, f.__P = e, f.__e = !1, C = m.__r, w = 0, b) f.state = f.__s, f.__d = !1, C && C(t), u = f.render(f.props, f.state, f.context), k.push.apply(f.__h, f._sb), f._sb = [];
else do
- p.__d = !1, C && C(t), u = p.render(p.props, p.state, p.context), p.state = p.__s;
- while (p.__d && ++w < 25);
- p.state = p.__s, p.getChildContext != null && (r = A(A({}, r), p.getChildContext())), b && !m && p.getSnapshotBeforeUpdate != null && (_ = p.getSnapshotBeforeUpdate(h, g)), T = u != null && u.type === M && u.key == null ? ge(u.props.children) : u, s = oe(e, k(T) ? T : [T], t, n, r, i, a, o, s, c, l), p.base = t.__e, t.__u &= -161, p.__h.length && o.push(p), v && (p.__E = p.__ = null);
+ f.__d = !1, C && C(t), u = f.render(f.props, f.state, f.context), f.state = f.__s;
+ while (f.__d && ++w < 25);
+ f.state = f.__s, f.getChildContext != null && (r = j(j({}, r), f.getChildContext())), b && !p && f.getSnapshotBeforeUpdate != null && (_ = f.getSnapshotBeforeUpdate(h, g)), T = u != null && u.type === N && u.key == null ? _e(u.props.children) : u, s = se(e, A(T) ? T : [T], t, n, r, i, a, o, s, c, l), f.base = t.__e, t.__u &= -161, f.__h.length && o.push(f), v && (f.__E = f.__ = null);
} catch (e) {
if (o.length = d, t.__v = null, c || a != null) {
if (e.then) {
for (t.__u |= c ? 160 : 128; s && s.nodeType == 8 && s.nextSibling;) s = s.nextSibling;
a != null && (a[a.indexOf(s)] = null), t.__e = s;
- } else if (a != null) for (E = a.length; E--;) ee(a[E]);
+ } else if (a != null) for (E = a.length; E--;) M(a[E]);
} else t.__e = n.__e;
- t.__k ??= n.__k || [], e.then || me(t), f.__e(e, t, n);
+ t.__k ??= n.__k || [], e.then || he(t), m.__e(e, t, n);
}
- } else a == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : s = t.__e = _e(n.__e, t, n, r, i, a, o, c, l);
- return (u = f.diffed) && u(t), 128 & t.__u ? void 0 : s;
+ } else a == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : s = t.__e = ve(n.__e, t, n, r, i, a, o, c, l);
+ return (u = m.diffed) && u(t), 128 & t.__u ? void 0 : s;
}
-function me(e) {
- e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(me));
+function he(e) {
+ e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(he));
}
-function he(e, t, n) {
- for (var r = 0; r < n.length; r++) ve(n[r], n[++r], n[++r]);
- f.__c && f.__c(t, e), e.some(function(t) {
+function ge(e, t, n) {
+ for (var r = 0; r < n.length; r++) ye(n[r], n[++r], n[++r]);
+ m.__c && m.__c(t, e), e.some(function(t) {
try {
e = t.__h, t.__h = [], e.some(function(e) {
e.call(t);
});
} catch (e) {
- f.__e(e, t.__v);
+ m.__e(e, t.__v);
}
});
}
-function ge(e) {
- return typeof e != "object" || !e || e.__b > 0 ? e : k(e) ? e.map(ge) : e.constructor === void 0 ? A({}, e) : null;
+function _e(e) {
+ return typeof e != "object" || !e || e.__b > 0 ? e : A(e) ? e.map(_e) : e.constructor === void 0 ? j({}, e) : null;
}
-function _e(e, t, n, r, i, a, o, s, c) {
- var l, u, p, m, h, g, _, v = n.props || E, y = t.props, b = t.type;
+function ve(e, t, n, r, i, a, o, s, c) {
+ var l, u, d, f, h, g, _, v = n.props || O, y = t.props, b = t.type;
if (b == "svg" ? i = "http://www.w3.org/2000/svg" : b == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i ||= "http://www.w3.org/1999/xhtml", a != null) {
for (l = 0; l < a.length; l++) if ((h = a[l]) && "setAttribute" in h == !!b && (b ? h.localName == b : h.nodeType == 3)) {
e = h, a[l] = null;
@@ -191,75 +191,75 @@ function _e(e, t, n, r, i, a, o, s, c) {
}
if (e == null) {
if (b == null) return document.createTextNode(y);
- e = document.createElementNS(i, b, y.is && y), s &&= (f.__m && f.__m(t, a), !1), a = null;
+ e = document.createElementNS(i, b, y.is && y), s &&= (m.__m && m.__m(t, a), !1), a = null;
}
if (b == null) v === y || s && e.data == y || (e.data = y);
else {
- if (a = b == "textarea" && y.defaultValue != null ? null : a && d.call(e.childNodes), !s && a != null) for (v = {}, l = 0; l < e.attributes.length; l++) v[(h = e.attributes[l]).name] = h.value;
- for (l in v) h = v[l], l == "dangerouslySetInnerHTML" ? p = h : l == "children" || l in y || l == "value" && "defaultValue" in y || l == "checked" && "defaultChecked" in y || de(e, l, null, h, i);
- for (l in y) h = y[l], l == "children" ? m = h : l == "dangerouslySetInnerHTML" ? u = h : l == "value" ? g = h : l == "checked" ? _ = h : s && typeof h != "function" || v[l] === h || de(e, l, h, v[l], i);
- if (u) s || p && (u.__html == p.__html || u.__html == e.innerHTML) || (e.innerHTML = u.__html), t.__k = [];
- else if (p && (e.innerHTML = ""), oe(t.type == "template" ? e.content : e, k(m) ? m : [m], t, n, r, b == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, a, o, a ? a[0] : n.__k && P(n, 0), s, c), a != null) for (l = a.length; l--;) ee(a[l]);
- s && b != "textarea" || (l = "value", b == "progress" && g == null ? e.removeAttribute("value") : g != null && (g !== e[l] || b == "progress" && !g || b == "option" && g != v[l]) && de(e, l, g, v[l], i), l = "checked", _ != null && _ != e[l] && de(e, l, _, v[l], i));
+ if (a = b == "textarea" && y.defaultValue != null ? null : a && p.call(e.childNodes), !s && a != null) for (v = {}, l = 0; l < e.attributes.length; l++) v[(h = e.attributes[l]).name] = h.value;
+ for (l in v) h = v[l], l == "dangerouslySetInnerHTML" ? d = h : l == "children" || l in y || l == "value" && "defaultValue" in y || l == "checked" && "defaultChecked" in y || fe(e, l, null, h, i);
+ for (l in y) h = y[l], l == "children" ? f = h : l == "dangerouslySetInnerHTML" ? u = h : l == "value" ? g = h : l == "checked" ? _ = h : s && typeof h != "function" || v[l] === h || fe(e, l, h, v[l], i);
+ if (u) s || d && (u.__html == d.__html || u.__html == e.innerHTML) || (e.innerHTML = u.__html), t.__k = [];
+ else if (d && (e.innerHTML = ""), se(t.type == "template" ? e.content : e, A(f) ? f : [f], t, n, r, b == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, a, o, a ? a[0] : n.__k && F(n, 0), s, c), a != null) for (l = a.length; l--;) M(a[l]);
+ s && b != "textarea" || (l = "value", b == "progress" && g == null ? e.removeAttribute("value") : g != null && (g !== e[l] || b == "progress" && !g || b == "option" && g != v[l]) && fe(e, l, g, v[l], i), l = "checked", _ != null && _ != e[l] && fe(e, l, _, v[l], i));
}
return e;
}
-function ve(e, t, n) {
+function ye(e, t, n) {
try {
if (typeof e == "function") {
var r = typeof e.__u == "function";
r && e.__u(), r && t == null || (e.__u = e(t));
} else e.current = t;
} catch (e) {
- f.__e(e, n);
+ m.__e(e, n);
}
}
-function ye(e, t, n) {
+function be(e, t, n) {
var r, i;
- if (f.unmount && f.unmount(e), (r = e.ref) && (r.current && r.current != e.__e || ve(r, null, t)), (r = e.__c) != null) {
+ if (m.unmount && m.unmount(e), (r = e.ref) && (r.current && r.current != e.__e || ye(r, null, t)), (r = e.__c) != null) {
if (r.componentWillUnmount) try {
r.componentWillUnmount();
} catch (e) {
- f.__e(e, t);
+ m.__e(e, t);
}
r.base = r.__P = r.__n = null;
}
- if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && ye(r[i], t, n || typeof e.type != "function");
- n || ee(e.__e), e.__c = e.__ = e.__e = void 0;
+ if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && be(r[i], t, n || typeof e.type != "function");
+ n || M(e.__e), e.__c = e.__ = e.__e = void 0;
}
-function be(e, t, n) {
+function xe(e, t, n) {
return this.constructor(e, n);
}
-function xe(e, t, n) {
+function Se(e, t, n) {
var r, i, a, o;
- t == document && (t = document.documentElement), f.__ && f.__(e, t), i = (r = typeof n == "function") ? null : n && n.__k || t.__k, a = [], o = [], pe(t, e = (!r && n || t).__k = te(M, null, [e]), i || E, E, t.namespaceURI, !r && n ? [n] : i ? null : t.firstChild ? d.call(t.childNodes) : null, a, !r && n ? n : i ? i.__e : t.firstChild, r, o), he(a, e, o), e.props.children = null;
+ t == document && (t = document.documentElement), m.__ && m.__(e, t), i = (r = typeof n == "function") ? null : n && n.__k || t.__k, a = [], o = [], me(t, e = (!r && n || t).__k = te(N, null, [e]), i || O, O, t.namespaceURI, !r && n ? [n] : i ? null : t.firstChild ? p.call(t.childNodes) : null, a, !r && n ? n : i ? i.__e : t.firstChild, r, o), ge(a, e, o), e.props.children = null;
}
-d = D.slice, f = { __e: function(e, t, n, r) {
+p = k.slice, m = { __e: function(e, t, n, r) {
for (var i, a, o; t = t.__;) if ((i = t.__c) && !i.__) try {
if ((a = i.constructor) && a.getDerivedStateFromError != null && (i.setState(a.getDerivedStateFromError(e)), o = i.__d), i.componentDidCatch != null && (i.componentDidCatch(e, r || {}), o = i.__d), o) return i.__E = i;
} catch (t) {
e = t;
}
throw e;
-} }, p = 0, m = function(e) {
+} }, h = 0, g = function(e) {
return e != null && e.constructor === void 0;
-}, N.prototype.setState = function(e, t) {
- var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = A({}, this.state);
- typeof e == "function" && (e = e(A({}, n), this.props)), e && A(n, e), e != null && this.__v && (t && this._sb.push(t), ie(this));
-}, N.prototype.forceUpdate = function(e) {
- this.__v && (this.__e = !0, e && this.__h.push(e), ie(this));
-}, N.prototype.render = M, h = [], _ = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, v = function(e, t) {
+}, P.prototype.setState = function(e, t) {
+ var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = j({}, this.state);
+ typeof e == "function" && (e = e(j({}, n), this.props)), e && j(n, e), e != null && this.__v && (t && this._sb.push(t), ae(this));
+}, P.prototype.forceUpdate = function(e) {
+ this.__v && (this.__e = !0, e && this.__h.push(e), ae(this));
+}, P.prototype.render = N, _ = [], y = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, b = function(e, t) {
return e.__v.__b - t.__v.__b;
-}, ae.__r = 0, y = Math.random().toString(8), b = "__d" + y, x = "__a" + y, S = /(PointerCapture)$|Capture$/i, C = 0, w = fe(!1), T = fe(!0);
+}, oe.__r = 0, x = Math.random().toString(8), S = "__d" + x, C = "__a" + x, w = /(PointerCapture)$|Capture$/i, T = 0, E = pe(!1), D = pe(!0);
//#endregion
//#region src/api.ts
-var Se = class extends Error {
+var Ce = class extends Error {
status;
body;
constructor(e, t, n = null) {
super(e), this.name = "ApiError", this.status = t, this.body = n;
}
-}, Ce = (e) => {
+}, we = (e) => {
if (!e || typeof e != "object") return "";
let t = e;
for (let e of [
@@ -271,8 +271,8 @@ var Se = class extends Error {
if (typeof n == "string" && n) return n;
}
return "";
-}, F = (e) => e instanceof Error ? e.message : String(e);
-async function I(e, t) {
+}, I = (e) => e instanceof Error ? e.message : String(e);
+async function L(e, t) {
let n = await fetch(e, {
headers: { Accept: "application/json" },
credentials: "same-origin",
@@ -281,10 +281,10 @@ async function I(e, t) {
try {
r = await n.json();
} catch {}
- if (!n.ok) throw new Se(Ce(r) || `请求失败(${n.status})`, n.status);
+ if (!n.ok) throw new Ce(we(r) || `请求失败(${n.status})`, n.status);
return r;
}
-async function L(e, t, n = "POST", r) {
+async function R(e, t, n = "POST", r) {
let i = await fetch(e, {
method: n,
...r ? { signal: r } : {},
@@ -298,29 +298,29 @@ async function L(e, t, n = "POST", r) {
try {
a = await i.json();
} catch {}
- if (!i.ok) throw new Se(Ce(a) || `请求失败(${i.status})`, i.status, a);
+ if (!i.ok) throw new Ce(we(a) || `请求失败(${i.status})`, i.status, a);
return a;
}
//#endregion
//#region node_modules/preact/hooks/dist/hooks.module.js
-var R, z, we, Te, Ee = 0, De = [], B = f, Oe = B.__b, ke = B.__r, Ae = B.diffed, je = B.__c, Me = B.unmount, Ne = B.__;
-function Pe(e, t) {
- B.__h && B.__h(z, e, Ee || t), Ee = 0;
- var n = z.__H || (z.__H = {
+var z, B, Te, Ee, De = 0, Oe = [], V = m, ke = V.__b, Ae = V.__r, je = V.diffed, Me = V.__c, Ne = V.unmount, Pe = V.__;
+function Fe(e, t) {
+ V.__h && V.__h(B, e, De || t), De = 0;
+ var n = B.__H || (B.__H = {
__: [],
__h: []
});
return e >= n.__.length && n.__.push({}), n.__[e];
}
-function V(e) {
- return Ee = 1, Fe(We, e);
+function H(e) {
+ return De = 1, Ie(Ge, e);
}
-function Fe(e, t, n) {
- var r = Pe(R++, 2);
- if (r.t = e, !r.__c && (r.__ = [n ? n(t) : We(void 0, t), function(e) {
+function Ie(e, t, n) {
+ var r = Fe(z++, 2);
+ if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Ge(void 0, t), function(e) {
var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
t !== n && (r.__N = [n, r.__[1]], r.__c.setState({}));
- }], r.__c = z, !z.__f)) {
+ }], r.__c = B, !B.__f)) {
var i = function(e, t, n) {
if (!r.__c.__H) return !0;
var i = !1, o = r.__c.props !== e;
@@ -336,112 +336,112 @@ function Fe(e, t, n) {
}
return !i || o;
};
- z.__f = !0;
- var a = z.shouldComponentUpdate, o = z.componentWillUpdate;
- z.componentWillUpdate = function(e, t, n) {
+ B.__f = !0;
+ var a = B.shouldComponentUpdate, o = B.componentWillUpdate;
+ B.componentWillUpdate = function(e, t, n) {
if (this.__e) {
var r = a;
a = void 0, i(e, t, n), a = r;
}
o && o.call(this, e, t, n);
- }, z.shouldComponentUpdate = i;
+ }, B.shouldComponentUpdate = i;
}
return r.__N || r.__;
}
-function Ie(e, t) {
- var n = Pe(R++, 3);
- !B.__s && Ue(n.__H, t) && (n.__ = e, n.u = t, z.__H.__h.push(n));
+function Le(e, t) {
+ var n = Fe(z++, 3);
+ !V.__s && We(n.__H, t) && (n.__ = e, n.u = t, B.__H.__h.push(n));
}
-function H(e, t) {
- var n = Pe(R++, 4);
- !B.__s && Ue(n.__H, t) && (n.__ = e, n.u = t, z.__h.push(n));
+function U(e, t) {
+ var n = Fe(z++, 4);
+ !V.__s && We(n.__H, t) && (n.__ = e, n.u = t, B.__h.push(n));
}
-function U(e) {
- return Ee = 5, Le(function() {
+function W(e) {
+ return De = 5, Re(function() {
return { current: e };
}, []);
}
-function Le(e, t) {
- var n = Pe(R++, 7);
- return Ue(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
+function Re(e, t) {
+ var n = Fe(z++, 7);
+ return We(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
}
-function Re() {
- for (var e; e = De.shift();) {
+function ze() {
+ for (var e; e = Oe.shift();) {
var t = e.__H;
if (e.__P && t) try {
- t.__h.some(Ve), t.__h.some(He), t.__h = [];
+ t.__h.some(He), t.__h.some(Ue), t.__h = [];
} catch (n) {
- t.__h = [], B.__e(n, e.__v);
+ t.__h = [], V.__e(n, e.__v);
}
}
}
-B.__b = function(e) {
- z = null, Oe && Oe(e);
-}, B.__ = function(e, t) {
- e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Ne && Ne(e, t);
-}, B.__r = function(e) {
- ke && ke(e), R = 0;
- var t = (z = e.__c).__H;
- t && (we === z ? (t.__h = [], z.__h = [], t.__.some(function(e) {
+V.__b = function(e) {
+ B = null, ke && ke(e);
+}, V.__ = function(e, t) {
+ e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Pe && Pe(e, t);
+}, V.__r = function(e) {
+ Ae && Ae(e), z = 0;
+ var t = (B = e.__c).__H;
+ t && (Te === B ? (t.__h = [], B.__h = [], t.__.some(function(e) {
e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
- })) : (t.__h.some(Ve), t.__h.some(He), t.__h = [], R = 0)), we = z;
-}, B.diffed = function(e) {
- Ae && Ae(e);
+ })) : (t.__h.some(He), t.__h.some(Ue), t.__h = [], z = 0)), Te = B;
+}, V.diffed = function(e) {
+ je && je(e);
var t = e.__c;
- t && t.__H && (t.__H.__h.length && (De.push(t) !== 1 && Te === B.requestAnimationFrame || ((Te = B.requestAnimationFrame) || Be)(Re)), t.__H.__.some(function(e) {
+ t && t.__H && (t.__H.__h.length && (Oe.push(t) !== 1 && Ee === V.requestAnimationFrame || ((Ee = V.requestAnimationFrame) || Ve)(ze)), t.__H.__.some(function(e) {
e.u &&= (e.__H = e.u, void 0);
- })), we = z = null;
-}, B.__c = function(e, t) {
+ })), Te = B = null;
+}, V.__c = function(e, t) {
t.some(function(e) {
try {
- e.__h.some(Ve), e.__h = e.__h.filter(function(e) {
- return !e.__ || He(e);
+ e.__h.some(He), e.__h = e.__h.filter(function(e) {
+ return !e.__ || Ue(e);
});
} catch (n) {
t.some(function(e) {
e.__h &&= [];
- }), t = [], B.__e(n, e.__v);
+ }), t = [], V.__e(n, e.__v);
}
- }), je && je(e, t);
-}, B.unmount = function(e) {
- Me && Me(e);
+ }), Me && Me(e, t);
+}, V.unmount = function(e) {
+ Ne && Ne(e);
var t, n = e.__c;
n && n.__H && (n.__H.__.some(function(e) {
try {
- Ve(e);
+ He(e);
} catch (e) {
t = e;
}
- }), n.__H = void 0, t && B.__e(t, n.__v));
+ }), n.__H = void 0, t && V.__e(t, n.__v));
};
-var ze = typeof requestAnimationFrame == "function";
-function Be(e) {
+var Be = typeof requestAnimationFrame == "function";
+function Ve(e) {
var t, n = function() {
- clearTimeout(r), ze && cancelAnimationFrame(t), setTimeout(e);
+ clearTimeout(r), Be && cancelAnimationFrame(t), setTimeout(e);
}, r = setTimeout(n, 35);
- ze && (t = requestAnimationFrame(n));
-}
-function Ve(e) {
- var t = z, n = e.__c;
- typeof n == "function" && (e.__c = void 0, n()), z = t;
+ Be && (t = requestAnimationFrame(n));
}
function He(e) {
- var t = z;
- e.__c = e.__(), z = t;
+ var t = B, n = e.__c;
+ typeof n == "function" && (e.__c = void 0, n()), B = t;
}
-function Ue(e, t) {
+function Ue(e) {
+ var t = B;
+ e.__c = e.__(), B = t;
+}
+function We(e, t) {
return !e || e.length !== t.length || t.some(function(t, n) {
return t !== e[n];
});
}
-function We(e, t) {
+function Ge(e, t) {
return typeof t == "function" ? t(e) : t;
}
//#endregion
//#region node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
-var Ge = 0;
+var Ke = 0;
Array.isArray;
-function W(e, t, n, r, i, a) {
+function G(e, t, n, r, i, a) {
t ||= {};
var o, s, c = t;
if ("ref" in c) for (s in c = {}, t) s == "ref" ? o = t[s] : c[s] = t[s];
@@ -456,26 +456,26 @@ function W(e, t, n, r, i, a) {
__e: null,
__c: null,
constructor: void 0,
- __v: --Ge,
+ __v: --Ke,
__i: -1,
__u: 0,
__source: i,
__self: a
};
if (typeof e == "function" && (o = e.defaultProps)) for (s in o) c[s] === void 0 && (c[s] = o[s]);
- return f.vnode && f.vnode(l), l;
+ return m.vnode && m.vnode(l), l;
}
//#endregion
//#region src/islands/access-settings.tsx
-function Ke({ id: e, label: t, value: n, onInput: r, error: i, help: a, current: o = !1 }) {
- return /* @__PURE__ */ W("div", {
+function qe({ id: e, label: t, value: n, onInput: r, error: i, help: a, current: o = !1 }) {
+ return /* @__PURE__ */ G("div", {
class: "configfield",
children: [
- /* @__PURE__ */ W("label", {
+ /* @__PURE__ */ G("label", {
for: e,
children: t
}),
- /* @__PURE__ */ W("input", {
+ /* @__PURE__ */ G("input", {
id: e,
class: "geist-input",
type: "password",
@@ -487,7 +487,7 @@ function Ke({ id: e, label: t, value: n, onInput: r, error: i, help: a, current:
"aria-invalid": !!i,
"aria-describedby": i || a ? `${e}-hint` : void 0
}),
- i || a ? /* @__PURE__ */ W("p", {
+ i || a ? /* @__PURE__ */ G("p", {
id: `${e}-hint`,
class: i ? "configbad" : "confighelp",
role: i ? "alert" : void 0,
@@ -496,97 +496,97 @@ function Ke({ id: e, label: t, value: n, onInput: r, error: i, help: a, current:
]
});
}
-function qe({ initial: e, receipt: t }) {
- let [r, i] = V(e), [a, s] = V(""), [c, l] = V(""), [u, d] = V(""), [f, p] = V(!1), [m, h] = V(""), [g, _] = V({}), v = U(null), y = U(!1), b = U(null);
- return /* @__PURE__ */ W("form", {
+function Je({ initial: e, receipt: t }) {
+ let [r, i] = H(e), [a, o] = H(""), [s, l] = H(""), [u, d] = H(""), [f, p] = H(!1), [m, h] = H(""), [g, _] = H({}), v = W(null), y = W(!1), b = W(null);
+ return /* @__PURE__ */ G("form", {
class: "configfieldset",
onSubmit: async (e) => {
if (e.preventDefault(), y.current) return;
h("");
let n = {};
- if (r.mode === "password" && !a && (n.current_password = "请输入当前访问密码"), f || ((c.length < 8 || c.length > 256) && (n.password = "访问密码需为 8–256 个字符"), c !== u && (n.confirmation = "两次输入的密码不一致")), _(n), Object.keys(n).length) {
+ if (r.mode === "password" && !a && (n.current_password = "请输入当前访问密码"), f || ((s.length < 8 || s.length > 256) && (n.password = "访问密码需为 8–256 个字符"), s !== u && (n.confirmation = "两次输入的密码不一致")), _(n), Object.keys(n).length) {
requestAnimationFrame(() => v.current?.querySelector("[aria-invalid=\"true\"]")?.focus());
return;
}
- y.current = !0, o(b.current, !0);
+ y.current = !0, c(b.current, !0);
try {
- let e = await L("/api/configuration/access", {
+ let e = await R("/api/configuration/access", {
revision: r.revision,
action: f ? "disable" : "set",
confirm_disable: f,
current_password: a,
- password: f ? "" : c,
+ password: f ? "" : s,
confirmation: f ? "" : u
});
- i(e), s(""), l(""), d(""), p(!1), _({}), t(e.mode === "open" ? "已关闭访问密码" : "已保存访问密码");
+ i(e), o(""), l(""), d(""), p(!1), _({}), t(e.mode === "open" ? "已关闭访问密码" : "已保存访问密码");
} catch (e) {
- let t = e instanceof Se ? e.body : null, n = t?.errors || t?.detail?.errors;
- n ? _(n) : h(F(e));
+ let t = e instanceof Ce ? e.body : null, n = t?.errors || t?.detail?.errors;
+ n ? _(n) : h(I(e));
} finally {
- y.current = !1, o(b.current, !1);
+ y.current = !1, c(b.current, !1);
}
},
"aria-labelledby": "accessTitle",
noValidate: !0,
ref: v,
- children: [/* @__PURE__ */ W("div", {
+ children: [/* @__PURE__ */ G("div", {
class: "geist-fieldset-content",
children: [
- /* @__PURE__ */ W("div", {
+ /* @__PURE__ */ G("div", {
class: "configfieldset-heading",
- children: [/* @__PURE__ */ W("div", { dangerouslySetInnerHTML: { __html: n("accessTitle", "访问密码") } }), /* @__PURE__ */ W("p", {
+ children: [/* @__PURE__ */ G("div", { dangerouslySetInnerHTML: { __html: n("accessTitle", "访问密码") } }), /* @__PURE__ */ G("p", {
class: "confighelp",
children: r.mode === "open" ? "未设置密码,能连接到 Peach 的设备可直接访问。" : r.mode === "legacy" ? "当前使用系统生成的访问口令。你可以设置自己的密码,或关闭登录要求。" : r.mode === "locked" ? "访问设置无法读取,请在本机检查配置文件。" : "已设置密码。新设备需要登录,保持登录时间在登录页选择。"
})]
}),
- r.mode === "password" ? /* @__PURE__ */ W(Ke, {
+ r.mode === "password" ? /* @__PURE__ */ G(qe, {
id: "access-current",
label: "当前访问密码",
value: a,
- onInput: s,
+ onInput: o,
error: g.current_password,
current: !0
}) : null,
- !f && r.mode !== "locked" ? /* @__PURE__ */ W(M, { children: [/* @__PURE__ */ W(Ke, {
+ !f && r.mode !== "locked" ? /* @__PURE__ */ G(N, { children: [/* @__PURE__ */ G(qe, {
id: "access-password",
label: r.mode === "password" ? "新访问密码" : "设置访问密码",
- value: c,
+ value: s,
onInput: l,
error: g.password,
help: "至少 8 个字符。保存后其他设备需要重新登录。"
- }), /* @__PURE__ */ W(Ke, {
+ }), /* @__PURE__ */ G(qe, {
id: "access-confirm",
label: "确认访问密码",
value: u,
onInput: d,
error: g.confirmation
})] }) : null,
- r.mode === "password" || r.mode === "legacy" ? /* @__PURE__ */ W("label", {
+ r.mode === "password" || r.mode === "legacy" ? /* @__PURE__ */ G("label", {
class: "configcheck",
- children: [/* @__PURE__ */ W("span", {
+ children: [/* @__PURE__ */ G("span", {
class: "pcheck",
- children: [/* @__PURE__ */ W("input", {
+ children: [/* @__PURE__ */ G("input", {
type: "checkbox",
checked: f,
onChange: (e) => p(e.currentTarget.checked)
- }), /* @__PURE__ */ W("span", {
+ }), /* @__PURE__ */ G("span", {
"aria-hidden": "true",
- children: /* @__PURE__ */ W("svg", {
+ children: /* @__PURE__ */ G("svg", {
viewBox: "0 0 24 24",
- children: /* @__PURE__ */ W("use", { href: "#i-check" })
+ children: /* @__PURE__ */ G("use", { href: "#i-check" })
})
})]
- }), /* @__PURE__ */ W("span", { children: "关闭访问密码,允许能连接到 Peach 的设备直接访问" })]
+ }), /* @__PURE__ */ G("span", { children: "关闭访问密码,允许能连接到 Peach 的设备直接访问" })]
}) : null,
- m ? /* @__PURE__ */ W("p", {
+ m ? /* @__PURE__ */ G("p", {
class: "configbad",
role: "alert",
children: m
}) : null
]
- }), r.mode === "locked" ? null : /* @__PURE__ */ W("div", {
+ }), r.mode === "locked" ? null : /* @__PURE__ */ G("div", {
class: "geist-fieldset-footer",
- children: [/* @__PURE__ */ W("p", { children: "保存后立即生效。" }), /* @__PURE__ */ W("button", {
+ children: [/* @__PURE__ */ G("p", { children: "保存后立即生效。" }), /* @__PURE__ */ G("button", {
class: "geist-button primary",
type: "submit",
ref: b,
@@ -597,29 +597,29 @@ function qe({ initial: e, receipt: t }) {
}
//#endregion
//#region src/islands/configuration.tsx
-var Je = "/api/configuration", Ye = "/api/pick-folder", Xe = 8e3, Ze = (e, t) => I(Je, t), G = ({ html: e, class: t }) => /* @__PURE__ */ W("div", {
+var Ye = "/api/configuration", Xe = "/api/pick-folder", Ze = 8e3, Qe = (e, t) => L(Ye, t), K = ({ html: e, class: t }) => /* @__PURE__ */ G("div", {
class: t,
dangerouslySetInnerHTML: { __html: e }
-}), Qe = (e) => !(e instanceof Se) || e.status !== 400 ? null : e.body?.errors ?? null;
-function $e({ facts: e }) {
- return /* @__PURE__ */ W("section", {
+}), $e = (e) => !(e instanceof Ce) || e.status !== 400 ? null : e.body?.errors ?? null;
+function et({ facts: e }) {
+ return /* @__PURE__ */ G("section", {
class: "configfieldset",
"data-geist-fieldset": !0,
"aria-labelledby": "configFactsTitle",
- children: /* @__PURE__ */ W("div", {
+ children: /* @__PURE__ */ G("div", {
class: "geist-fieldset-content",
- children: [/* @__PURE__ */ W(G, { html: n("configFactsTitle", "运行信息") }), /* @__PURE__ */ W("dl", {
+ children: [/* @__PURE__ */ G(K, { html: n("configFactsTitle", "运行信息") }), /* @__PURE__ */ G("dl", {
class: "configfacts",
- children: e.map((e) => /* @__PURE__ */ W(M, { children: [/* @__PURE__ */ W("dt", { children: e.term }), /* @__PURE__ */ W("dd", { children: [e.value, e.download_url ? /* @__PURE__ */ W("span", {
+ children: e.map((e) => /* @__PURE__ */ G(N, { children: [/* @__PURE__ */ G("dt", { children: e.term }), /* @__PURE__ */ G("dd", { children: [e.value, e.download_url ? /* @__PURE__ */ G("span", {
class: "confighelp",
- children: [" ", /* @__PURE__ */ W("a", {
+ children: [" ", /* @__PURE__ */ G("a", {
href: e.download_url,
target: "_blank",
rel: "noreferrer",
- children: [e.download_label, /* @__PURE__ */ W("svg", {
+ children: [e.download_label, /* @__PURE__ */ G("svg", {
"aria-hidden": "true",
viewBox: "0 0 24 24",
- children: /* @__PURE__ */ W("use", { href: "#i-external-link" })
+ children: /* @__PURE__ */ G("use", { href: "#i-external-link" })
})]
})]
}) : null] })] }))
@@ -627,57 +627,57 @@ function $e({ facts: e }) {
})
});
}
-function et({ data: t }) {
- let [r, i] = V(t.media_sources), [s, c] = V(""), l = U(null);
- Ie(() => () => l.current?.abort(), []);
+function tt({ data: t }) {
+ let [r, i] = H(t.media_sources), [a, o] = H(""), l = W(null);
+ Le(() => () => l.current?.abort(), []);
let u = async (e) => {
if (l.current) return;
let t = new AbortController();
- l.current = t, o(e, !0), c("");
+ l.current = t, c(e, !0), o("");
try {
- let e = await I(Je, t.signal);
+ let e = await L(Ye, t.signal);
t.signal.aborted || i(e.media_sources);
} catch (e) {
- t.signal.aborted || c(F(e));
+ t.signal.aborted || o(I(e));
} finally {
- l.current = null, o(e, !1);
+ l.current = null, c(e, !1);
}
};
- return r ? /* @__PURE__ */ W("section", {
+ return r ? /* @__PURE__ */ G("section", {
class: "configfieldset",
"aria-labelledby": "configMountsTitle",
- children: [/* @__PURE__ */ W("div", {
+ children: [/* @__PURE__ */ G("div", {
class: "geist-fieldset-content",
children: [
- /* @__PURE__ */ W(G, { html: n("configMountsTitle", "挂载状态") }),
- /* @__PURE__ */ W("dl", {
+ /* @__PURE__ */ G(K, { html: n("configMountsTitle", "挂载状态") }),
+ /* @__PURE__ */ G("dl", {
class: "configfacts",
- children: r.map((t) => /* @__PURE__ */ W(M, { children: [/* @__PURE__ */ W("dt", { children: [/* @__PURE__ */ W("span", {
+ children: r.map((t) => /* @__PURE__ */ G(N, { children: [/* @__PURE__ */ G("dt", { children: [/* @__PURE__ */ G("span", {
"aria-hidden": "true",
- dangerouslySetInnerHTML: { __html: a(e[t.location]) }
+ dangerouslySetInnerHTML: { __html: s(e[t.location]) }
}), {
local: "本地磁盘",
115: "CloudDrive · 115",
pikpak: "CloudDrive · PikPak"
- }[t.location] || t.location] }), /* @__PURE__ */ W("dd", { children: [
+ }[t.location] || t.location] }), /* @__PURE__ */ G("dd", { children: [
t.path || "未配置挂载点",
" ",
- /* @__PURE__ */ W("span", {
+ /* @__PURE__ */ G("span", {
class: `configstatus ${t.online === !0 ? "online" : t.online === !1 ? "offline" : "unknown"}`,
children: t.online === !0 ? "在线" : t.online === !1 ? "离线" : "未检测"
})
] })] }))
}),
- s ? /* @__PURE__ */ W("p", {
+ a ? /* @__PURE__ */ G("p", {
class: "configbad",
role: "alert",
- children: s
+ children: a
}) : null
]
- }), /* @__PURE__ */ W("div", {
+ }), /* @__PURE__ */ G("div", {
class: "geist-fieldset-footer",
"data-geist-fieldset-footer": !0,
- children: /* @__PURE__ */ W("button", {
+ children: /* @__PURE__ */ G("button", {
type: "button",
class: "geist-button",
onClick: (e) => u(e.currentTarget),
@@ -686,11 +686,11 @@ function et({ data: t }) {
})]
}) : null;
}
-function tt({ value: t, label: n, onChange: r }) {
- let a = U(null), o = U(null), c = U(r);
- return c.current = r, H(() => {
- let r = a.current;
- r.innerHTML = i([
+function nt({ value: t, label: n, onChange: r }) {
+ let i = W(null), a = W(null), s = W(r);
+ return s.current = r, U(() => {
+ let r = i.current;
+ r.innerHTML = o([
["local", "本地磁盘"],
["115", "CloudDrive · 115"],
["pikpak", "CloudDrive · PikPak"]
@@ -699,90 +699,90 @@ function tt({ value: t, label: n, onChange: r }) {
n,
e[t]
]), t, { label: n });
- let l = s(r.firstElementChild);
- o.current = l;
- let u = () => c.current(l.value);
- return l.addEventListener("change", u), () => {
- o.current = null, l.disabled = !0, l.removeEventListener("change", u), r.replaceChildren();
+ let c = l(r.firstElementChild);
+ a.current = c;
+ let u = () => s.current(c.value);
+ return c.addEventListener("change", u), () => {
+ a.current = null, c.disabled = !0, c.removeEventListener("change", u), r.replaceChildren();
};
- }, [n]), H(() => {
- o.current && (o.current.value = t);
- }, [t]), /* @__PURE__ */ W("div", {
- ref: a,
+ }, [n]), U(() => {
+ a.current && (a.current.value = t);
+ }, [t]), /* @__PURE__ */ G("div", {
+ ref: i,
class: "configsourcecontrol"
});
}
-function nt({ data: e, receipt: t }) {
- let i = e.media_sources?.filter((e) => [
+function rt({ data: e, receipt: t }) {
+ let r = e.media_sources?.filter((e) => [
"local",
"115",
"pikpak"
- ].includes(e.location)), [a, s] = V(i?.length ? i.map((e) => e.path) : e.media_dirs.length ? e.media_dirs : [""]), [c, l] = V(i?.map((e) => e.location) ?? []), [u, d] = V(i?.map((e) => e.root) ?? []), [f, p] = V(String(e.port)), [m, h] = V(!1), [g, _] = V([]), [v, y] = V(""), [b, x] = V(""), [S, C] = V(null), [w, T] = V(null), E = U(!1), D = U(e.revision), O = U([]), k = U(null);
- H(() => {
+ ].includes(e.location)), [a, o] = H(r?.length ? r.map((e) => e.path) : e.media_dirs.length ? e.media_dirs : [""]), [s, l] = H(r?.map((e) => e.location) ?? []), [u, d] = H(r?.map((e) => e.root) ?? []), [f, p] = H(String(e.port)), [m, h] = H(!1), [g, _] = H([]), [v, y] = H(""), [b, x] = H(""), [S, C] = H(null), [w, T] = H(null), E = W(!1), D = W(e.revision), O = W([]), k = W(null);
+ U(() => {
w !== null && (O.current[w]?.focus(), T(null));
- }, [w]), Ie(() => {
+ }, [w]), Le(() => {
if (!S) return;
- let e = setTimeout(() => location.assign(S.url), Xe);
+ let e = setTimeout(() => location.assign(S.url), Ze);
return () => clearTimeout(e);
}, [S]);
- let A = (e, t) => {
- s((n) => n.map((n, r) => r === e ? t : n));
- }, ee = () => {
- T(a.length), s((e) => [...e, ""]);
- }, te = (e) => {
- l((t) => t.filter((t, n) => n !== e)), d((t) => t.filter((t, n) => n !== e)), s((t) => t.filter((t, n) => n !== e)), _((t) => t.filter((t, n) => n !== e));
- }, j = (e, t) => {
+ let ee = (e, t) => {
+ o((n) => n.map((n, r) => r === e ? t : n));
+ }, A = () => {
+ T(a.length), o((e) => [...e, ""]);
+ }, j = (e) => {
+ l((t) => t.filter((t, n) => n !== e)), d((t) => t.filter((t, n) => n !== e)), o((t) => t.filter((t, n) => n !== e)), _((t) => t.filter((t, n) => n !== e));
+ }, M = (e, t) => {
_((n) => {
let r = [...n];
for (; r.length <= e;) r.push("");
return r[e] = t, r;
});
- }, M = async (e, t) => {
+ }, te = async (e, t) => {
if (t.getAttribute("aria-busy") !== "true") {
- o(t, !0);
+ c(t, !0);
try {
- let { path: t } = await L(Ye, { initial: a[e] ?? "" });
- t && (A(e, t), j(e, ""));
+ let { path: t } = await R(Xe, { initial: a[e] ?? "" });
+ t && (ee(e, t), M(e, ""));
} catch (t) {
- j(e, F(t));
+ M(e, I(t));
} finally {
- o(t, !1);
+ c(t, !1);
}
}
};
- return S ? /* @__PURE__ */ W("div", {
+ return S ? /* @__PURE__ */ G("div", {
class: "configsaved",
role: "status",
- children: /* @__PURE__ */ W("div", {
+ children: /* @__PURE__ */ G("div", {
class: "geist-note geist-note-success",
role: "note",
- children: [/* @__PURE__ */ W("svg", {
+ children: [/* @__PURE__ */ G("svg", {
"aria-hidden": "true",
viewBox: "0 0 24 24",
- children: /* @__PURE__ */ W("use", { href: "#i-check" })
- }), /* @__PURE__ */ W("p", { children: /* @__PURE__ */ W("span", { children: [
+ children: /* @__PURE__ */ G("use", { href: "#i-check" })
+ }), /* @__PURE__ */ G("p", { children: /* @__PURE__ */ G("span", { children: [
"配置已保存,Peach 正在重新启动。稍后自动跳转,或点击",
- /* @__PURE__ */ W("a", {
+ /* @__PURE__ */ G("a", {
href: S.url,
children: "进入馆藏"
}),
"。"
] }) })]
})
- }) : /* @__PURE__ */ W("form", {
+ }) : /* @__PURE__ */ G("form", {
class: "configfieldset",
"data-geist-fieldset": !0,
"aria-labelledby": "configTitle",
onSubmit: async (n) => {
if (n.preventDefault(), !E.current) {
- E.current = !0, o(k.current, !0), x("");
+ E.current = !0, c(k.current, !0), x("");
try {
- let n = await L(Je, {
+ let n = await R(Ye, {
revision: D.current,
media_dirs: a,
...e.media_sources ? { media_sources: a.map((e, t) => ({
path: e,
- location: c[t] || "local",
+ location: s[t] || "local",
root: u[t] || ""
})) } : {},
port: f,
@@ -790,83 +790,83 @@ function nt({ data: e, receipt: t }) {
});
D.current = n.revision, _([]), y(""), t("已保存配置"), C(n);
} catch (e) {
- let t = Qe(e);
- t ? (_(t.media_dirs ?? []), y(t.port ?? "")) : (_([]), y(""), x(F(e)));
+ let t = $e(e);
+ t ? (_(t.media_dirs ?? []), y(t.port ?? "")) : (_([]), y(""), x(I(e)));
} finally {
- E.current = !1, o(k.current, !1);
+ E.current = !1, c(k.current, !1);
}
}
},
noValidate: !0,
- children: [/* @__PURE__ */ W("div", {
+ children: [/* @__PURE__ */ G("div", {
class: "geist-fieldset-content",
children: [
- /* @__PURE__ */ W(G, { html: n("configTitle", "这台电脑") }),
- /* @__PURE__ */ W("div", {
+ /* @__PURE__ */ G(K, { html: n("configTitle", "这台电脑") }),
+ /* @__PURE__ */ G("div", {
class: "configfield",
children: [
- /* @__PURE__ */ W("span", {
+ /* @__PURE__ */ G("span", {
class: "configlabel",
id: "configDirsLabel",
children: "媒体文件夹"
}),
- /* @__PURE__ */ W("div", {
+ /* @__PURE__ */ G("div", {
class: "configdirs",
role: "group",
"aria-labelledby": "configDirsLabel",
- children: a.map((t, n) => /* @__PURE__ */ W("div", {
+ children: a.map((t, n) => /* @__PURE__ */ G("div", {
class: "configdir",
children: [
- /* @__PURE__ */ W("span", {
+ /* @__PURE__ */ G("span", {
class: "configpathlabel",
children: ["本机文件夹 ", n + 1]
}),
- /* @__PURE__ */ W("input", {
+ /* @__PURE__ */ G("input", {
class: "geist-input",
type: "text",
value: t,
"aria-label": `媒体文件夹 ${n + 1}`,
"aria-invalid": g[n] ? "true" : void 0,
- onInput: (e) => A(n, e.currentTarget.value),
+ onInput: (e) => ee(n, e.currentTarget.value),
ref: (e) => {
O.current[n] = e;
}
}),
- /* @__PURE__ */ W("button", {
+ /* @__PURE__ */ G("button", {
type: "button",
class: "geist-button configpick",
"aria-label": "选择文件夹",
- onClick: (e) => M(n, e.currentTarget),
- children: /* @__PURE__ */ W("svg", {
+ onClick: (e) => te(n, e.currentTarget),
+ children: /* @__PURE__ */ G("svg", {
viewBox: "0 0 24 24",
"aria-hidden": "true",
- children: /* @__PURE__ */ W("use", { href: "#i-folder-search" })
+ children: /* @__PURE__ */ G("use", { href: "#i-folder-search" })
})
}),
- a.length > 1 ? /* @__PURE__ */ W("button", {
+ a.length > 1 ? /* @__PURE__ */ G("button", {
type: "button",
class: "geist-button configrm",
"aria-label": "移除这个文件夹",
- onClick: () => te(n),
- children: /* @__PURE__ */ W("svg", {
+ onClick: () => j(n),
+ children: /* @__PURE__ */ G("svg", {
viewBox: "0 0 24 24",
"aria-hidden": "true",
- children: /* @__PURE__ */ W("use", { href: "#i-x" })
+ children: /* @__PURE__ */ G("use", { href: "#i-x" })
})
}) : null,
- /* @__PURE__ */ W("div", {
+ /* @__PURE__ */ G("div", {
class: "configsource",
- children: [/* @__PURE__ */ W("div", {
+ children: [/* @__PURE__ */ G("div", {
class: "configsourcelabel",
- children: ["媒体来源", /* @__PURE__ */ W(tt, {
+ children: ["媒体来源", /* @__PURE__ */ G(nt, {
label: `媒体来源 ${n + 1}`,
- value: c[n] || "local",
+ value: s[n] || "local",
onChange: (e) => {
- let t = [...c];
+ let t = [...s];
t[n] = e, l(t);
}
})]
- }), e.windows === !1 ? /* @__PURE__ */ W("label", { children: ["Windows 中的对应路径", /* @__PURE__ */ W("input", {
+ }), e.windows === !1 ? /* @__PURE__ */ G("label", { children: ["Windows 中的对应路径", /* @__PURE__ */ G("input", {
class: "geist-input",
"aria-label": `Windows 中的对应路径 ${n + 1}`,
value: u[n] || "",
@@ -877,7 +877,7 @@ function nt({ data: e, receipt: t }) {
}
})] }) : null]
}),
- g[n] ? /* @__PURE__ */ W("p", {
+ g[n] ? /* @__PURE__ */ G("p", {
class: "configbad",
role: "alert",
children: g[n]
@@ -885,61 +885,61 @@ function nt({ data: e, receipt: t }) {
]
}, n))
}),
- /* @__PURE__ */ W("button", {
+ /* @__PURE__ */ G("button", {
type: "button",
class: "geist-button configadd",
- onClick: ee,
+ onClick: A,
children: "添加文件夹"
}),
- c.some((e) => e === "115" || e === "pikpak") ? /* @__PURE__ */ W("p", {
+ s.some((e) => e === "115" || e === "pikpak") ? /* @__PURE__ */ G("p", {
class: "confighelp",
- children: ["先在 CloudDrive 登录网盘并完成挂载。", /* @__PURE__ */ W("a", {
+ children: ["先在 CloudDrive 登录网盘并完成挂载。", /* @__PURE__ */ G("a", {
href: "https://www.clouddrive2.com/help.html",
target: "_blank",
rel: "noreferrer",
- children: ["挂载帮助", /* @__PURE__ */ W("svg", {
+ children: ["挂载帮助", /* @__PURE__ */ G("svg", {
"aria-hidden": "true",
viewBox: "0 0 24 24",
- children: /* @__PURE__ */ W("use", { href: "#i-external-link" })
+ children: /* @__PURE__ */ G("use", { href: "#i-external-link" })
})]
})]
}) : null,
- c.some((e) => e === "115" || e === "pikpak") ? e.mount_dependencies?.filter((e) => !e.available).map((e) => /* @__PURE__ */ W("p", {
+ s.some((e) => e === "115" || e === "pikpak") ? e.mount_dependencies?.filter((e) => !e.available).map((e) => /* @__PURE__ */ G("p", {
class: "confighelp",
children: [
"未检测到 ",
e.name,
"。",
- /* @__PURE__ */ W("a", {
+ /* @__PURE__ */ G("a", {
href: e.download_url,
target: "_blank",
rel: "noreferrer",
children: [
"下载 ",
e.name,
- /* @__PURE__ */ W("svg", {
+ /* @__PURE__ */ G("svg", {
"aria-hidden": "true",
viewBox: "0 0 24 24",
- children: /* @__PURE__ */ W("use", { href: "#i-external-link" })
+ children: /* @__PURE__ */ G("use", { href: "#i-external-link" })
})
]
})
]
})) : null,
- e.windows === !1 ? /* @__PURE__ */ W("p", {
+ e.windows === !1 ? /* @__PURE__ */ G("p", {
class: "confighelp",
children: "本机文件夹是这台电脑读取媒体的位置。Windows 中的对应路径用于匹配馆藏中已有的路径,例如 B:\\ 对应本机挂载文件夹。"
}) : null
]
}),
- e.port_editable === !1 ? null : /* @__PURE__ */ W("div", {
+ e.port_editable === !1 ? null : /* @__PURE__ */ G("div", {
class: "configfield",
children: [
- /* @__PURE__ */ W("label", {
+ /* @__PURE__ */ G("label", {
for: "configPort",
children: "本机访问端口"
}),
- /* @__PURE__ */ W("input", {
+ /* @__PURE__ */ G("input", {
id: "configPort",
class: "geist-input",
type: "text",
@@ -948,43 +948,43 @@ function nt({ data: e, receipt: t }) {
"aria-invalid": v ? "true" : void 0,
onInput: (e) => p(e.currentTarget.value)
}),
- v ? /* @__PURE__ */ W("p", {
+ v ? /* @__PURE__ */ G("p", {
class: "configbad",
role: "alert",
children: v
}) : null,
- /* @__PURE__ */ W("p", {
+ /* @__PURE__ */ G("p", {
class: "confighelp",
children: "浏览器地址里冒号后面的数字,一般不用改。"
})
]
}),
- /* @__PURE__ */ W("label", {
+ /* @__PURE__ */ G("label", {
class: "configcheck",
- children: [/* @__PURE__ */ W("span", {
+ children: [/* @__PURE__ */ G("span", {
class: "pcheck",
- children: [/* @__PURE__ */ W("input", {
+ children: [/* @__PURE__ */ G("input", {
type: "checkbox",
checked: m,
onChange: (e) => h(e.currentTarget.checked)
- }), /* @__PURE__ */ W("span", {
+ }), /* @__PURE__ */ G("span", {
"aria-hidden": "true",
- children: /* @__PURE__ */ W("svg", {
+ children: /* @__PURE__ */ G("svg", {
viewBox: "0 0 24 24",
- children: /* @__PURE__ */ W("use", { href: "#i-check" })
+ children: /* @__PURE__ */ G("use", { href: "#i-check" })
})
})]
- }), /* @__PURE__ */ W("span", { children: "保存后扫描媒体文件夹" })]
+ }), /* @__PURE__ */ G("span", { children: "保存后扫描媒体文件夹" })]
}),
- b ? /* @__PURE__ */ W(G, { html: r(b, {
+ b ? /* @__PURE__ */ G(K, { html: i(b, {
variant: "error",
label: "没有保存"
}) }) : null
]
- }), /* @__PURE__ */ W("div", {
+ }), /* @__PURE__ */ G("div", {
class: "geist-fieldset-footer",
"data-geist-fieldset-footer": !0,
- children: [/* @__PURE__ */ W("p", { children: e.port_editable === !1 ? "保存后 Peach 会重新载入配置。" : "保存后 Peach 会重新启动,端口改了就用新地址打开。" }), /* @__PURE__ */ W("button", {
+ children: [/* @__PURE__ */ G("p", { children: e.port_editable === !1 ? "保存后 Peach 会重新载入配置。" : "保存后 Peach 会重新启动,端口改了就用新地址打开。" }), /* @__PURE__ */ G("button", {
type: "submit",
class: "geist-button primary",
ref: k,
@@ -993,51 +993,51 @@ function nt({ data: e, receipt: t }) {
})]
});
}
-function rt({ receipt: e, data: t, error: n }) {
- return n || !t ? /* @__PURE__ */ W(G, {
+function it({ receipt: e, data: t, error: n }) {
+ return n || !t ? /* @__PURE__ */ G(K, {
class: "configpage",
- html: r(n || "没有读到配置", {
+ html: i(n || "没有读到配置", {
variant: "error",
label: "打不开配置"
})
- }) : /* @__PURE__ */ W("div", {
+ }) : /* @__PURE__ */ G("div", {
class: "configpage",
children: [
- t.editable ? /* @__PURE__ */ W(nt, {
+ t.editable ? /* @__PURE__ */ G(rt, {
data: t,
receipt: e
- }) : /* @__PURE__ */ W(G, { html: r(t.notice, {
+ }) : /* @__PURE__ */ G(K, { html: i(t.notice, {
variant: "secondary",
label: "只读"
}) }),
- t.access ? /* @__PURE__ */ W(qe, {
+ t.access ? /* @__PURE__ */ G(Je, {
initial: t.access,
receipt: e
}) : null,
- /* @__PURE__ */ W($e, { facts: t.facts }),
- /* @__PURE__ */ W(et, { data: t })
+ /* @__PURE__ */ G(et, { facts: t.facts }),
+ /* @__PURE__ */ G(tt, { data: t })
]
});
}
//#endregion
//#region node_modules/@preact/signals-core/dist/signals-core.module.js
-var it = Symbol.for("preact-signals");
-function at() {
- if (q > 1) q--;
+var at = Symbol.for("preact-signals");
+function ot() {
+ if (J > 1) J--;
else {
var e, t = !1;
for ((function() {
- var e = pt;
- for (pt = void 0; e !== void 0;) {
+ var e = mt;
+ for (mt = 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;
}
- })(); lt !== void 0;) {
- var n = lt;
- for (lt = void 0, ut++; n !== void 0;) {
+ })(); ut !== void 0;) {
+ var n = ut;
+ for (ut = void 0, dt++; n !== void 0;) {
var r = n.u;
- if (n.u = void 0, n.f &= -3, !(8 & n.f) && _t(n)) try {
+ if (n.u = void 0, n.f &= -3, !(8 & n.f) && vt(n)) try {
n.c();
} catch (n) {
t ||= (e = n, !0);
@@ -1045,116 +1045,116 @@ function at() {
n = r;
}
}
- if (ut = 0, q--, t) throw e;
+ if (dt = 0, J--, t) throw e;
}
}
-function ot(e) {
- if (q > 0) return e();
- ft = ++dt, q++;
+function st(e) {
+ if (J > 0) return e();
+ pt = ++ft, J++;
try {
return e();
} finally {
- at();
+ ot();
}
}
-var st, K = void 0;
-function ct(e) {
- var t = K, n = st;
- K = void 0, st = void 0;
+var ct, q = void 0;
+function lt(e) {
+ var t = q, n = ct;
+ q = void 0, ct = void 0;
try {
return e();
} finally {
- K = t, st = n;
+ q = t, ct = n;
}
}
-var lt = void 0, q = 0, ut = 0, dt = 0, ft = 0, pt = void 0, mt = 0;
-function ht(e) {
- if (K !== void 0) {
+var ut = void 0, J = 0, dt = 0, ft = 0, pt = 0, mt = void 0, ht = 0;
+function gt(e) {
+ if (q !== void 0) {
var t = e.n;
- if (t === void 0 || t.t !== K) return t = {
+ if (t === void 0 || t.t !== q) return t = {
i: 0,
S: e,
- p: K.s,
+ p: q.s,
n: void 0,
- t: K,
+ t: q,
e: void 0,
x: void 0,
r: t
- }, K.s !== void 0 && (K.s.n = t), K.s = t, e.n = t, 32 & K.f && e.S(t), t;
- if (t.i === -1) return t.i = 0, t.n !== void 0 && (t.n.p = t.p, t.p !== void 0 && (t.p.n = t.n), t.p = K.s, t.n = void 0, K.s.n = t, K.s = t), t;
+ }, q.s !== void 0 && (q.s.n = t), q.s = t, e.n = t, 32 & q.f && e.S(t), t;
+ if (t.i === -1) return t.i = 0, t.n !== void 0 && (t.n.p = t.p, t.p !== void 0 && (t.p.n = t.n), t.p = q.s, t.n = void 0, q.s.n = t, q.s = t), t;
}
}
-function J(e, t) {
+function Y(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;
}
-J.prototype.brand = it, J.prototype.h = function() {
+Y.prototype.brand = at, Y.prototype.h = function() {
return !0;
-}, J.prototype.S = function(e) {
+}, Y.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 ? ct(function() {
+ n !== e && e.e === void 0 && (e.x = n, this.t = e, n === void 0 ? lt(function() {
var e;
(e = t.W) == null || e.call(t);
}) : n.e = e);
-}, J.prototype.U = function(e) {
+}, Y.prototype.U = function(e) {
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 && ct(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 && lt(function() {
var e;
(e = t.Z) == null || e.call(t);
}));
}
-}, J.prototype.subscribe = function(e) {
+}, Y.prototype.subscribe = function(e) {
var t = this;
- return Z(function() {
+ return Tt(function() {
var n = t.value;
- ct(function() {
+ lt(function() {
return e(n);
});
}, { name: "sub" });
-}, J.prototype.valueOf = function() {
+}, Y.prototype.valueOf = function() {
return this.value;
-}, J.prototype.toString = function() {
+}, Y.prototype.toString = function() {
return this.value + "";
-}, J.prototype.toJSON = function() {
+}, Y.prototype.toJSON = function() {
return this.value;
-}, J.prototype.peek = function() {
+}, Y.prototype.peek = function() {
var e = this;
- return ct(function() {
+ return lt(function() {
return e.value;
});
-}, Object.defineProperty(J.prototype, "value", {
+}, Object.defineProperty(Y.prototype, "value", {
get: function() {
- var e = ht(this);
+ var e = gt(this);
return e !== void 0 && (e.i = this.i), this.v;
},
set: function(e) {
if (e !== this.v) {
- if (ut > 100) throw Error("Cycle detected");
+ if (dt > 100) throw Error("Cycle detected");
(function(e) {
- q !== 0 && ut === 0 && e.l !== ft && (e.l = ft, pt = {
+ J !== 0 && dt === 0 && e.l !== pt && (e.l = pt, mt = {
S: e,
v: e.v,
i: e.i,
- o: pt
+ o: mt
});
- })(this), this.v = e, this.i++, mt++, q++;
+ })(this), this.v = e, this.i++, ht++, J++;
try {
for (var t = this.t; t !== void 0; t = t.x) t.t.N();
} finally {
- at();
+ ot();
}
}
}
});
-function gt(e, t) {
- return new J(e, t);
+function _t(e, t) {
+ return new Y(e, t);
}
-function _t(e) {
+function vt(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 vt(e) {
+function yt(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) {
@@ -1163,81 +1163,81 @@ function vt(e) {
}
}
}
-function yt(e) {
+function bt(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 Y(e, t) {
- J.call(this, void 0, t), this.x = e, this.s = void 0, this.g = mt - 1, this.f = 4;
+function X(e, t) {
+ Y.call(this, void 0, t), this.x = e, this.s = void 0, this.g = ht - 1, this.f = 4;
}
-Y.prototype = new J(), Y.prototype.h = function() {
+X.prototype = new Y(), X.prototype.h = function() {
if (this.f &= -3, 1 & this.f) return !1;
- if ((36 & this.f) == 32 || (this.f &= -5, this.g === mt)) return !0;
- if (this.g = mt, this.f |= 1, this.i > 0 && !_t(this)) return this.f &= -2, !0;
- var e = K;
+ if ((36 & this.f) == 32 || (this.f &= -5, this.g === ht)) return !0;
+ if (this.g = ht, this.f |= 1, this.i > 0 && !vt(this)) return this.f &= -2, !0;
+ var e = q;
try {
- vt(this), K = this;
+ yt(this), q = 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 K = e, yt(this), this.f &= -2, !0;
-}, Y.prototype.S = function(e) {
+ return q = e, bt(this), this.f &= -2, !0;
+}, X.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);
}
- J.prototype.S.call(this, e);
-}, Y.prototype.U = function(e) {
- if (this.t !== void 0 && (J.prototype.U.call(this, e), this.t === void 0)) {
+ Y.prototype.S.call(this, e);
+}, X.prototype.U = function(e) {
+ if (this.t !== void 0 && (Y.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);
}
-}, Y.prototype.N = function() {
+}, X.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(Y.prototype, "value", { get: function() {
+}, Object.defineProperty(X.prototype, "value", { get: function() {
if (1 & this.f) throw Error("Cycle detected");
- var e = ht(this);
+ var e = gt(this);
if (this.h(), e !== void 0 && (e.i = this.i), 16 & this.f) throw this.v;
return this.v;
} });
-function bt(e, t) {
- return new Y(e, t);
+function xt(e, t) {
+ return new X(e, t);
}
-function xt(e) {
+function St(e) {
var t = e.m;
if (e.m = void 0, typeof t == "function") {
- q++;
- var n = K;
- K = void 0;
+ J++;
+ var n = q;
+ q = void 0;
try {
t();
} catch (t) {
- throw e.f &= -2, e.f |= 8, St(e), t;
+ throw e.f &= -2, e.f |= 8, Ct(e), t;
} finally {
- K = n, at();
+ q = n, ot();
}
}
}
-function St(e) {
+function Ct(e) {
for (var t = e.s; t !== void 0; t = t.n) t.S.U(t);
- e.x = void 0, e.s = void 0, xt(e);
+ e.x = void 0, e.s = void 0, St(e);
}
-function Ct(e) {
- if (K !== this) throw Error("Out-of-order effect");
- yt(this), K = e, this.f &= -2, 8 & this.f && St(this), at();
+function wt(e) {
+ if (q !== this) throw Error("Out-of-order effect");
+ bt(this), q = e, this.f &= -2, 8 & this.f && Ct(this), ot();
}
-function X(e, t) {
- this.x = e, this.m = void 0, this.s = void 0, this.u = void 0, this.f = 32, this.name = t?.name, st && st.push(this);
+function Z(e, t) {
+ this.x = e, this.m = void 0, this.s = void 0, this.u = void 0, this.f = 32, this.name = t?.name, ct && ct.push(this);
}
-X.prototype.c = function() {
+Z.prototype.c = function() {
var e = this.S();
try {
if (8 & this.f || this.x === void 0) return;
@@ -1246,20 +1246,20 @@ X.prototype.c = function() {
} finally {
e();
}
-}, X.prototype.S = function() {
+}, Z.prototype.S = function() {
if (1 & this.f) throw Error("Cycle detected");
- this.f |= 1, this.f &= -9, xt(this), vt(this), q++;
- var e = K;
- return K = this, Ct.bind(this, e);
-}, X.prototype.N = function() {
- 2 & this.f || (this.f |= 2, this.u = lt, lt = this);
-}, X.prototype.d = function() {
- this.f |= 8, 1 & this.f || St(this);
-}, X.prototype.dispose = function() {
+ this.f |= 1, this.f &= -9, St(this), yt(this), J++;
+ var e = q;
+ return q = this, wt.bind(this, e);
+}, Z.prototype.N = function() {
+ 2 & this.f || (this.f |= 2, this.u = ut, ut = this);
+}, Z.prototype.d = function() {
+ this.f |= 8, 1 & this.f || Ct(this);
+}, Z.prototype.dispose = function() {
this.d();
};
-function Z(e, t) {
- var n = new X(e, t);
+function Tt(e, t) {
+ var n = new Z(e, t);
try {
n.c();
} catch (e) {
@@ -1270,35 +1270,35 @@ function Z(e, t) {
}
//#endregion
//#region node_modules/@preact/signals/dist/signals.module.js
-var wt, Tt, Et = typeof window < "u" && !!window.__PREACT_SIGNALS_DEVTOOLS__, Dt = [];
-Z(function() {
- wt = this.N;
+var Et, Dt, Ot = typeof window < "u" && !!window.__PREACT_SIGNALS_DEVTOOLS__, kt = [];
+Tt(function() {
+ Et = this.N;
})();
function Q(e, t) {
- f[e] = t.bind(null, f[e] || function() {});
+ m[e] = t.bind(null, m[e] || function() {});
}
-function Ot(e) {
- if (Tt) {
- var t = Tt;
- Tt = void 0, t();
+function At(e) {
+ if (Dt) {
+ var t = Dt;
+ Dt = void 0, t();
}
- Tt = e && e.S();
+ Dt = e && e.S();
}
-function kt(e) {
- var t = this, n = e.data, r = jt(n);
+function jt(e) {
+ var t = this, n = e.data, r = Nt(n);
r.name = "ReactiveDom", r.value = n;
- var i = Le(function() {
+ var i = Re(function() {
for (var e = t, n = t.__v; n = n.__;) if (n.__c) {
n.__c.__$f |= 4;
break;
}
- var i = bt(function() {
+ var i = xt(function() {
var e = r.value.value;
return e === 0 ? 0 : !0 === e ? "" : e || "";
- }), a = bt(function() {
- return !Array.isArray(i.value) && !m(i.value);
- }), o = Z(function() {
- if (this.N = Pt, a.value) {
+ }), a = xt(function() {
+ return !Array.isArray(i.value) && !g(i.value);
+ }), o = Tt(function() {
+ if (this.N = It, a.value) {
var t = i.value;
e.__v && e.__v.__e && e.__v.__e.nodeType === 3 && (e.__v.__e.data = t);
}
@@ -1309,14 +1309,14 @@ function kt(e) {
}, []), a = i[0], o = i[1];
return a.value ? o.peek() : o.value;
}
-kt.displayName = "ReactiveTextNode", Object.defineProperties(J.prototype, {
+jt.displayName = "ReactiveTextNode", Object.defineProperties(Y.prototype, {
constructor: {
configurable: !0,
value: void 0
},
type: {
configurable: !0,
- value: kt
+ value: jt
},
props: {
configurable: !0,
@@ -1336,30 +1336,30 @@ kt.displayName = "ReactiveTextNode", Object.defineProperties(J.prototype, {
var n, r = t.props;
for (var i in r) if (i !== "children") {
var a = r[i];
- a instanceof J && (n || (t.__np = n = {}), n[i] = a, r[i] = a.peek());
+ a instanceof Y && (n || (t.__np = n = {}), n[i] = a, r[i] = a.peek());
}
}
e(t);
}), Q("__r", function(e, t) {
- if (e(t), t.type !== M) {
- Ot();
+ if (e(t), t.type !== N) {
+ At();
var n, r = t.__c;
r && (r.__$f &= -2, (n = r.__$u) === void 0 && (r.__$u = n = function(e, t) {
var n;
- return Z(function() {
+ return Tt(function() {
n = this;
}, { name: t }), n.c = e, n;
}(function(e) {
return function() {
var t;
- Et && ((t = this.y) == null || t.call(this)), e.__$f |= 1, e.setState({});
+ Ot && ((t = this.y) == null || t.call(this)), e.__$f |= 1, e.setState({});
};
- }(r), typeof t.type == "function" ? t.type.displayName || t.type.name : ""))), Ot(n);
+ }(r), typeof t.type == "function" ? t.type.displayName || t.type.name : ""))), At(n);
}
}), Q("__e", function(e, t, n, r) {
- Ot(), e(t, n, r);
+ At(), e(t, n, r);
}), Q("diffed", function(e, t) {
- Ot();
+ At();
var n;
if (typeof t.type == "string" && (n = t.__e)) {
var r = t.__np, i = t.props, a = n.U;
@@ -1369,19 +1369,19 @@ kt.displayName = "ReactiveTextNode", Object.defineProperties(J.prototype, {
}
if (r) for (var c in a || (a = {}, n.U = a), r) {
var l = a[c], u = r[c];
- l === void 0 ? (l = At(n, c, u, i), a[c] = l) : l.o(u, i);
+ l === void 0 ? (l = Mt(n, c, u, i), a[c] = l) : l.o(u, i);
}
}
e(t);
});
-function At(e, t, n, r) {
- var i = t in e && e.ownerSVGElement === void 0, a = gt(n);
+function Mt(e, t, n, r) {
+ var i = t in e && e.ownerSVGElement === void 0, a = _t(n);
return {
o: function(e, t) {
a.value = e, r = t;
},
- d: Z(function() {
- this.N = Pt;
+ d: Tt(function() {
+ this.N = It;
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));
})
@@ -1413,7 +1413,7 @@ Q("unmount", function(e, t) {
e(t);
}), Q("__h", function(e, t, n, r) {
r < 3 && (t.__$f |= 2), e(t, n, r);
-}), N.prototype.shouldComponentUpdate = function(e, t) {
+}), P.prototype.shouldComponentUpdate = function(e, t) {
if (this.__R) return !0;
var n = this.__$u, r = n && n.s !== void 0;
for (var i in t) return !0;
@@ -1425,107 +1425,107 @@ Q("unmount", function(e, t) {
for (var s in this.props) if (!(s in e)) return !0;
return !1;
};
-function jt(e, t) {
- return Le(function() {
- return gt(e, t);
+function Nt(e, t) {
+ return Re(function() {
+ return _t(e, t);
}, []);
}
-var Mt = function(e) {
+var Pt = function(e) {
queueMicrotask(function() {
queueMicrotask(e);
});
};
-function Nt() {
- ot(function() {
- for (var e; e = Dt.shift();) wt.call(e);
+function Ft() {
+ st(function() {
+ for (var e; e = kt.shift();) Et.call(e);
});
}
-function Pt() {
- Dt.push(this) === 1 && (f.requestAnimationFrame || Mt)(Nt);
+function It() {
+ kt.push(this) === 1 && (m.requestAnimationFrame || Pt)(Ft);
}
//#endregion
//#region src/state/quality-goals.ts
-var Ft = "/api/quality-goals?limit=200", It = {
+var Lt = "/api/quality-goals?limit=200", Rt = {
data: null,
error: ""
-}, Lt = gt(It), Rt = 0, zt = bt(() => Lt.value);
-bt(() => Lt.value.data?.total ?? null);
-function Bt() {
- Rt += 1, Lt.value = It;
+}, zt = _t(Rt), Bt = 0, Vt = xt(() => zt.value);
+xt(() => zt.value.data?.total ?? null);
+function Ht() {
+ Bt += 1, zt.value = Rt;
}
-async function Vt(e) {
- let t = Rt += 1;
+async function Ut(e) {
+ let t = Bt += 1;
try {
- let n = await I(Ft, e);
- return t === Rt && (Lt.value = {
+ let n = await L(Lt, e);
+ return t === Bt && (zt.value = {
data: n,
error: ""
}), n;
} catch (n) {
- throw !e?.aborted && t === Rt && (Lt.value = {
+ throw !e?.aborted && t === Bt && (zt.value = {
data: null,
- error: F(n)
+ error: I(n)
}), n;
}
}
//#endregion
//#region src/islands/quality-goals.tsx
-var Ht = (e, t) => Vt(t), Ut = (e) => e.has_cover ? `/cover?code=${encodeURIComponent(e.code ?? "")}` : `/poster?id=${e.id}&c=4`;
-function Wt({ openItem: e, javTitleHtml: n, javDisplayName: i, srcBadge: a }) {
- let { data: o, error: s } = zt.value;
- if (s) return /* @__PURE__ */ W("div", {
+var Wt = (e, t) => Ut(t), Gt = (e) => e.has_cover ? `/cover?code=${encodeURIComponent(e.code ?? "")}` : `/poster?id=${e.id}&c=4`;
+function Kt({ openItem: e, javTitleHtml: n, javDisplayName: r, srcBadge: a }) {
+ let { data: o, error: s } = Vt.value;
+ if (s) return /* @__PURE__ */ G("div", {
class: "qualitylist",
- dangerouslySetInnerHTML: { __html: r(s, {
+ dangerouslySetInnerHTML: { __html: i(s, {
variant: "error",
label: "读取失败"
}) }
});
- let d = o?.items ?? [];
- return d.length ? /* @__PURE__ */ W("div", {
+ let c = o?.items ?? [];
+ return c.length ? /* @__PURE__ */ G("div", {
class: "qualitylist",
- children: d.map((t) => /* @__PURE__ */ W("article", {
+ children: c.map((t) => /* @__PURE__ */ G("article", {
class: "qualityitem",
- children: [/* @__PURE__ */ W("button", {
+ children: [/* @__PURE__ */ G("button", {
class: "qualitycover",
type: "button",
- "aria-label": `打开 ${i(t)}`,
+ "aria-label": `打开 ${r(t)}`,
onClick: () => e(t.id),
- children: /* @__PURE__ */ W("img", {
- src: Ut(t),
+ children: /* @__PURE__ */ G("img", {
+ src: Gt(t),
alt: "",
loading: "lazy",
onError: (e) => e.currentTarget.remove()
})
- }), /* @__PURE__ */ W("div", { children: [
- /* @__PURE__ */ W("h3", { children: /* @__PURE__ */ W("button", {
+ }), /* @__PURE__ */ G("div", { children: [
+ /* @__PURE__ */ G("h3", { children: /* @__PURE__ */ G("button", {
type: "button",
"data-middle-truncate": !0,
onClick: () => e(t.id),
dangerouslySetInnerHTML: { __html: n(t) }
}) }),
- /* @__PURE__ */ W("p", {
+ /* @__PURE__ */ G("p", {
class: "mono",
children: [
- /* @__PURE__ */ W("span", {
+ /* @__PURE__ */ G("span", {
style: "display:contents",
dangerouslySetInnerHTML: { __html: a(t.location, t.cost) }
}),
- /* @__PURE__ */ W("span", { children: c[t.location] ?? t.location }),
- /* @__PURE__ */ W("span", { children: l(t.duration) }),
- /* @__PURE__ */ W("span", { children: u(t.size ?? 0) })
+ /* @__PURE__ */ G("span", { children: u[t.location] ?? t.location }),
+ /* @__PURE__ */ G("span", { children: d(t.duration) }),
+ /* @__PURE__ */ G("span", { children: f(t.size ?? 0) })
]
}),
- t.reason ? /* @__PURE__ */ W("p", { children: t.reason }) : null
+ t.reason ? /* @__PURE__ */ G("p", { children: t.reason }) : null
] })]
}, t.id))
- }) : /* @__PURE__ */ W("div", {
+ }) : /* @__PURE__ */ G("div", {
class: "qualitylist",
dangerouslySetInnerHTML: { __html: t("sparkles", "没有标记中的高清版目标", "现有版本都已满足条件,或还没有加入追踪。") }
});
}
//#endregion
//#region src/jobs.ts
-async function Gt(e) {
+async function qt(e) {
let t = e.pause || ((e) => new Promise((t) => setTimeout(t, e))), n = 0;
for (; e.active();) {
let r;
@@ -1540,11 +1540,11 @@ async function Gt(e) {
await t(2e3);
}
}
-function Kt(e) {
+function Jt(e) {
let t = document.createElement("div");
e.host.hidden = !0, t.dataset.followJob = "", t.setAttribute("aria-live", "polite"), e.host.prepend(t);
let n = e.storageKey || "peach-follow-job", r = sessionStorage.getItem(n) || void 0, i = !1;
- Gt({
+ qt({
read: e.read,
active: () => !i && e.active() && t.isConnected,
keepWatching: e.watchIdle !== !1,
@@ -1570,43 +1570,43 @@ function Kt(e) {
}
//#endregion
//#region src/islands/scraping.tsx
-var qt = (e, t) => I("/api/scraping", t);
-function Jt({ value: e, onChange: t }) {
- let n = U(null), r = U(t);
- return r.current = t, H(() => {
+var Yt = (e, t) => L("/api/scraping", t);
+function Xt({ value: e, onChange: t }) {
+ let n = W(null), r = W(t);
+ return r.current = t, U(() => {
let t = n.current;
- t.innerHTML = i([
+ t.innerHTML = o([
["environment", "系统代理"],
["direct", "应用直连"],
["proxy", "自定义代理"]
], e, { label: "连接方式" });
- let a = s(t.firstElementChild), o = () => r.current(a.value);
- return a.addEventListener("change", o), () => {
- a.disabled = !0, a.removeEventListener("change", o), t.replaceChildren();
+ let i = l(t.firstElementChild), a = () => r.current(i.value);
+ return i.addEventListener("change", a), () => {
+ i.disabled = !0, i.removeEventListener("change", a), t.replaceChildren();
};
- }, []), /* @__PURE__ */ W("div", {
+ }, []), /* @__PURE__ */ G("div", {
ref: n,
class: "scraping-network"
});
}
-function Yt({ source: e, toast: t }) {
- let [i, a] = V(e), [s, c] = V(e.network), [l, u] = V(""), [d, f] = V(""), [p, m] = V(""), [h, g] = V("paste"), [_, v] = V(""), [y, b] = V(!1), [x, S] = V(""), [C, w] = V([]), T = U(null), E = U(null);
- H(() => {
- E.current?.querySelectorAll("footer button").forEach((e) => o(e, y));
+function Zt({ source: e, toast: t }) {
+ let [r, a] = H(e), [o, s] = H(e.network), [l, u] = H(""), [d, f] = H(""), [p, m] = H(""), [h, g] = H("paste"), [_, v] = H(""), [y, b] = H(!1), [x, S] = H(""), [C, w] = H([]), T = W(null), E = W(null);
+ U(() => {
+ E.current?.querySelectorAll("footer button").forEach((e) => c(e, y));
}, [y]);
- let D = U(new AbortController());
- Ie(() => () => D.current.abort(), []);
+ let D = W(new AbortController());
+ Le(() => () => D.current.abort(), []);
async function O(n) {
if (!y) {
b(!0), S(""), w([]);
try {
if (n === "check") {
- let t = await L("/api/scraping/check", { source: e.source }, "POST", D.current.signal);
+ let t = await R("/api/scraping/check", { source: e.source }, "POST", D.current.signal);
D.current.signal.aborted || w(t.results);
} else {
- let r = await L("/api/scraping/settings", {
+ let r = await R("/api/scraping/settings", {
source: e.source,
- network: s,
+ network: o,
proxy: l,
cookie: d,
cookies_text: p,
@@ -1615,55 +1615,55 @@ function Yt({ source: e, toast: t }) {
D.current.signal.aborted || (a(r.saved), u(""), f(""), m(""), v(""), T.current && (T.current.value = ""), t(n === "revoke" ? "Cookie 已撤销" : "来源设置已保存"));
}
} catch (e) {
- D.current.signal.aborted || S(F(e));
+ D.current.signal.aborted || S(I(e));
} finally {
D.current.signal.aborted || b(!1);
}
}
}
- return /* @__PURE__ */ W("section", {
+ return /* @__PURE__ */ G("section", {
class: "scraping-source",
- children: /* @__PURE__ */ W("form", {
+ children: /* @__PURE__ */ G("form", {
ref: E,
class: "cleanupfieldset",
"data-geist-fieldset": !0,
onSubmit: (e) => {
e.preventDefault(), O("save");
},
- children: [/* @__PURE__ */ W("div", {
+ children: [/* @__PURE__ */ G("div", {
class: "geist-fieldset-content scraping-fields",
children: [
- /* @__PURE__ */ W("div", { dangerouslySetInnerHTML: { __html: n(`scraping-${e.source}`, e.label) } }),
- /* @__PURE__ */ W("a", {
+ /* @__PURE__ */ G("div", { dangerouslySetInnerHTML: { __html: n(`scraping-${e.source}`, e.label) } }),
+ /* @__PURE__ */ G("a", {
class: "scraping-url",
href: e.login,
target: "_blank",
rel: "noopener noreferrer",
children: e.login
}),
- /* @__PURE__ */ W("div", {
+ /* @__PURE__ */ G("div", {
class: "scraping-label",
- children: ["连接方式", /* @__PURE__ */ W(Jt, {
- value: s,
- onChange: c
+ children: ["连接方式", /* @__PURE__ */ G(Xt, {
+ value: o,
+ onChange: s
})]
}),
- s === "proxy" && /* @__PURE__ */ W("label", { children: ["代理地址", /* @__PURE__ */ W("input", {
+ o === "proxy" && /* @__PURE__ */ G("label", { children: ["代理地址", /* @__PURE__ */ G("input", {
class: "geist-input",
type: "password",
autoComplete: "off",
value: l,
- placeholder: i.proxy_saved ? "已保存,留空保留" : "http://127.0.0.1:7890",
+ placeholder: r.proxy_saved ? "已保存,留空保留" : "http://127.0.0.1:7890",
disabled: y,
onInput: (e) => u(e.currentTarget.value)
})] }),
- e.accepts_cookie && /* @__PURE__ */ W(M, { children: [
- /* @__PURE__ */ W("p", { children: i.cookie_saved ? "Cookie 已保存,登录是否有效请在抓取时确认。" : "需要登录时,任选一种方式提供 Cookie。" }),
- /* @__PURE__ */ W("div", {
+ e.accepts_cookie && /* @__PURE__ */ G(N, { children: [
+ /* @__PURE__ */ G("p", { children: r.cookie_saved ? "Cookie 已保存,登录是否有效请在抓取时确认。" : "需要登录时,任选一种方式提供 Cookie。" }),
+ /* @__PURE__ */ G("div", {
class: "insightswitch scraping-cookie-method",
role: "radiogroup",
"aria-label": "提供 Cookie 的方式(二选一)",
- children: [["paste", "粘贴 Cookie"], ["file", "导入文件"]].map(([t, n]) => /* @__PURE__ */ W("label", { children: [/* @__PURE__ */ W("input", {
+ children: [["paste", "粘贴 Cookie"], ["file", "导入文件"]].map(([t, n]) => /* @__PURE__ */ G("label", { children: [/* @__PURE__ */ G("input", {
type: "radio",
name: `cookie-method-${e.source}`,
value: t,
@@ -1671,29 +1671,29 @@ function Yt({ source: e, toast: t }) {
onChange: () => {
g(t), f(""), m(""), v("");
}
- }), /* @__PURE__ */ W("span", { children: n })] }, t))
+ }), /* @__PURE__ */ G("span", { children: n })] }, t))
}),
- h === "paste" ? /* @__PURE__ */ W("label", { children: ["Cookie", /* @__PURE__ */ W("input", {
+ h === "paste" ? /* @__PURE__ */ G("label", { children: ["Cookie", /* @__PURE__ */ G("input", {
class: "geist-input",
type: "password",
autoComplete: "off",
value: d,
disabled: y,
onInput: (e) => f(e.currentTarget.value)
- })] }) : /* @__PURE__ */ W("label", {
+ })] }) : /* @__PURE__ */ G("label", {
class: "scraping-file",
- children: ["Netscape Cookie 文件(.txt)", /* @__PURE__ */ W("span", {
+ children: ["Netscape Cookie 文件(.txt)", /* @__PURE__ */ G("span", {
class: "scraping-file-control",
children: [
- /* @__PURE__ */ W("span", {
+ /* @__PURE__ */ G("span", {
class: "geist-button",
children: "选择文件"
}),
- /* @__PURE__ */ W("span", {
+ /* @__PURE__ */ G("span", {
class: "scraping-file-name",
children: _ || "未选择文件"
}),
- /* @__PURE__ */ W("input", {
+ /* @__PURE__ */ G("input", {
ref: T,
type: "file",
accept: ".txt",
@@ -1723,31 +1723,31 @@ function Yt({ source: e, toast: t }) {
})]
})
] }),
- x && /* @__PURE__ */ W("div", {
+ x && /* @__PURE__ */ G("div", {
role: "alert",
- dangerouslySetInnerHTML: { __html: r(x, { variant: "error" }) }
+ dangerouslySetInnerHTML: { __html: i(x, { variant: "error" }) }
}),
- C.map((t) => /* @__PURE__ */ W("div", {
+ C.map((t) => /* @__PURE__ */ G("div", {
role: "status",
- dangerouslySetInnerHTML: { __html: r(`${e.label}${t.label === "来源页面" ? "" : " 高清图片"}:${t.ok ? "可连接" : "不能连接"}` + (t.width ? ` · ${t.width} × ${t.height}` : "") + (t.message ? `。${t.message}` : ""), { variant: t.ok ? "success" : "error" }) }
+ dangerouslySetInnerHTML: { __html: i(`${e.label}${t.label === "来源页面" ? "" : " 高清图片"}:${t.ok ? "可连接" : "不能连接"}` + (t.width ? ` · ${t.width} × ${t.height}` : "") + (t.message ? `。${t.message}` : ""), { variant: t.ok ? "success" : "error" }) }
}, t.label))
]
- }), /* @__PURE__ */ W("footer", {
+ }), /* @__PURE__ */ G("footer", {
class: "geist-fieldset-footer",
"data-geist-fieldset-footer": !0,
children: [
- /* @__PURE__ */ W("button", {
+ /* @__PURE__ */ G("button", {
class: "geist-button primary",
type: "submit",
children: "保存"
}),
- /* @__PURE__ */ W("button", {
+ /* @__PURE__ */ G("button", {
class: "geist-button",
type: "button",
onClick: () => void O("check"),
children: "检查连接"
}),
- e.accepts_cookie && i.cookie_saved && /* @__PURE__ */ W("button", {
+ e.accepts_cookie && r.cookie_saved && /* @__PURE__ */ G("button", {
class: "geist-button",
type: "button",
onClick: () => void O("revoke"),
@@ -1758,88 +1758,175 @@ function Yt({ source: e, toast: t }) {
})
});
}
-function Xt({ data: e, error: t, toast: i }) {
- let [a, s] = V(""), [c, l] = V(!1), [u, d] = V(""), f = U(null);
- H(() => o(f.current, c), [c]);
- let p = U(new AbortController()), m = U(0);
+function Qt({ data: e, error: t, toast: r }) {
+ let [a, o] = H(""), [s, l] = H(!1), [u, d] = H(""), f = W(null);
+ U(() => c(f.current, s), [s]);
+ let p = W(new AbortController()), m = W(0);
async function h(e = !1) {
let t = ++m.current;
- await Gt({
- read: (e) => I("/api/scraping/cover", e),
+ await qt({
+ read: (e) => L("/api/scraping/cover", e),
active: () => !p.current.signal.aborted && t === m.current,
render: (t) => {
- l(t.status === "running"), t.status === "running" && (e = !1), t.status === "failed" && !e && d(t.error || "采集未取得"), t.status === "complete" && !e && i(t.result || "封面采集完成");
+ l(t.status === "running"), t.status === "running" && (e = !1), t.status === "failed" && !e && d(t.error || "采集未取得"), t.status === "complete" && !e && r(t.result || "封面采集完成");
},
disconnected: () => d("连接中断,正在重新读取后台进度")
});
}
- Ie(() => (h(!0), () => p.current.abort()), []);
+ Le(() => (h(!0), () => p.current.abort()), []);
async function g() {
- if (!c) {
+ if (!s) {
m.current++, l(!0), d("");
try {
- await L("/api/scraping/cover", { code: a }, "POST", p.current.signal), await h();
+ await R("/api/scraping/cover", { code: a }, "POST", p.current.signal), await h();
} catch (e) {
- p.current.signal.aborted || (l(!1), d(F(e)));
+ p.current.signal.aborted || (l(!1), d(I(e)));
}
}
}
- return t ? /* @__PURE__ */ W("div", {
+ return t ? /* @__PURE__ */ G("div", {
role: "alert",
- dangerouslySetInnerHTML: { __html: r(t, { variant: "error" }) }
- }) : /* @__PURE__ */ W("div", {
+ dangerouslySetInnerHTML: { __html: i(t, { variant: "error" }) }
+ }) : /* @__PURE__ */ G("div", {
class: "scraping-page",
children: [
- /* @__PURE__ */ W("p", { children: "高清图片可能需要代理才能下载,请先检查连接。" }),
- /* @__PURE__ */ W("section", {
+ /* @__PURE__ */ G("p", { children: "高清图片可能需要代理才能下载,请先检查连接。" }),
+ /* @__PURE__ */ G("section", {
class: "cleanupfieldset scraping-source",
"data-geist-fieldset": !0,
- children: /* @__PURE__ */ W("div", {
+ children: /* @__PURE__ */ G("div", {
class: "geist-fieldset-content scraping-fields",
children: [
- /* @__PURE__ */ W("div", { dangerouslySetInnerHTML: { __html: n("scraping-cover", "高清封面") } }),
- /* @__PURE__ */ W("form", {
+ /* @__PURE__ */ G("div", { dangerouslySetInnerHTML: { __html: n("scraping-cover", "高清封面") } }),
+ /* @__PURE__ */ G("form", {
class: "scraping-cover-form",
onSubmit: (e) => {
e.preventDefault(), g();
},
- children: [/* @__PURE__ */ W("input", {
+ children: [/* @__PURE__ */ G("input", {
class: "geist-input",
"aria-label": "馆藏番号",
required: !0,
value: a,
- disabled: c,
+ disabled: s,
placeholder: "输入馆藏番号,如 ABW-232",
- onInput: (e) => s(e.currentTarget.value)
- }), /* @__PURE__ */ W("button", {
+ onInput: (e) => o(e.currentTarget.value)
+ }), /* @__PURE__ */ G("button", {
ref: f,
class: "geist-button primary",
type: "submit",
children: "抓取封面"
})]
}),
- u && /* @__PURE__ */ W("div", {
+ u && /* @__PURE__ */ G("div", {
role: "alert",
- dangerouslySetInnerHTML: { __html: r(u, { variant: "error" }) }
+ dangerouslySetInnerHTML: { __html: i(u, { variant: "error" }) }
})
]
})
}),
- e?.sources.map((e) => /* @__PURE__ */ W(Yt, {
+ e?.sources.map((e) => /* @__PURE__ */ G(Zt, {
source: e,
- toast: i
+ toast: r
}, e.source))
]
});
}
//#endregion
+//#region src/islands/library-processing.tsx
+var $t = (e, t) => L("/api/library-processing", t);
+function en({ data: e, error: t, toast: o, onComplete: s }) {
+ let [l, u] = H(e || { status: "idle" }), [d, f] = H(t), [p, m] = H(!1), [h, g] = H(!1), _ = W(new AbortController()), v = W(0), y = W(null), b = p || l.status === "running";
+ U(() => c(y.current, b), [b]);
+ async function x() {
+ let e = ++v.current;
+ await qt({
+ read: (e) => L("/api/library-processing", e),
+ active: () => !_.current.signal.aborted && v.current === e,
+ render: (e) => {
+ u(e), f(""), e.status === "complete" && (g(!0), o("已完成扫描与资料采集")), (e.status === "complete" || e.status === "failed") && s?.();
+ },
+ disconnected: () => f("连接中断,正在重新读取处理进度")
+ });
+ }
+ Le(() => (l.status === "running" && x(), () => _.current.abort()), []);
+ async function S() {
+ if (!b) {
+ m(!0), f(""), g(!1);
+ try {
+ let e = await R("/api/library-processing", {}, "POST", _.current.signal);
+ if (_.current.signal.aborted) return;
+ u(e), m(!1), await x();
+ } catch (e) {
+ _.current.signal.aborted || (f(I(e)), m(!1));
+ }
+ }
+ }
+ return /* @__PURE__ */ G(N, { children: [/* @__PURE__ */ G("div", {
+ class: "geist-fieldset-content library-processing",
+ children: [
+ /* @__PURE__ */ G("div", { dangerouslySetInnerHTML: { __html: n("cleanupScrapingTitle", "扫描与采集") } }),
+ /* @__PURE__ */ G("p", { children: "扫描媒体文件夹,导入已有资料,采集缺失信息。" }),
+ /* @__PURE__ */ G("div", {
+ "aria-live": "polite",
+ children: [
+ l.status === "running" && /* @__PURE__ */ G(N, { children: [/* @__PURE__ */ G("div", { dangerouslySetInnerHTML: { __html: r(l.stage || "正在处理") } }), !!l.total && /* @__PURE__ */ G("div", { dangerouslySetInnerHTML: { __html: a(`已处理 ${l.checked || 0} / ${l.total} 个视频`, l.checked || 0, l.total) } })] }),
+ (d || l.status === "failed") && /* @__PURE__ */ G("div", {
+ role: "alert",
+ dangerouslySetInnerHTML: { __html: i(d || l.error || "处理未完成,请重试", { variant: "error" }) }
+ }),
+ l.status === "failed" && !!l.issues?.length && /* @__PURE__ */ G("ul", { children: l.issues.slice(0, 20).map((e) => /* @__PURE__ */ G("li", { children: [
+ e.asset_id ? /* @__PURE__ */ G("a", {
+ href: `/item/${e.asset_id}`,
+ children: "查看视频"
+ }) : null,
+ e.asset_id ? ":" : "",
+ e.message
+ ] })) }),
+ h && /* @__PURE__ */ G("p", { children: [
+ "已扫描 ",
+ l.scanned || 0,
+ " 个文件,识别 ",
+ l.identified || 0,
+ " 个番号,生成 ",
+ l.candidates || 0,
+ " 组待复核资料。"
+ ] })
+ ]
+ })
+ ]
+ }), /* @__PURE__ */ G("footer", {
+ class: "geist-fieldset-footer",
+ "data-geist-fieldset-footer": !0,
+ children: [
+ /* @__PURE__ */ G("a", {
+ class: "geist-button",
+ href: "/scraping",
+ children: "采集来源"
+ }),
+ !!l.candidates && /* @__PURE__ */ G("a", {
+ class: "geist-button",
+ href: "/review",
+ children: "复核资料"
+ }),
+ /* @__PURE__ */ G("button", {
+ ref: y,
+ type: "button",
+ class: "geist-button primary",
+ onClick: () => void S(),
+ children: l.status === "failed" ? "重试未完成项" : "扫描并补全资料"
+ })
+ ]
+ })] });
+}
+//#endregion
//#region src/state/index.ts
-var Zt = { "quality-goals": {
- refresh: Vt,
- reset: Bt
-} }, Qt = () => Object.keys(Zt);
-async function $t(e) {
- let t = Zt[e];
+var tn = { "quality-goals": {
+ refresh: Ut,
+ reset: Ht
+} }, nn = () => Object.keys(tn);
+async function rn(e) {
+ let t = tn[e];
if (!t) throw Error(`未登记的共享 store:${String(e)}`);
try {
return await t.refresh(), !0;
@@ -1849,10 +1936,10 @@ async function $t(e) {
}
//#endregion
//#region src/native-image.ts
-function en(e, t, n, r) {
+function an(e, t, n, r) {
return e > 0 && t > 0 && e === n && t === r;
}
-function tn(e, t, n, r, i = 1) {
+function on(e, t, n, r, i = 1) {
let a = Number.isFinite(i) && i > 0 ? i : 1;
e /= a, t /= a;
let o = [
@@ -1869,7 +1956,7 @@ function tn(e, t, n, r, i = 1) {
}
//#endregion
//#region src/entity-skeleton.ts
-function nn(e, t) {
+function sn(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>
@@ -1881,7 +1968,7 @@ function nn(e, t) {
}
//#endregion
//#region src/catalog-onboarding.ts
-var rn = [
+var cn = [
"loc",
"creator",
"performer",
@@ -1898,7 +1985,7 @@ var rn = [
"jav",
"thumb"
];
-function an() {
+function ln() {
let e = (e) => [
,
,
@@ -1909,9 +1996,9 @@ function an() {
tags: "<span class=\"catalog-placeholder placeholder-tags\" aria-hidden=\"true\">" + e("<span class=\"pill\">&nbsp;</span>") + "</span>"
};
}
-async function on(e, t) {
+async function un(e, t) {
let n = new URLSearchParams();
- for (let t of rn) e[t] && n.set(t, e[t]);
+ for (let t of cn) 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 || [],
@@ -1922,7 +2009,7 @@ async function on(e, t) {
return r.set("q", e), r.set("limit", "1"), (await t("/api/items?" + r)).total > 0 ? e : "";
}))).filter(Boolean);
}
-function sn({ kind: e = "catalog", filtered: n = !1, jav: r = !1, configurable: i = !1, online: a = !1 } = {}) {
+function dn({ kind: e = "catalog", filtered: n = !1, jav: r = !1, configurable: i = !1, online: a = !1 } = {}) {
let o = i ? "<a class=\"geist-button primary\" href=\"/configuration\">添加内容</a>" : "", s = "<a class=\"geist-button\" href=\"/follow-manage\">添加来源</a>";
return n || r ? t("search", r ? "还没有符合条件的 JAV 作品" : "没有符合条件的内容", r ? "已扫描但尚未补充发行资料的视频可在全部内容中查看。" : "清除筛选或搜索条件后查看全部内容。", { actions: "<a class=\"geist-button primary\" href=\"/?loc=&thumb=0\">查看全部内容</a>" }) : e === "catalog" ? t("play", "还没有视频", "添加媒体文件夹或关注来源,开始建立你的馆藏。", { actions: o + s }) : t(e === "tags" ? "tags" : "user-round", "还没有" + ({
tags: "标签",
@@ -1935,7 +2022,7 @@ function sn({ kind: e = "catalog", filtered: n = !1, jav: r = !1, configurable:
}
//#endregion
//#region src/sidebar.ts
-function cn(e) {
+function fn(e) {
return [
"/",
"/unseen",
@@ -1945,29 +2032,29 @@ function cn(e) {
"/junk-files"
].includes(e) || /^\/(item|mix|parts|editions)\//.test(e) || /^\/playlists\/\d+\/\d+$/.test(e) || /^\/(performers|studios|creators|series|agencies)\/.+/.test(e);
}
-function ln(e, t) {
+function pn(e, t) {
return e.dataset.surface === t && e.querySelector(".dnav") ? !1 : (e.dataset.surface = t, e.replaceChildren(), !0);
}
-function un(e) {
+function mn(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/management.ts
-function dn(e) {
+function hn(e) {
return e.filter((e) => ["115", "pikpak"].includes(e.location) && (e.roots === void 0 || e.roots.length > 0)).map((e) => e.location);
}
-function fn(e, t) {
+function gn(e, t) {
return t.filter((t) => e.some((e) => e.location === t));
}
-function pn() {
+function _n() {
return `<div class="cleanuppage" data-skeleton="cleanup" aria-busy="true" aria-label="正在读取数据管理状态">
<div class="cleanupgrid">${[
[
- "采集来源",
- "设置采集来源",
- "下载高清封面,设置代理和 Cookie。"
+ "扫描与采集",
+ "扫描并补全资料",
+ "扫描媒体文件夹,导入已有资料,采集缺失信息。"
],
[
"垃圾文件",
@@ -2007,7 +2094,7 @@ function pn() {
<footer class="geist-fieldset-footer" data-geist-fieldset-footer><button type="button"${r === 3 ? " class=\"danger\"" : ""} disabled>${r === 3 ? "<svg aria-hidden=\"true\"><use href=\"#i-trash\"></use></svg><span>" + t + "</span>" : t}</button></footer>
</section>`).join("")}</div></div>`;
}
-function mn(e, t = !1, n = !1) {
+function vn(e, t = !1, n = !1) {
if (t || n) return "";
let r = "<svg aria-hidden=\"true\"><use href=\"#i-external-link\"></use></svg>";
return `<details class="taste-history-guide"${e ? " open" : ""}>
@@ -2018,63 +2105,67 @@ function mn(e, t = !1, n = !1) {
<ul><li>Chrome:在 <a href="https://takeout.google.com/" target="_blank" rel="noreferrer">Google Takeout${r}</a> 选择 Chrome 历史记录,下载 ZIP 后直接导入。</li>
<li>其他浏览器:使用 <a href="https://github.com/purarue/browserexport" target="_blank" rel="noreferrer">browserexport${r}</a> 导出历史记录,再导入导出文件。</li></ul>
<p>需要刷新时再次读取或导入;数据源可在页面底部移除。</p>
- <button type="button" class="taste-guide-skip">跳过</button>
+ <button type="button" class="geist-button taste-guide-skip">跳过</button>
</div></details>`;
}
-var hn = "peach-taste-guide-dismissed";
-function gn(e, t) {
+var yn = "peach-taste-guide-dismissed";
+function bn(e, t) {
let n = e.querySelector(".taste-history-guide");
n?.querySelector(".taste-guide-skip")?.addEventListener("click", () => {
- t.setItem(hn, "1"), n.remove();
+ t.setItem(yn, "1"), n.remove();
});
}
//#endregion
//#region src/jav-artwork.ts
-function _n(e) {
+function xn(e) {
return [
"small",
"sleeve",
"preview"
].includes(String(e)) ? "small" : "big";
}
-function vn(e) {
+function Sn(e) {
return {
- javLayout: _n(e.javLayout),
- javImage: yn(e.javLayout === "preview" ? "thumbnail" : e.javImage)
+ javLayout: xn(e.javLayout),
+ javImage: Cn(e.javLayout === "preview" ? "thumbnail" : e.javImage)
};
}
-function yn(e) {
+function Cn(e) {
return e === "thumbnail" ? "thumbnail" : "cover";
}
-function bn(e, t) {
- return e.is_jav && e.code && e.has_cover && (yn(t) === "cover" || !e.has_thumb) ? "cover" : e.has_thumb ? "thumbnail" : "";
+function wn(e, t) {
+ return e.is_jav && e.code && e.has_cover && (Cn(t) === "cover" || !e.has_thumb) ? "cover" : e.has_thumb ? "thumbnail" : "";
}
-function xn(e, t) {
+function Tn(e, t) {
e.querySelectorAll("img[data-jav-image]").forEach((e) => {
- let n = e.dataset.javCover || "", r = e.dataset.javThumb || "", i = !!(n && (yn(t) === "cover" || !r)), a = i ? n : r;
+ let n = e.dataset.javCover || "", r = e.dataset.javThumb || "", i = !!(n && (Cn(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 Sn = {
+var En = {
+ "library-processing": {
+ load: $t,
+ component: en
+ },
scraping: {
- load: qt,
- component: Xt
+ load: Yt,
+ component: Qt
},
"quality-goals": {
- load: Ht,
- component: Wt
+ load: Wt,
+ component: Kt
},
configuration: {
- load: Ze,
- component: rt
+ load: Qe,
+ component: it
}
-}, Cn = () => Object.keys(Sn), $ = /* @__PURE__ */ new Map();
-async function wn(e, t, n, r = {}) {
- let i = Sn[e];
+}, Dn = () => Object.keys(En), $ = /* @__PURE__ */ new Map();
+async function On(e, t, n, r = {}) {
+ let i = En[e];
if (!i) throw Error(`未注册的 island:${String(e)}`);
- Tn(t);
+ kn(t);
let a = {
controller: new AbortController(),
painted: !1
@@ -2090,7 +2181,7 @@ async function wn(e, t, n, r = {}) {
if (a.controller.signal.aborted) return;
o = {
data: null,
- error: F(e)
+ error: I(e)
};
}
if ($.get(t) !== a) return;
@@ -2103,11 +2194,11 @@ async function wn(e, t, n, r = {}) {
...n,
...o
};
- xe(te(i.component, s), t);
+ Se(te(i.component, s), t);
}
-function Tn(e) {
+function kn(e) {
let t = $.get(e);
- t && (t.controller.abort(), $.delete(e), t.painted && xe(null, e));
+ t && (t.controller.abort(), $.delete(e), t.painted && Se(null, e));
}
//#endregion
-export { hn as TASTE_GUIDE_KEY, sn as catalogEmptyHtml, on as catalogSuggestions, pn as cleanupSkeletonHtml, dn as cloudLocations, fn as cloudPreferenceLocations, an as emptyCatalogLayout, nn as entitySkeletonHtml, Kt as followJobProgress, Cn as islandNames, bn as javImageKind, en as matchesFaceSource, wn as mountIsland, tn as nativeImageFit, yn as normalizeJavImage, _n as normalizeJavLayout, vn as normalizeJavPreferences, $t as refreshStore, cn as sidebarHasCatalogContent, un as sidebarTagCounts, Qt as storeNames, xn as syncJavImages, ln as syncSidebarSurface, mn as tasteHistoryGuideHtml, Tn as unmountIsland, Gt as watchJob, gn as wireTasteHistoryGuide };
+export { yn as TASTE_GUIDE_KEY, dn as catalogEmptyHtml, un as catalogSuggestions, _n as cleanupSkeletonHtml, hn as cloudLocations, gn as cloudPreferenceLocations, ln as emptyCatalogLayout, sn as entitySkeletonHtml, Jt as followJobProgress, Dn as islandNames, wn as javImageKind, an as matchesFaceSource, On as mountIsland, on as nativeImageFit, Cn as normalizeJavImage, xn as normalizeJavLayout, Sn as normalizeJavPreferences, rn as refreshStore, fn as sidebarHasCatalogContent, mn as sidebarTagCounts, nn as storeNames, Tn as syncJavImages, pn as syncSidebarSurface, vn as tasteHistoryGuideHtml, kn as unmountIsland, qt as watchJob, bn as wireTasteHistoryGuide };