Skip to content

armgit / peach

Public Imported from GitHub
0

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

feat: 完成 CloudDrive 来源引导、挂载映射与状态配置

longmeidaofadf78015766
diff --git a/README.md b/README.md
index cf7171730..60176748d 100644
--- a/README.md
+++ b/README.md
@@ -35,6 +35,11 @@ Peach 在一台机器上就能完整运行,目前处于 pre-1.0 阶段。Windo
## 数据边界
+CloudDrive 在首次设置页与配置页按文件夹选择「CloudDrive · 115」或「CloudDrive · PikPak」。
+先在 CloudDrive 登录对应网盘并完成挂载,再把本机文件夹填入 Peach;Windows 使用盘符路径,
+macOS 同时填写本机挂载点及对应的 Windows 账本根目录。配置页的「挂载状态」可刷新检查各来源。
+离线来源可保存,恢复挂载后再扫描。详细步骤见 [CloudDrive 配置](docs/OPERATIONS.md#clouddrive-配置)。
+
Ledger 是资产、身份、行为和复核决定的真相源。CloudDrive、在线站点和 AI 都是适配器或候选来源,不能直接改写真相字段。
| 内容 | 位置或规则 |
diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md
index a0858bba7..3f6857f0c 100644
--- a/docs/HANDOFF.md
+++ b/docs/HANDOFF.md
@@ -131,7 +131,7 @@ React 渲染的规格页、用户截图这类给不出可重抓字节的实测
## 运行与部署
-命令、顺序、失败表现和踩过的坑见 `docs/OPERATIONS.md`,这里只留边界。
+CloudDrive 配置与运维步骤见 `docs/OPERATIONS.md`。
- 源码部署由项目 venv 持有服务,刷新入口为 `scripts/restart_windows_tray.py`。独立测试包自带运行环境,数据在用户目录;配置更改由托盘消费标记并重启子服务。
- 「同步开发进度」(GitHub)和「同步 Ledger」(SMB 共享)是两条独立通道,任一方不可达都不该拖住另一方;服务只观察角色不自动复制。
diff --git a/docs/OPERATIONS.md b/docs/OPERATIONS.md
index cbdf20871..df9ad19e0 100644
--- a/docs/OPERATIONS.md
+++ b/docs/OPERATIONS.md
@@ -6,6 +6,37 @@
## 首次运行与设置文件
+### CloudDrive 配置
+
+1. 在 CloudDrive 中登录网盘并建立挂载点,打开「启动时自动挂载」。步骤见
+ [CloudDrive 官方帮助](https://www.clouddrive2.com/help.html)。
+2. 在 Peach 首次设置页或独立包的「管理 → 配置」中添加文件夹,选择对应来源。
+ 115 使用来源 ID `115`,PikPak 使用 `pikpak`,本地磁盘使用 `local`;每个来源可有多个互不重叠的根。
+3. Windows 填本机盘符路径。macOS 的文件夹填本机挂载点,「账本根目录」填该来源原有的
+ Windows 盘符根,例如 `B:\` 对应 `/Volumes/CloudDrive/115`、`A:\` 对应
+ `/Volumes/CloudDrive/PikPak`。已有馆藏必须沿用原账本根目录。
+4. 保存配置,由托盘重新载入。配置页「挂载状态」逐根显示在线或离线;刷新状态保留尚未保存的输入。
+ Windows 的 Peach 与 CloudDrive 应在同一普通用户会话下运行;提升权限的进程可能看不到挂载盘。
+5. 勾选扫描时,托盘顺序扫描配置内的在线来源,离线根跳过。恢复挂载后可再次勾选扫描并保存。
+
+离线来源允许保留配置,重叠盘符根或本机挂载点会在对应行报错。来源判定沿用 `asset.location`,
+115/PikPak 进入既有网盘流量策略。保存配置不修改已有资产的来源归属和账本路径。
+源码部署使用配置文件管理;首次网页引导支持相同来源,终端 `peach init` 的目录问答用于本地来源。
+
+对应 macOS 配置示例:
+
+```toml
+[media.locations]
+"115" = ['B:\']
+pikpak = ['A:\']
+
+[media.mounts]
+"115" = ['/Volumes/CloudDrive/115']
+pikpak = ['/Volumes/CloudDrive/PikPak']
+```
+
+### 初始化与托盘
+
- 配置完成之后,Windows 和有 TLS 的 macOS 托盘由 HTTP 导航进程与 HTTPS 业务进程组成;HTTP 的 `/healthz` 仅证明导航进程存活。业务入口 `/healthz?ready=1` 检查配置、页面、数据库查询和迁移校验和,不就绪返回 503;不带参数仍只探活。还没配置的机器上托盘只起一条引导服务,见下面的首次设置几条。
- wheel 将 `web`、`migrations`、`resources` 装入 `peach/_resources`。`scripts/smoke_wheel.py` 在仓库外使用安装 wheel 的解释器运行;CI 消费任务只下载制品,不检出源码。测试只使用临时数据根。
- 设置文件固定是 `<数据根>/config.toml`。数据根按三步找:环境变量 `PEACH_DATA_ROOT`、
diff --git a/docs/REUSE.md b/docs/REUSE.md
index ce96eab5a..4d0352ac7 100644
--- a/docs/REUSE.md
+++ b/docs/REUSE.md
@@ -5,6 +5,14 @@
## 复用决策门槛
+CloudDrive 引导复用现有 `settings_file`、`platform.root_online`、`scan_location` 和 Preact
+配置 island;来源仍为 `local`、`115`、`pikpak`。外部挂载由已安装的 CloudDrive 负责,
+[官方帮助](https://www.clouddrive2.com/help.html) 规定 Windows 使用盘符、macOS 使用目录挂载点。
+CloudDrive 为外部应用,本项目不捆绑其二进制或依赖其管理 API,也不保存网盘凭据;因此不引入
+非官方 CloudDrive SDK。路径处理复用 Python 标准库 `pathlib`、`os.scandir`、`tomllib`,
+不新增依赖。最小实证使用盘符 `A:/`、`B:/` 与 macOS 挂载形状,验证配置往返、重叠拒绝和
+读取目录失败的离线结果;Peach 保留表单、来源归属及扫描选择。
+
- 抓取入口的复用缺口与证据统一见 [抓取复用审计](SCRAPING_AUDIT.md) 和 [逐脚本 CSV](scraping-audit.csv);
跨用户安装、来源网络、Cookie GUI、最高可得画质与图像清单按 [ADR-0024](adr/0024-mark-manifest-not-bundled-bytes.md)。
私有后缀判断采用 tldextract 5.3.2(BSD-3-Clause、Python ≥3.10、平台无关),使用随包 PSL、
diff --git a/frontend/src/islands/configuration.tsx b/frontend/src/islands/configuration.tsx
index 400ff341e..45b0f6628 100644
--- a/frontend/src/islands/configuration.tsx
+++ b/frontend/src/islands/configuration.tsx
@@ -30,6 +30,8 @@ export interface ConfigurationData {
/** 设置文件的指纹,保存时带回去,服务端据此拒绝盖掉别处的改动。 */
revision: string;
media_dirs: string[];
+ media_sources?: { location: string; root: string; path: string; online?: boolean }[];
+ windows?: boolean;
port: number;
facts: ConfigurationFact[];
}
@@ -87,8 +89,36 @@ function Facts({ facts }: { facts: ConfigurationFact[] }) {
);
}
+function MountStatus({ data }: { data: ConfigurationData }) {
+ const [sources, setSources] = useState(data.media_sources);
+ const [error, setError] = useState('');
+ const controller = useRef<AbortController | null>(null);
+ useEffect(() => () => controller.current?.abort(), []);
+ const refresh = async (button: HTMLButtonElement) => {
+ if (controller.current) return;
+ const request = new AbortController(); controller.current = request;
+ setActionBusy(button, true); setError('');
+ try {
+ const result = await apiGet<ConfigurationData>(CONFIGURATION_URL, request.signal);
+ if (!request.signal.aborted) setSources(result.media_sources);
+ } catch (cause) {
+ if (!request.signal.aborted) setError(errorMessage(cause));
+ } finally { controller.current = null; setActionBusy(button, false); }
+ };
+ if (!sources) return null;
+ return <section class="configfieldset" aria-labelledby="configMountsTitle"><div class="geist-fieldset-content">
+ <Html html={fieldsetTitle('configMountsTitle', '挂载状态')} />
+ <dl class="configfacts">{sources.map((row) => <><dt>{row.location} · {row.root}</dt><dd>{row.path || '未配置挂载点'} · {row.online ? '在线' : '离线'}</dd></>)}</dl>
+ {error ? <p class="configbad" role="alert">{error}</p> : null}
+ <button type="button" class="geist-button" onClick={(event) => refresh(event.currentTarget)}>刷新挂载状态</button>
+ </div></section>;
+}
+
function ConfigurationForm({ data, receipt }: { data: ConfigurationData; receipt: ConfigurationProps['receipt'] }) {
- const [dirs, setDirs] = useState<string[]>(data.media_dirs.length ? data.media_dirs : ['']);
+ const initial = data.media_sources?.filter((row) => ['local', '115', 'pikpak'].includes(row.location));
+ const [dirs, setDirs] = useState<string[]>(initial?.length ? initial.map((row) => row.path) : data.media_dirs.length ? data.media_dirs : ['']);
+ const [kinds, setKinds] = useState<string[]>(initial?.map((row) => row.location) ?? []);
+ const [roots, setRoots] = useState<string[]>(initial?.map((row) => row.root) ?? []);
const [port, setPort] = useState(String(data.port));
const [scanNow, setScanNow] = useState(false);
const [rowErrors, setRowErrors] = useState<string[]>([]);
@@ -122,6 +152,8 @@ function ConfigurationForm({ data, receipt }: { data: ConfigurationData; receipt
setDirs((list) => [...list, '']);
};
const remove = (index: number) => {
+ setKinds((list) => list.filter((_, i) => i !== index));
+ setRoots((list) => list.filter((_, i) => i !== index));
setDirs((list) => list.filter((_, i) => i !== index));
setRowErrors((errors) => errors.filter((_, i) => i !== index));
};
@@ -160,6 +192,7 @@ function ConfigurationForm({ data, receipt }: { data: ConfigurationData; receipt
const result = await apiSend<SaveResult>(CONFIGURATION_URL, {
revision: revision.current,
media_dirs: dirs,
+ ...(data.media_sources ? { media_sources: dirs.map((path, i) => ({ path, location: kinds[i] || 'local', root: roots[i] || '' })) } : {}),
port,
scan_now: scanNow,
});
@@ -221,12 +254,24 @@ function ConfigurationForm({ data, receipt }: { data: ConfigurationData; receipt
<svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-x" /></svg>
</button>
) : null}
+ <div class="configsource">
+ <label>媒体来源
+ <select class="geist-input" aria-label={`媒体来源 ${index + 1}`} value={kinds[index] || 'local'}
+ onChange={(event) => { const next = [...kinds]; next[index] = event.currentTarget.value; setKinds(next); }}>
+ <option value="local">本地磁盘</option><option value="115">CloudDrive · 115</option><option value="pikpak">CloudDrive · PikPak</option>
+ </select>
+ </label>
+ {data.windows === false ? <label>账本根目录
+ <input class="geist-input" aria-label={`账本根目录 ${index + 1}`} value={roots[index] || ''} placeholder="例如 B:\\"
+ onInput={(event) => { const next = [...roots]; next[index] = event.currentTarget.value; setRoots(next); }} />
+ </label> : null}
+ </div>
{rowErrors[index] ? <p class="configbad" role="alert">{rowErrors[index]}</p> : null}
</div>
))}
</div>
<button type="button" class="geist-button configadd" onClick={add}>添加文件夹</button>
- <p class="confighelp">Peach 从这些文件夹读取视频和图片。可以是外置硬盘上的文件夹,但必须已经存在。</p>
+ <p class="confighelp">CloudDrive:先登录网盘并挂载,再选择对应的 115 或 PikPak 来源。macOS 填本机挂载点与对应的账本盘符根。<a href="https://www.clouddrive2.com/help.html" target="_blank" rel="noreferrer">挂载帮助</a></p>
</div>
<div class="configfield">
<label for="configPort">本机访问端口</label>
@@ -269,6 +314,7 @@ export function Configuration({ receipt, data, error }: ConfigurationProps & Sta
? <ConfigurationForm data={data} receipt={receipt} />
: <Html html={noteHtml(data.notice, { variant: 'secondary', label: '只读' })} />}
<Facts facts={data.facts} />
+ <MountStatus data={data} />
</div>
);
}
diff --git a/frontend/test/configuration.test.tsx b/frontend/test/configuration.test.tsx
index f33f1a789..9199e92b8 100644
--- a/frontend/test/configuration.test.tsx
+++ b/frontend/test/configuration.test.tsx
@@ -23,7 +23,7 @@ const mount = (props: Partial<ConfigurationData> = {}, receipt = vi.fn()) => {
return { el, receipt };
};
-const inputs = (el: Element) => [...el.querySelectorAll<HTMLInputElement>('.configdir .geist-input')];
+const inputs = (el: Element) => [...el.querySelectorAll<HTMLInputElement>('.configdir > input')];
const submit = (el: Element) => {
el.querySelector('form')?.dispatchEvent(new Event('submit', { cancelable: true }));
};
@@ -55,6 +55,34 @@ describe('配置页取数', () => {
});
describe('媒体文件夹列表', () => {
+ it('刷新挂载状态保留未保存的路径', async () => {
+ const media_sources = [{ location: '115', path: 'B:/', root: 'B:/', online: false }];
+ vi.stubGlobal('fetch', fetchMock(200, data({media_sources: [{ ...media_sources[0]!, online: true }]})));
+ const { el } = mount({ windows: true, media_sources });
+ const input = inputs(el)[0]!;
+ input.value = 'B:/Movies'; input.dispatchEvent(new Event('input')); await settle();
+ [...el.querySelectorAll<HTMLButtonElement>('button')].find((button) => button.textContent === '刷新挂载状态')?.click();
+ await settle();
+ expect(inputs(el)[0]?.value).toBe('B:/Movies');
+ expect(el.textContent).toContain('在线');
+ });
+ it('按来源回填所有挂载点,提交时保留 macOS 盘符映射', async () => {
+ const fetch = fetchMock(200, { saved: true, url: '/', revision: 'rev-2' });
+ vi.stubGlobal('fetch', fetch);
+ const { el } = mount({ windows: false, media_sources: [
+ { location: '115', root: 'B:\\', path: '/Volumes/115', online: false },
+ { location: 'pikpak', root: 'A:\\', path: '/Volumes/PikPak', online: true },
+ ] });
+ expect(inputs(el).map((input) => input.value)).toEqual(['/Volumes/115', '/Volumes/PikPak']);
+ expect(el.textContent).toContain('离线');
+ expect(el.textContent).toContain('在线');
+ submit(el); await settle();
+ const body = JSON.parse(String(fetch.mock.calls[0]?.[1].body));
+ expect(body.media_sources).toEqual([
+ { location: '115', root: 'B:\\', path: '/Volumes/115' },
+ { location: 'pikpak', root: 'A:\\', path: '/Volumes/PikPak' },
+ ]);
+ });
it('一行一个文件夹,只有一行时没有移除键', () => {
const { el } = mount();
expect(inputs(el).map((input) => input.value)).toEqual(['D:\\Media']);
diff --git a/scripts/test_runner.py b/scripts/test_runner.py
index a08b0e171..9dd14c1e3 100644
--- a/scripts/test_runner.py
+++ b/scripts/test_runner.py
@@ -54,7 +54,7 @@ SCOPES: dict[str, tuple[str, ...]] = {
"test_link_rediscovery.py", "test_link_label_owner.py",
"test_agency_entity.py"),
"tooling": ("test_scripts.py", "test_auth.py", "test_cli.py", "test_script_policy.py",
- "test_scan.py", "test_onboarding.py", "test_folder_picker.py", "test_ledger_backups.py",
+ "test_scan.py", "test_onboarding.py", "test_configuration_sources.py", "test_folder_picker.py", "test_ledger_backups.py",
"test_agent_worktree.py", "test_dependency_policy.py",
"test_restart_windows_tray.py",
"test_buildinfo.py", "test_versioning.py",
diff --git a/src/peach/cli.py b/src/peach/cli.py
index 16d30f9d4..4bf88eecd 100644
--- a/src/peach/cli.py
+++ b/src/peach/cli.py
@@ -438,6 +438,16 @@ def _scan(args: argparse.Namespace) -> int:
mounts = {location: tuple(str(mount) for mount in points)
for location, points in location_mounts().items()}
try:
+ if args.location == "configured" and args.root is None:
+ from .platform import root_online, translate_ledger_path
+ for location, declared in config.locations.items():
+ for root in declared:
+ if not root_online(translate_ledger_path(root)):
+ print(f"{location}:挂载点离线,未扫描", flush=True)
+ continue
+ scan.scan_location(args.db, location, root, declared_roots=config.locations,
+ mounts=mounts, report=lambda line: print(line, flush=True))
+ return 0
if args.root is None:
if args.location not in config.locations:
known = "、".join(sorted(config.locations)) or "(设置文件里一个都没有)"
diff --git a/src/peach/media_configuration.py b/src/peach/media_configuration.py
new file mode 100644
index 000000000..412786ddc
--- /dev/null
+++ b/src/peach/media_configuration.py
@@ -0,0 +1,63 @@
+"""媒体来源表单与配置映射;来源 ID 直接沿用扫描及流量策略。"""
+from __future__ import annotations
+
+from pathlib import Path, PureWindowsPath, PurePosixPath
+from typing import Any
+
+from . import platform
+
+SOURCE_OPTIONS = (("local", "本地磁盘"), ("115", "CloudDrive · 115"),
+ ("pikpak", "CloudDrive · PikPak"))
+
+
+def rows(config, *, windows: bool, probe: bool = False) -> list[dict[str, Any]]:
+ result = []
+ for location, roots in config.locations.items():
+ mounts = config.mounts.get(location, ())
+ for index, root in enumerate(roots):
+ mount = root if windows else (mounts[index] if index < len(mounts) else "")
+ result.append({"location": location, "root": root, "path": mount,
+ "online": platform.root_online(Path(mount)) if probe and mount else False})
+ return result
+
+
+def validate(raws: object, *, windows: bool) -> tuple[dict, dict, list[str]]:
+ """离线来源允许保存;绝对路径、盘符根与来源间重叠在保存前校验。"""
+ if not isinstance(raws, list) or not raws or len(raws) > 100:
+ return {}, {}, ["请添加 1 到 100 个媒体文件夹"]
+ locations: dict[str, list[str]] = {}
+ mounts: dict[str, list[str]] = {}
+ errors = [""] * len(raws)
+ seen: list[tuple[int, PureWindowsPath, Path]] = []
+ for index, row in enumerate(raws):
+ try:
+ if not isinstance(row, dict):
+ raise ValueError("媒体来源格式不正确")
+ location = row.get("location")
+ if location not in dict(SOURCE_OPTIONS):
+ raise ValueError("请选择本地磁盘、115 或 PikPak")
+ text = str(row.get("path", "")).strip()
+ root = text if windows else str(row.get("root", "")).strip()
+ if not platform.is_windows_path(root) or ".." in PureWindowsPath(root).parts:
+ raise ValueError("账本根目录必须是绝对盘符路径,例如 B:\\")
+ path = PureWindowsPath(text) if windows else PurePosixPath(text)
+ if not text or not (platform.is_windows_path(text) if windows else text.startswith("/")):
+ raise ValueError("请填写本机挂载点的绝对路径")
+ if ".." in path.parts:
+ raise ValueError("挂载点不能包含上级目录 ..")
+ declared = PureWindowsPath(root)
+ for _, other_root, other_path in seen:
+ if (declared == other_root or declared.is_relative_to(other_root)
+ or other_root.is_relative_to(declared)):
+ raise ValueError("账本根目录与另一行重复或重叠")
+ if path == other_path or path.is_relative_to(other_path) or other_path.is_relative_to(path):
+ raise ValueError("本机挂载点与另一行重复或重叠")
+ seen.append((index, declared, path))
+ locations.setdefault(location, []).append(str(declared))
+ if not windows:
+ mounts.setdefault(location, []).append(str(path))
+ except ValueError as exc:
+ errors[index] = str(exc)
+ return ({key: tuple(value) for key, value in locations.items()},
+ {key: tuple(value) for key, value in mounts.items()},
+ errors if any(errors) else [])
diff --git a/src/peach/onboarding.py b/src/peach/onboarding.py
index 786188746..ed2fed289 100644
--- a/src/peach/onboarding.py
+++ b/src/peach/onboarding.py
@@ -6,9 +6,9 @@
`PeachConfig`,`apply()` 把它变成一台能直接起服务的机器(目录、账本、CA、口令、设置
文件)。前端只负责把字串送进来、把结果和错误显示出去。
-问答刻意只收最小集合:数据根、一个或几个本地媒体目录、监听范围、端口、局域网名字。复制、
-115、PikPak、writer 镜像与 SMB 一律保持默认关闭或留空——陌生人第一次跑不该被这些问题
-拦住,设置文件里也只写用户声明过的来源,不把维护者的示例盘符写进别人的文件。
+终端问答收集数据根、本地媒体目录、监听范围、端口和局域网名字。网页引导另按每个目录收集
+本地、115 或 PikPak 来源及 macOS 映射,校验由 `media_configuration` 负责。复制、writer
+镜像与 SMB 保持关闭或留空,设置文件只写用户声明过的来源。
媒体目录在两个平台上落成不同的写法,因为账本路径的形状是不变量(AGENTS.md):
@@ -17,7 +17,7 @@
`[media.mounts] local = <这些目录>` 按同样顺序给出,读取侧按「声明根前缀 → 本机挂载点」
翻译(`peach.platform`),扫描侧按同一规则反着写(`peach.scan`)。
-几个目录都归同一个来源 `local`:它们是同一块馆藏的几个落点,不是几种来源。
+终端问答的目录归 `local`;网页引导用 `Answers.media_sources` 保存逐行选择。
"""
from __future__ import annotations
@@ -91,6 +91,7 @@ class Answers:
host: str
port: int
mdns_name: str
+ media_sources: list[dict[str, str]] | None = None
# --------------------------------------------------------------------------- 校验
@@ -324,7 +325,7 @@ def interview(
def configure(config: PeachConfig, answers: Answers, *, windows: bool) -> PeachConfig:
"""把答案落成一份可写回的设置。`config` 要按 `answers.data_root` 重新解析过。
- 只写用户声明过的来源:`[media.locations]` 里只有 `local`,几个目录就几个声明根。
+ 只写用户声明过的来源;网页答案包含逐行来源及映射,终端答案按本地目录处理。
复制保持关闭,writer 镜像与 SMB 坐标留空,目录键全部落成显式值——和非交互
`peach init` 同一形状。
"""
@@ -334,6 +335,11 @@ def configure(config: PeachConfig, answers: Answers, *, windows: bool) -> PeachC
else:
locations = {LOCAL_LOCATION: posix_declared_roots(len(answers.media_dirs))}
mounts = {LOCAL_LOCATION: tuple(str(path) for path in answers.media_dirs)}
+ if answers.media_sources is not None:
+ from . import media_configuration
+ locations, mounts, errors = media_configuration.validate(answers.media_sources, windows=windows)
+ if errors:
+ raise ValueError(";".join(error for error in errors if error))
prepared = settings_file.capture_existing(
config, replication_enabled=False,
overrides={"host": answers.host, "port": answers.port,
diff --git a/src/peach/routes_configuration.py b/src/peach/routes_configuration.py
index 9ead02c9f..f7145d3c8 100644
--- a/src/peach/routes_configuration.py
+++ b/src/peach/routes_configuration.py
@@ -16,7 +16,7 @@ from typing import Any
from fastapi import APIRouter, Body, Depends, HTTPException, Request
-from . import distribution, folder_picker, onboarding, settings_file
+from . import distribution, folder_picker, onboarding, settings_file, media_configuration
from .routes_auth import require_auth
from .routes_pages import runtime_facts
@@ -62,6 +62,8 @@ def snapshot(config) -> dict[str, Any]:
"notice": "" if editable else FILE_MANAGED_NOTICE,
"revision": revision(config),
"media_dirs": list(media),
+ "media_sources": media_configuration.rows(config, windows=os.name == "nt", probe=True),
+ "windows": os.name == "nt",
"port": config.server.port,
"facts": [{"term": term, "value": value} for term, value in runtime_facts(config)],
}
@@ -82,8 +84,13 @@ def _validate(body: dict[str, Any], config) -> tuple[dict[str, Any], dict[str, A
validated: dict[str, Any] = {}
raws = body.get("media_dirs")
rows = [str(item) for item in raws] if isinstance(raws, list) else [str(raws or "")]
- paths, problems = onboarding.read_media_dirs(
- rows, validate=onboarding.media_dir_validator(windows=os.name == "nt"))
+ if "media_sources" in body:
+ locations, mounts, problems = media_configuration.validate(body["media_sources"], windows=os.name == "nt")
+ paths = []
+ validated.update(locations=locations, mounts=mounts)
+ else:
+ paths, problems = onboarding.read_media_dirs(
+ rows, validate=onboarding.media_dir_validator(windows=os.name == "nt"))
if problems:
errors["media_dirs"] = problems
else:
@@ -143,7 +150,13 @@ def save_configuration(request: Request, body: dict[str, Any] = Body(default_fac
raise HTTPException(400, {"message": "有几项需要修改", "errors": errors})
paths = validated["media_dirs"]
locations, mounts = dict(config.locations), dict(config.mounts)
- if os.name == "nt":
+ if "locations" in validated:
+ locations, mounts = validated["locations"], validated["mounts"]
+ for key in set(config.locations) - dict(media_configuration.SOURCE_OPTIONS).keys():
+ locations[key] = config.locations[key]
+ if key in config.mounts:
+ mounts[key] = config.mounts[key]
+ elif os.name == "nt":
locations["local"] = tuple(str(path) for path in paths)
else:
locations["local"] = onboarding.posix_declared_roots(len(paths))
@@ -156,7 +169,7 @@ def save_configuration(request: Request, body: dict[str, Any] = Body(default_fac
temporary.write_text(settings_file.render(prepared), encoding="utf-8")
os.replace(temporary, config.path)
if body.get("scan_now"):
- onboarding.request_first_scan(prepared)
+ onboarding.request_first_scan(prepared, "configured")
config.directory("state").mkdir(parents=True, exist_ok=True)
(config.directory("state") / RELOAD_NAME).write_text("reload", encoding="utf-8")
except OSError as exc:
diff --git a/src/peach/routes_pages.py b/src/peach/routes_pages.py
index 57e7cf9e2..fbf711c38 100644
--- a/src/peach/routes_pages.py
+++ b/src/peach/routes_pages.py
@@ -127,6 +127,10 @@ button[type=submit]:hover{background:color-mix(in srgb,var(--ink) 88%,var(--grou
.dir{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}
.dir:first-child{margin-top:0}.dir .bad{flex-basis:100%;margin:0}
.dir input[type=text]{flex:1 1 auto;width:auto;min-width:0}
+.dir > input[type=text]{flex:1 1 0;width:0}
+.sourcefields{flex-basis:100%;display:grid;gap:8px;min-width:0}
+.sourcefields select{width:100%;height:var(--control-h);border:1px solid var(--line-soft);border-radius:var(--control-radius);background:var(--surface);color:var(--ink);padding:0 12px;font:inherit}
+.sourcefields select:focus-visible{outline:2px solid var(--tungsten);outline-offset:2px}
.rm,.pick,.add{height:var(--control-h);border:1px solid var(--line);border-radius:var(--control-radius);
background:var(--ground);color:var(--ink);cursor:pointer;font:500 var(--fs-sm) system-ui,sans-serif}
.rm,.pick{width:var(--control-h);flex:none;display:grid;place-items:center;color:var(--muted)}
@@ -138,6 +142,7 @@ stroke-linejoin:round}
.rm[hidden],.pick[hidden],.add[hidden]{display:none}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
@media(max-width:760px){input[type=text],input[type=number]{font-size:16px}}
+@media(max-width:560px){body{--control-h:44px}.sourcefields select{font-size:var(--fs-lg)}}
@media(max-width:440px){body{padding:24px 20px}h1{font-size:var(--fs-2xl)}}
</style>"""
@@ -336,7 +341,13 @@ def _copy_for(key: str, fallback: str) -> tuple[str, str]:
return _SETUP_COPY.get(key, (fallback, ""))
-def _media_dir_row(value: str, error: str, *, first: bool) -> str:
+def _media_dir_row(value: str, error: str, *, first: bool, location: str = "local", root: str = "", windows: bool = True) -> str:
+ from .media_configuration import SOURCE_OPTIONS
+ source = '<select name="media_location" aria-label="媒体来源">' + ''.join(
+ f'<option value="{key}"{" selected" if key == location else ""}>{label}</option>'
+ for key, label in SOURCE_OPTIONS) + '</select>'
+ mapping = (f'<input name="media_root" type="text" aria-label="账本根目录" '
+ f'placeholder="账本根目录,例如 B:\\" value="{escape(root, quote=True)}">') if not windows else ''
attrs = ' id="f-media_dir" required' if first else ' aria-label="媒体文件夹"'
return (f'<div class="dir"><input name="media_dir" type="text"{attrs} autocomplete="off" '
f'spellcheck="false" aria-invalid="{"true" if error else "false"}" '
@@ -344,10 +355,10 @@ def _media_dir_row(value: str, error: str, *, first: bool) -> str:
f'<button type="button" class="pick" aria-label="选择文件夹" hidden>{_FOLDER_SVG}</button>'
f'<button type="button" class="rm" aria-label="移除这个文件夹" hidden>{_X_SVG}</button>'
+ (f'<p class="bad" role="alert">{escape(error)}</p>' if error else "")
- + "</div>")
+ + f'<div class="sourcefields">{source}{mapping}</div></div>')
-def _media_dirs_html(values: Sequence[str], errors: Sequence[str], note: str) -> str:
+def _media_dirs_html(values: Sequence[str], errors: Sequence[str], note: str, *, locations=(), roots=(), windows=True) -> str:
"""媒体文件夹列表:每行一个输入框,行尾是移除键,列表下是「添加文件夹」。
移除键和添加键都带 `hidden`,由页面脚本亮出来:没有脚本时它们什么都做不了,与其留
@@ -357,14 +368,18 @@ def _media_dirs_html(values: Sequence[str], errors: Sequence[str], note: str) ->
title, help_text = _copy_for("media_dir", "媒体文件夹")
rows = list(values) or [""]
body = "".join(
- _media_dir_row(value, errors[index] if index < len(errors) else "", first=index == 0)
+ _media_dir_row(value, errors[index] if index < len(errors) else "", first=index == 0,
+ location=locations[index] if index < len(locations) else "local",
+ root=roots[index] if index < len(roots) else "", windows=windows)
for index, value in enumerate(rows))
return (
'<div class="field">'
f'<label for="f-media_dir"><span class="req" aria-hidden="true">*</span>{escape(title)}</label>'
f'<div class="dirs" id="dirs">{body}</div>'
'<button type="button" class="add" id="add-dir" hidden>添加文件夹</button>'
- f'<template id="dir-row">{_media_dir_row("", "", first=False)}</template>'
+ f'<template id="dir-row">{_media_dir_row("", "", first=False, windows=windows)}</template>'
+ '<p class="help">CloudDrive:先在 CloudDrive 登录网盘并挂载,再选择对应的 115 或 PikPak 来源。'
+ '<a href="https://www.clouddrive2.com/help.html" target="_blank" rel="noreferrer">挂载帮助</a></p>'
+ "".join(f'<p class="help">{escape(line)}</p>' for line in (help_text, note) if line)
+ "</div>"
)
@@ -433,7 +448,9 @@ def setup_page(
row_errors = errors.get("media_dir", [])
note = "" if windows else onboarding.mounts_explanation(
[path for path in media_dirs if path] or ["你在上面填的目录"])
- fields.append(_media_dirs_html(media_dirs, list(row_errors), note))
+ fields.append(_media_dirs_html(media_dirs, list(row_errors), "" if windows else
+ "本机文件夹填写 macOS 挂载点;账本根目录填写对应的 Windows 盘符路径。",
+ locations=values.get("media_location", ()), roots=values.get("media_root", ()), windows=windows))
continue
value = str(values.get(question.key, question.default))
field = _field_html(question, value, str(errors.get(question.key, "")), "")
@@ -616,6 +633,9 @@ async def setup_submit(request: Request):
submitted: dict[str, object] = {key: (value or [""])[0] for key, value in form.items()}
# 媒体文件夹是一个列表:几行输入框同名提交,回显时也要原样给回几行。
submitted["media_dir"] = list(form.get("media_dir", []))
+ for key in ("media_location", "media_root"):
+ if key in form:
+ submitted[key] = list(form[key])
scan_now = "scan_now" in form
config = settings_file.active()
@@ -645,7 +665,7 @@ async def setup_submit(request: Request):
return HTMLResponse(setup_page(config, windows=windows, values=submitted,
errors={"data_root": str(exc)}, scan_now=scan_now), status_code=400)
if scan_now:
- onboarding.request_first_scan(applied.config)
+ onboarding.request_first_scan(applied.config, "configured" if answers.media_sources is not None else "local")
response = HTMLResponse(setup_done_page(applied, windows=windows, scan_requested=scan_now))
if distribution.standalone():
response.set_cookie("tok", auth.read_token(applied.config.directory("secrets")),
@@ -665,6 +685,18 @@ def _read_answers(
errors: dict[str, object] = {}
for question in onboarding.questions(config, windows=windows):
if question.key == "media_dir":
+ if "media_location" in submitted:
+ from . import media_configuration
+ dirs = _media_dir_values(submitted, question.default)
+ kinds = submitted["media_location"]
+ roots = submitted.get("media_root", [])
+ sources = [{"location": kinds[i] if i < len(kinds) else "local", "path": path,
+ "root": roots[i] if i < len(roots) else ""} for i, path in enumerate(dirs)]
+ _, _, problems = media_configuration.validate(sources, windows=windows)
+ if problems:
+ errors["media_dir"] = problems
+ values.update(media_dirs=tuple(Path(path) for path in dirs), media_sources=sources)
+ continue
paths, problems = onboarding.read_media_dirs(
_media_dir_values(submitted, ""), validate=question.validate,
default=question.default)
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 715be8d9a..b6ecb5d74 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -493,6 +493,17 @@ class ScanCommandTests(unittest.TestCase):
self.assertIn("✓ local: 2 文件", output)
self.assertEqual(self._count(), 2)
+ def test_configured_scan_uses_each_online_source_id(self):
+ fixed = replace(settings_file.active(), locations={'115': ('B:/',), 'pikpak': ('A:/',)})
+ with mock.patch.object(settings_file, 'active', return_value=fixed), \
+ mock.patch('peach.platform.root_online', side_effect=[False, True]), \
+ mock.patch.object(cli.scan, 'scan_location') as scanner:
+ code, output = self._run(['scan', 'configured', '--db', str(self.db)])
+ self.assertEqual(code, 0)
+ self.assertIn('115', output)
+ self.assertEqual(scanner.call_count, 1)
+ self.assertEqual(scanner.call_args.args[1:3], ('pikpak', 'A:/'))
+
def test_an_explicit_subdirectory_is_scanned_alone(self):
code, _ = self._run(["scan", "local", str(self.media / "sub"), "--db", str(self.db)])
self.assertEqual(code, 0)
diff --git a/tests/test_configuration_sources.py b/tests/test_configuration_sources.py
new file mode 100644
index 000000000..670f0cb35
--- /dev/null
+++ b/tests/test_configuration_sources.py
@@ -0,0 +1,66 @@
+"""CloudDrive 表单、来源映射与离线状态的隔离回归。"""
+from dataclasses import replace
+from pathlib import Path
+import tempfile
+import unittest
+from unittest.mock import patch
+
+from peach import media_configuration as media_config, onboarding, settings_file
+
+
+class MediaConfigurationTests(unittest.TestCase):
+ def test_windows_cloud_sources_keep_policy_ids_and_offline_roots(self):
+ roots, mounts, errors = media_config.validate([
+ {"location": "115", "path": "B:/"}, {"location": "pikpak", "path": "A:/"},
+ ], windows=True)
+ self.assertFalse(errors)
+ self.assertEqual(roots, {"115": ("B:\\",), "pikpak": ("A:\\",)})
+ self.assertEqual(mounts, {})
+
+ def test_macos_multiple_mounts_preserve_declared_root_order(self):
+ roots, mounts, errors = media_config.validate([
+ {"location": "115", "root": "B:/Movies", "path": "/Volumes/115/Movies"},
+ {"location": "115", "root": "B:/Photos", "path": "/Volumes/115/Photos"},
+ ], windows=False)
+ self.assertFalse(errors)
+ self.assertEqual(roots["115"], ("B:\\Movies", "B:\\Photos"))
+ self.assertEqual(mounts["115"], ("/Volumes/115/Movies", "/Volumes/115/Photos"))
+
+ def test_invalid_and_overlapping_roots_return_row_errors(self):
+ for rows in ([{"location": "bad", "path": "B:/"}],
+ [{"location": "115", "path": "../115"}],
+ [{"location": "115", "path": "B:/"}, {"location": "local", "path": "b:/Movies"}]):
+ self.assertTrue(media_config.validate(rows, windows=True)[2])
+
+ def test_cloud_only_setup_roundtrips_config_without_local_source(self):
+ with tempfile.TemporaryDirectory() as directory:
+ base = Path(directory).resolve()
+ config = settings_file.load_config(environ={"PEACH_DATA_ROOT": str(base)})
+ answers = onboarding.Answers(base, (), "127.0.0.1", 8900, "peach", [
+ {"location": "115", "path": "/Volumes/115", "root": "B:/"}])
+ prepared = onboarding.configure(config, answers, windows=False)
+ settings_file.write(prepared)
+ loaded = settings_file.load_config(environ={"PEACH_DATA_ROOT": str(base)})
+ self.assertEqual(loaded.locations, {"115": ("B:\\",)})
+ self.assertEqual(loaded.mounts, {"115": ("/Volumes/115",)})
+ self.assertFalse((base / "database" / "ledger.db").exists())
+
+ def test_unreadable_existing_mount_is_offline(self):
+ config = replace(settings_file.PeachConfig(Path('/unused'), Path('/unused/config.toml')), locations={"115": ("B:/",)}, mounts={"115": ("/Volumes/115",)})
+ with patch("peach.platform.os.scandir", side_effect=OSError("Device not configured")):
+ self.assertFalse(media_config.rows(config, windows=False, probe=True)[0]["online"])
+
+ def test_setup_post_reader_keeps_cloud_source_and_inline_error(self):
+ from peach.routes_pages import _read_answers, setup_page
+ with tempfile.TemporaryDirectory() as directory:
+ base = Path(directory).resolve()
+ config = settings_file.load_config(environ={"PEACH_DATA_ROOT": str(base)})
+ submitted = {"data_root": str(base), "media_dir": ["/Volumes/115"],
+ "media_location": ["115"], "media_root": ["B:/"], "host": "1"}
+ answers, errors = _read_answers(config, submitted, windows=False)
+ self.assertFalse(errors)
+ self.assertEqual(answers.media_sources[0]["location"], "115")
+ html = setup_page(config, windows=False, values=submitted)
+ self.assertIn('value="115" selected', html)
+ self.assertIn('name="media_root"', html)
+ self.assertIn('value="B:/"', html)
diff --git a/tests/test_onboarding.py b/tests/test_onboarding.py
index c756f0a6f..6e0b8d662 100644
--- a/tests/test_onboarding.py
+++ b/tests/test_onboarding.py
@@ -452,7 +452,8 @@ class SetupPageTests(_Case):
self.assertEqual(body.count('<span class="req"'), 4)
# 「谁可以访问」是两段式单选,不用原生下拉;两个选项由 `HOST_OPTIONS` 给出,
# 局域网在左边并且默认选中。
- self.assertNotIn("<select", body)
+ self.assertNotIn('<select name="host"', body)
+ self.assertIn('<select name="media_location"', body)
self.assertIn('class="switch" role="radiogroup"', body)
for value, label in onboarding.HOST_OPTIONS:
self.assertIn(f'<input type="radio" name="host" value="{value}"', body)
@@ -681,6 +682,24 @@ class StandaloneConfigurationTests(_Case):
self.assertTrue(body["errors"]["port"])
self.assertEqual(before, self.config.path.read_bytes())
+ def test_cloud_configuration_saves_all_sources_and_requests_configured_scan(self):
+ from peach.routes_configuration import revision
+ from peach import media_configuration
+ with self.client() as client:
+ response = client.post('/api/configuration', headers={'X-Token': 'test-token'}, json={
+ 'revision': revision(self.config), 'port': 9123, 'scan_now': True,
+ 'media_sources': [
+ {'location': '115', 'path': str(self.media), 'root': 'B:/'},
+ ]})
+ self.assertEqual(response.status_code, 200, response.text)
+ saved = settings_file.load_config()
+ self.assertEqual(set(saved.locations), {'115'})
+ self.assertEqual(onboarding.take_first_scan_request(saved), 'configured')
+ snapshot = client.get('/api/configuration', headers={'X-Token': 'test-token'}).json()
+ self.assertEqual(snapshot['media_sources'][0]['location'], '115')
+ self.assertTrue(snapshot['media_sources'][0]['online'])
+ self.assertFalse((saved.directory('database') / 'ledger.db').exists())
+
def test_settings_reject_unauthenticated_remote_cross_origin_and_stale_forms(self):
from peach.routes_configuration import revision
data = {"revision": revision(self.config), "media_dirs": [str(self.media)], "port": "9124"}
diff --git a/web/css/23-configuration.css b/web/css/23-configuration.css
index 25aff4a58..0dfa5db1b 100644
--- a/web/css/23-configuration.css
+++ b/web/css/23-configuration.css
@@ -18,12 +18,17 @@
flex 而不是 grid:只剩一行时移除键不画,grid 的空轨道会留下一段 gap。 */
.configdir{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}
.configdir .geist-input{flex:1 1 auto;width:auto;min-width:0}
+.configdir > input.geist-input{flex:1 1 0;width:0}
.configdir:first-child{margin-top:0}.configdir .configbad{flex-basis:100%;margin:0}
.configrm.geist-button,.configpick.geist-button{width:var(--control-h);height:var(--control-h);flex:none;padding:0;color:var(--muted)}
.configrm.geist-button:hover:not(:disabled),.configpick.geist-button:hover:not(:disabled){color:var(--ink)}
.configrm svg,.configpick svg{width:16px;height:16px;stroke:currentColor;fill:none}
.configadd{margin-top:8px}
+.configsource{flex-basis:100%;display:grid;grid-template-columns:repeat(auto-fit,minmax(min(220px,100%),1fr));gap:8px}
+.configsource label{min-width:0;display:grid;gap:6px;font-size:var(--fs-sm);color:var(--muted)}
+.configsource .geist-input{width:100%;box-sizing:border-box}
.configcheck{display:flex;align-items:center;gap:12px;min-height:32px;cursor:pointer;color:var(--ink)}
.configfacts{margin:0;display:grid;grid-template-columns:max-content minmax(0,1fr);gap:10px 24px;align-items:baseline}
.configfacts dt{color:var(--muted);font-size:var(--fs-sm)}.configfacts dd{margin:0;overflow-wrap:anywhere}
@media(max-width:560px){.configfacts{grid-template-columns:minmax(0,1fr)}.configfacts dd{margin-top:-6px}}
+@media(max-width:560px){.configpage{--control-h:44px}.configfieldset>.geist-fieldset-footer{flex-wrap:wrap}.configsource .geist-input{font-size:var(--fs-lg)}}
diff --git a/web/dist/peach-ui.js b/web/dist/peach-ui.js
index 022e3c569..a554bcddd 100644
--- a/web/dist/peach-ui.js
+++ b/web/dist/peach-ui.js
@@ -6,16 +6,16 @@ function O(e, t) {
for (var n in t) e[n] = t[n];
return e;
}
-function ee(e) {
+function k(e) {
e && e.parentNode && e.parentNode.removeChild(e);
}
-function k(e, t, n) {
+function A(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 ? l.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 A(e, o, r, i, null);
+ return j(e, o, r, i, null);
}
-function A(e, t, n, r, i) {
+function j(e, t, n, r, i) {
var a = {
type: e,
props: t,
@@ -33,62 +33,62 @@ function A(e, t, n, r, i) {
};
return i == null && u.vnode != null && u.vnode(a), a;
}
-function j(e) {
+function M(e) {
return e.children;
}
-function M(e, t) {
+function N(e, t) {
this.props = e, this.context = t;
}
-function N(e, t) {
- if (t == null) return e.__ ? N(e.__, e.__i + 1) : null;
+function P(e, t) {
+ if (t == null) return e.__ ? P(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" ? N(e) : null;
+ return typeof e.type == "function" ? P(e) : null;
}
-function te(e) {
+function ee(e) {
if (e.__P && e.__d) {
var t = e.__v, n = t.__e, r = [], i = [], a = O({}, t);
- a.__v = t.__v + 1, u.vnode && u.vnode(a), fe(e.__P, a, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [n] : null, r, n ?? N(t), !!(32 & t.__u), i), a.__v = t.__v, a.__.__k[a.__i] = a, me(r, a, i), t.__e = t.__ = null, a.__e != n && ne(a);
+ a.__v = t.__v + 1, u.vnode && u.vnode(a), de(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, pe(r, a, i), t.__e = t.__ = null, a.__e != n && te(a);
}
}
-function ne(e) {
+function te(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;
- }), ne(e);
+ }), te(e);
}
-function re(e) {
- (!e.__d && (e.__d = !0) && p.push(e) && !ie.__r++ || m != u.debounceRendering) && ((m = u.debounceRendering) || h)(ie);
+function ne(e) {
+ (!e.__d && (e.__d = !0) && p.push(e) && !re.__r++ || m != u.debounceRendering) && ((m = u.debounceRendering) || h)(re);
}
-function ie() {
+function re() {
try {
- for (var e, t = 1; p.length;) p.length > t && p.sort(g), e = p.shift(), t = p.length, te(e);
+ for (var e, t = 1; p.length;) p.length > t && p.sort(g), e = p.shift(), t = p.length, ee(e);
} finally {
- p.length = ie.__r = 0;
+ p.length = re.__r = 0;
}
}
-function ae(e, t, n, r, i, a, o, s, c, l, u) {
+function ie(e, t, n, r, i, a, o, s, c, l, u) {
var d, f, p, m, h, g, _ = r && r.__k || T, v = t.length;
- for (c = oe(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && _[p.__i] || w, p.__i = d, g = fe(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && _e(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h == null && m != null && (h = m), 4 & p.__u ? (c = se(p, c, e), f.__e && (f.__e = null)) : typeof p.type == "function" && g !== void 0 ? c = g : m && (c = m.nextSibling), p.__u &= -7);
+ for (c = ae(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && _[p.__i] || w, p.__i = d, g = de(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && ge(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h == null && m != null && (h = m), 4 & p.__u ? (c = oe(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 oe(e, t, n, r, i) {
+function ae(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] = A(null, o, null, null, null) : D(o) ? o = e.__k[a] = A(j, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = A(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 = ce(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 = N(s)), ve(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] = j(null, o, null, null, null) : D(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 = se(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)), _e(s, s));
return r;
}
-function se(e, t, n) {
+function oe(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 = se(r[i], t, n));
+ for (r = e.__k, i = 0; r && i < r.length; i++) r[i] && (r[i].__ = e, t = oe(r[i], t, n));
return t;
}
- e.__e != t && (t && e.type && !t.parentNode && (t = N(e)), t = n.insertBefore(e.__e, t || null));
+ e.__e != t && (t && e.type && !t.parentNode && (t = P(e)), t = n.insertBefore(e.__e, t || null));
do
t &&= t.nextSibling;
while (t != null && t.nodeType == 8);
return t;
}
-function ce(e, t, n, r) {
+function se(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,16 +96,16 @@ function ce(e, t, n, r) {
}
return -1;
}
-function le(e, t, n) {
+function ce(e, t, n) {
t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || E.test(t) ? n : n + "px";
}
-function ue(e, t, n, r, i) {
+function le(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 || le(e.style, t, "");
- if (n) for (t in n) r && n[t] == r[t] || le(e.style, t, n[t]);
+ if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || ce(e.style, t, "");
+ if (n) for (t in n) r && n[t] == r[t] || ce(e.style, t, n[t]);
}
} else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(b, "$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[y] = r[y] : (n[y] = x, e.addEventListener(t, a ? C : S, a)) : e.removeEventListener(t, a ? C : S, a);
else {
@@ -117,7 +117,7 @@ function ue(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 de(e) {
+function ue(e) {
return function(t) {
if (this.l) {
var n = this.l[t.type + e];
@@ -127,19 +127,19 @@ function de(e) {
}
};
}
-function fe(e, t, n, r, i, a, o, s, c, l) {
- var d, f, p, m, h, g, _, v, y, b, x, S, C, w, E, k, A = t.type;
+function de(e, t, n, r, i, a, o, s, c, l) {
+ var d, f, p, m, h, g, _, v, y, b, x, S, C, w, E, A, j = t.type;
if (t.constructor !== void 0) return null;
128 & n.__u && (c = !!(32 & n.__u), a = [s = t.__e = n.__e]), (d = u.__b) && d(t);
- n: if (typeof A == "function") {
+ n: if (typeof j == "function") {
f = o.length;
try {
- if (y = t.props, b = A.prototype && A.prototype.render, x = (d = A.contextType) && r[d.__c], S = d ? x ? x.props.value : d.__ : r, n.__c ? v = (p = t.__c = n.__c).__ = p.__E : (b ? t.__c = p = new A(y, S) : (t.__c = p = new M(y, S), p.constructor = A, p.render = ye), 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 && A.getDerivedStateFromProps != null && (p.__s == p.state && (p.__s = O({}, p.__s)), O(p.__s, A.getDerivedStateFromProps(y, p.__s))), h = p.props, g = p.state, p.__v = t, m) b && A.getDerivedStateFromProps == null && p.componentWillMount != null && p.componentWillMount(), b && p.componentDidMount != null && p.__h.push(p.componentDidMount);
+ if (y = t.props, b = j.prototype && j.prototype.render, x = (d = j.contextType) && r[d.__c], S = d ? x ? x.props.value : d.__ : r, n.__c ? v = (p = t.__c = n.__c).__ = p.__E : (b ? t.__c = p = new j(y, S) : (t.__c = p = new N(y, S), p.constructor = j, p.render = ve), 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 && j.getDerivedStateFromProps != null && (p.__s == p.state && (p.__s = O({}, p.__s)), O(p.__s, j.getDerivedStateFromProps(y, p.__s))), h = p.props, g = p.state, p.__v = t, m) b && j.getDerivedStateFromProps == null && p.componentWillMount != null && p.componentWillMount(), b && p.componentDidMount != null && p.__h.push(p.componentDidMount);
else {
- if (b && A.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)) {
+ if (b && j.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) {
e && (e.__ = t);
- }), T.push.apply(p.__h, p._sb), p._sb = [], p.__h.length && o.push(p), s = N(n);
+ }), T.push.apply(p.__h, p._sb), p._sb = [], p.__h.length && o.push(p), s = P(n);
break n;
}
p.componentWillUpdate != null && p.componentWillUpdate(y, p.__s, S), b && p.componentDidUpdate != null && p.__h.push(function() {
@@ -150,24 +150,24 @@ function fe(e, t, n, r, i, a, o, s, c, l) {
else do
p.__d = !1, C && C(t), d = 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 = O(O({}, r), p.getChildContext())), b && !m && p.getSnapshotBeforeUpdate != null && (_ = p.getSnapshotBeforeUpdate(h, g)), E = d != null && d.type === j && d.key == null ? he(d.props.children) : d, s = ae(e, D(E) ? E : [E], 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);
+ p.state = p.__s, p.getChildContext != null && (r = O(O({}, r), p.getChildContext())), b && !m && p.getSnapshotBeforeUpdate != null && (_ = p.getSnapshotBeforeUpdate(h, g)), E = d != null && d.type === M && d.key == null ? me(d.props.children) : d, s = ie(e, D(E) ? E : [E], 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);
} catch (e) {
if (o.length = f, 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 (k = a.length; k--;) ee(a[k]);
+ } else if (a != null) for (A = a.length; A--;) k(a[A]);
} else t.__e = n.__e;
- t.__k ??= n.__k || [], e.then || pe(t), u.__e(e, t, n);
+ t.__k ??= n.__k || [], e.then || fe(t), u.__e(e, t, n);
}
- } else a == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : s = t.__e = ge(n.__e, t, n, r, i, a, o, c, l);
+ } else a == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : s = t.__e = he(n.__e, t, n, r, i, a, o, c, l);
return (d = u.diffed) && d(t), 128 & t.__u ? void 0 : s;
}
-function pe(e) {
- e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(pe));
+function fe(e) {
+ e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(fe));
}
-function me(e, t, n) {
- for (var r = 0; r < n.length; r++) _e(n[r], n[++r], n[++r]);
+function pe(e, t, n) {
+ for (var r = 0; r < n.length; r++) ge(n[r], n[++r], n[++r]);
u.__c && u.__c(t, e), e.some(function(t) {
try {
e = t.__h, t.__h = [], e.some(function(e) {
@@ -178,10 +178,10 @@ function me(e, t, n) {
}
});
}
-function he(e) {
- return typeof e != "object" || !e || e.__b > 0 ? e : D(e) ? e.map(he) : e.constructor === void 0 ? O({}, e) : null;
+function me(e) {
+ return typeof e != "object" || !e || e.__b > 0 ? e : D(e) ? e.map(me) : e.constructor === void 0 ? O({}, e) : null;
}
-function ge(e, t, n, r, i, a, o, s, c) {
+function he(e, t, n, r, i, a, o, s, c) {
var d, f, p, m, h, g, _, v = n.props || w, 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 (d = 0; d < a.length; d++) if ((h = a[d]) && "setAttribute" in h == !!b && (b ? h.localName == b : h.nodeType == 3)) {
@@ -196,15 +196,15 @@ function ge(e, t, n, r, i, a, o, s, c) {
if (b == null) v === y || s && e.data == y || (e.data = y);
else {
if (a = b == "textarea" && y.defaultValue != null ? null : a && l.call(e.childNodes), !s && a != null) for (v = {}, d = 0; d < e.attributes.length; d++) v[(h = e.attributes[d]).name] = h.value;
- for (d in v) h = v[d], d == "dangerouslySetInnerHTML" ? p = h : d == "children" || d in y || d == "value" && "defaultValue" in y || d == "checked" && "defaultChecked" in y || ue(e, d, null, h, i);
- for (d in y) h = y[d], d == "children" ? m = h : d == "dangerouslySetInnerHTML" ? f = h : d == "value" ? g = h : d == "checked" ? _ = h : s && typeof h != "function" || v[d] === h || ue(e, d, h, v[d], i);
+ for (d in v) h = v[d], d == "dangerouslySetInnerHTML" ? p = h : d == "children" || d in y || d == "value" && "defaultValue" in y || d == "checked" && "defaultChecked" in y || le(e, d, null, h, i);
+ for (d in y) h = y[d], d == "children" ? m = h : d == "dangerouslySetInnerHTML" ? f = h : d == "value" ? g = h : d == "checked" ? _ = h : s && typeof h != "function" || v[d] === h || le(e, d, h, v[d], i);
if (f) s || p && (f.__html == p.__html || f.__html == e.innerHTML) || (e.innerHTML = f.__html), t.__k = [];
- else if (p && (e.innerHTML = ""), ae(t.type == "template" ? e.content : e, D(m) ? m : [m], t, n, r, b == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, a, o, a ? a[0] : n.__k && N(n, 0), s, c), a != null) for (d = a.length; d--;) ee(a[d]);
- s && b != "textarea" || (d = "value", b == "progress" && g == null ? e.removeAttribute("value") : g != null && (g !== e[d] || b == "progress" && !g || b == "option" && g != v[d]) && ue(e, d, g, v[d], i), d = "checked", _ != null && _ != e[d] && ue(e, d, _, v[d], i));
+ else if (p && (e.innerHTML = ""), ie(t.type == "template" ? e.content : e, D(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 (d = a.length; d--;) k(a[d]);
+ s && b != "textarea" || (d = "value", b == "progress" && g == null ? e.removeAttribute("value") : g != null && (g !== e[d] || b == "progress" && !g || b == "option" && g != v[d]) && le(e, d, g, v[d], i), d = "checked", _ != null && _ != e[d] && le(e, d, _, v[d], i));
}
return e;
}
-function _e(e, t, n) {
+function ge(e, t, n) {
try {
if (typeof e == "function") {
var r = typeof e.__u == "function";
@@ -214,9 +214,9 @@ function _e(e, t, n) {
u.__e(e, n);
}
}
-function ve(e, t, n) {
+function _e(e, t, n) {
var r, i;
- if (u.unmount && u.unmount(e), (r = e.ref) && (r.current && r.current != e.__e || _e(r, null, t)), (r = e.__c) != null) {
+ if (u.unmount && u.unmount(e), (r = e.ref) && (r.current && r.current != e.__e || ge(r, null, t)), (r = e.__c) != null) {
if (r.componentWillUnmount) try {
r.componentWillUnmount();
} catch (e) {
@@ -224,15 +224,15 @@ function ve(e, t, n) {
}
r.base = r.__P = r.__n = null;
}
- if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && ve(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] && _e(r[i], t, n || typeof e.type != "function");
+ n || k(e.__e), e.__c = e.__ = e.__e = void 0;
}
-function ye(e, t, n) {
+function ve(e, t, n) {
return this.constructor(e, n);
}
-function be(e, t, n) {
+function ye(e, t, n) {
var r, i, a, o;
- t == document && (t = document.documentElement), u.__ && u.__(e, t), i = (r = typeof n == "function") ? null : n && n.__k || t.__k, a = [], o = [], fe(t, e = (!r && n || t).__k = k(j, null, [e]), i || w, w, t.namespaceURI, !r && n ? [n] : i ? null : t.firstChild ? l.call(t.childNodes) : null, a, !r && n ? n : i ? i.__e : t.firstChild, r, o), me(a, e, o), e.props.children = null;
+ t == document && (t = document.documentElement), u.__ && u.__(e, t), i = (r = typeof n == "function") ? null : n && n.__k || t.__k, a = [], o = [], de(t, e = (!r && n || t).__k = A(M, null, [e]), i || w, w, t.namespaceURI, !r && n ? [n] : i ? null : t.firstChild ? l.call(t.childNodes) : null, a, !r && n ? n : i ? i.__e : t.firstChild, r, o), pe(a, e, o), e.props.children = null;
}
l = T.slice, u = { __e: function(e, t, n, r) {
for (var i, a, o; t = t.__;) if ((i = t.__c) && !i.__) try {
@@ -243,23 +243,23 @@ l = T.slice, u = { __e: function(e, t, n, r) {
throw e;
} }, d = 0, f = function(e) {
return e != null && e.constructor === void 0;
-}, M.prototype.setState = function(e, t) {
+}, N.prototype.setState = function(e, t) {
var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = O({}, this.state);
- typeof e == "function" && (e = e(O({}, n), this.props)), e && O(n, e), e != null && this.__v && (t && this._sb.push(t), re(this));
-}, M.prototype.forceUpdate = function(e) {
- this.__v && (this.__e = !0, e && this.__h.push(e), re(this));
-}, M.prototype.render = j, p = [], h = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, g = function(e, t) {
+ typeof e == "function" && (e = e(O({}, n), this.props)), e && O(n, e), e != null && this.__v && (t && this._sb.push(t), ne(this));
+}, N.prototype.forceUpdate = function(e) {
+ this.__v && (this.__e = !0, e && this.__h.push(e), ne(this));
+}, N.prototype.render = M, p = [], h = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, g = function(e, t) {
return e.__v.__b - t.__v.__b;
-}, ie.__r = 0, _ = Math.random().toString(8), v = "__d" + _, y = "__a" + _, b = /(PointerCapture)$|Capture$/i, x = 0, S = de(!1), C = de(!0);
+}, re.__r = 0, _ = Math.random().toString(8), v = "__d" + _, y = "__a" + _, b = /(PointerCapture)$|Capture$/i, x = 0, S = ue(!1), C = ue(!0);
//#endregion
//#region src/api.ts
-var xe = class extends Error {
+var be = class extends Error {
status;
body;
constructor(e, t, n = null) {
super(e), this.name = "ApiError", this.status = t, this.body = n;
}
-}, Se = (e) => {
+}, xe = (e) => {
if (!e || typeof e != "object") return "";
let t = e;
for (let e of [
@@ -271,8 +271,8 @@ var xe = class extends Error {
if (typeof n == "string" && n) return n;
}
return "";
-}, P = (e) => e instanceof Error ? e.message : String(e);
-async function Ce(e, t) {
+}, F = (e) => e instanceof Error ? e.message : String(e);
+async function I(e, t) {
let n = await fetch(e, {
headers: { Accept: "application/json" },
credentials: "same-origin",
@@ -281,10 +281,10 @@ async function Ce(e, t) {
try {
r = await n.json();
} catch {}
- if (!n.ok) throw new xe(Se(r) || `请求失败(${n.status})`, n.status);
+ if (!n.ok) throw new be(xe(r) || `请求失败(${n.status})`, n.status);
return r;
}
-async function F(e, t, n = "POST", r) {
+async function L(e, t, n = "POST", r) {
let i = await fetch(e, {
method: n,
...r ? { signal: r } : {},
@@ -298,29 +298,29 @@ async function F(e, t, n = "POST", r) {
try {
a = await i.json();
} catch {}
- if (!i.ok) throw new xe(Se(a) || `请求失败(${i.status})`, i.status, a);
+ if (!i.ok) throw new be(xe(a) || `请求失败(${i.status})`, i.status, a);
return a;
}
//#endregion
//#region node_modules/preact/hooks/dist/hooks.module.js
-var I, L, we, Te, Ee = 0, De = [], R = u, Oe = R.__b, ke = R.__r, Ae = R.diffed, je = R.__c, Me = R.unmount, Ne = R.__;
-function Pe(e, t) {
- R.__h && R.__h(L, e, Ee || t), Ee = 0;
- var n = L.__H || (L.__H = {
+var R, z, Se, Ce, we = 0, Te = [], B = u, Ee = B.__b, De = B.__r, Oe = B.diffed, ke = B.__c, Ae = B.unmount, je = B.__;
+function Me(e, t) {
+ B.__h && B.__h(z, e, we || t), we = 0;
+ var n = z.__H || (z.__H = {
__: [],
__h: []
});
return e >= n.__.length && n.__.push({}), n.__[e];
}
-function z(e) {
- return Ee = 1, Fe(Ge, e);
+function V(e) {
+ return we = 1, Ne(Ue, e);
}
-function Fe(e, t, n) {
- var r = Pe(I++, 2);
- if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Ge(void 0, t), function(e) {
+function Ne(e, t, n) {
+ var r = Me(R++, 2);
+ if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Ue(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 = L, !L.__f)) {
+ }], r.__c = z, !z.__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;
};
- L.__f = !0;
- var a = L.shouldComponentUpdate, o = L.componentWillUpdate;
- L.componentWillUpdate = function(e, t, n) {
+ z.__f = !0;
+ var a = z.shouldComponentUpdate, o = z.componentWillUpdate;
+ z.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);
- }, L.shouldComponentUpdate = i;
+ }, z.shouldComponentUpdate = i;
}
return r.__N || r.__;
}
-function Ie(e, t) {
- var n = Pe(I++, 3);
- !R.__s && We(n.__H, t) && (n.__ = e, n.u = t, L.__H.__h.push(n));
+function Pe(e, t) {
+ var n = Me(R++, 3);
+ !B.__s && He(n.__H, t) && (n.__ = e, n.u = t, z.__H.__h.push(n));
}
-function Le(e, t) {
- var n = Pe(I++, 4);
- !R.__s && We(n.__H, t) && (n.__ = e, n.u = t, L.__h.push(n));
+function Fe(e, t) {
+ var n = Me(R++, 4);
+ !B.__s && He(n.__H, t) && (n.__ = e, n.u = t, z.__h.push(n));
}
-function B(e) {
- return Ee = 5, Re(function() {
+function H(e) {
+ return we = 5, Ie(function() {
return { current: e };
}, []);
}
-function Re(e, t) {
- var n = Pe(I++, 7);
- return We(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
+function Ie(e, t) {
+ var n = Me(R++, 7);
+ return He(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
}
-function ze() {
- for (var e; e = De.shift();) {
+function Le() {
+ for (var e; e = Te.shift();) {
var t = e.__H;
if (e.__P && t) try {
- t.__h.some(He), t.__h.some(Ue), t.__h = [];
+ t.__h.some(Be), t.__h.some(Ve), t.__h = [];
} catch (n) {
- t.__h = [], R.__e(n, e.__v);
+ t.__h = [], B.__e(n, e.__v);
}
}
}
-R.__b = function(e) {
- L = null, Oe && Oe(e);
-}, R.__ = function(e, t) {
- e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Ne && Ne(e, t);
-}, R.__r = function(e) {
- ke && ke(e), I = 0;
- var t = (L = e.__c).__H;
- t && (we === L ? (t.__h = [], L.__h = [], t.__.some(function(e) {
+B.__b = function(e) {
+ z = null, Ee && Ee(e);
+}, B.__ = function(e, t) {
+ e && t.__k && t.__k.__m && (e.__m = t.__k.__m), je && je(e, t);
+}, B.__r = function(e) {
+ De && De(e), R = 0;
+ var t = (z = e.__c).__H;
+ t && (Se === z ? (t.__h = [], z.__h = [], t.__.some(function(e) {
e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
- })) : (t.__h.some(He), t.__h.some(Ue), t.__h = [], I = 0)), we = L;
-}, R.diffed = function(e) {
- Ae && Ae(e);
+ })) : (t.__h.some(Be), t.__h.some(Ve), t.__h = [], R = 0)), Se = z;
+}, B.diffed = function(e) {
+ Oe && Oe(e);
var t = e.__c;
- t && t.__H && (t.__H.__h.length && (De.push(t) !== 1 && Te === R.requestAnimationFrame || ((Te = R.requestAnimationFrame) || Ve)(ze)), t.__H.__.some(function(e) {
+ t && t.__H && (t.__H.__h.length && (Te.push(t) !== 1 && Ce === B.requestAnimationFrame || ((Ce = B.requestAnimationFrame) || ze)(Le)), t.__H.__.some(function(e) {
e.u &&= (e.__H = e.u, void 0);
- })), we = L = null;
-}, R.__c = function(e, t) {
+ })), Se = z = null;
+}, B.__c = function(e, t) {
t.some(function(e) {
try {
- e.__h.some(He), e.__h = e.__h.filter(function(e) {
- return !e.__ || Ue(e);
+ e.__h.some(Be), e.__h = e.__h.filter(function(e) {
+ return !e.__ || Ve(e);
});
} catch (n) {
t.some(function(e) {
e.__h &&= [];
- }), t = [], R.__e(n, e.__v);
+ }), t = [], B.__e(n, e.__v);
}
- }), je && je(e, t);
-}, R.unmount = function(e) {
- Me && Me(e);
+ }), ke && ke(e, t);
+}, B.unmount = function(e) {
+ Ae && Ae(e);
var t, n = e.__c;
n && n.__H && (n.__H.__.some(function(e) {
try {
- He(e);
+ Be(e);
} catch (e) {
t = e;
}
- }), n.__H = void 0, t && R.__e(t, n.__v));
+ }), n.__H = void 0, t && B.__e(t, n.__v));
};
-var Be = typeof requestAnimationFrame == "function";
-function Ve(e) {
+var Re = typeof requestAnimationFrame == "function";
+function ze(e) {
var t, n = function() {
- clearTimeout(r), Be && cancelAnimationFrame(t), setTimeout(e);
+ clearTimeout(r), Re && cancelAnimationFrame(t), setTimeout(e);
}, r = setTimeout(n, 35);
- Be && (t = requestAnimationFrame(n));
+ Re && (t = requestAnimationFrame(n));
}
-function He(e) {
- var t = L, n = e.__c;
- typeof n == "function" && (e.__c = void 0, n()), L = t;
+function Be(e) {
+ var t = z, n = e.__c;
+ typeof n == "function" && (e.__c = void 0, n()), z = t;
}
-function Ue(e) {
- var t = L;
- e.__c = e.__(), L = t;
+function Ve(e) {
+ var t = z;
+ e.__c = e.__(), z = t;
}
-function We(e, t) {
+function He(e, t) {
return !e || e.length !== t.length || t.some(function(t, n) {
return t !== e[n];
});
}
-function Ge(e, t) {
+function Ue(e, t) {
return typeof t == "function" ? t(e) : t;
}
//#endregion
//#region node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
-var Ke = 0;
+var We = 0;
Array.isArray;
-function V(e, t, n, r, i, a) {
+function U(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,7 +456,7 @@ function V(e, t, n, r, i, a) {
__e: null,
__c: null,
constructor: void 0,
- __v: --Ke,
+ __v: --We,
__i: -1,
__u: 0,
__source: i,
@@ -467,269 +467,372 @@ function V(e, t, n, r, i, a) {
}
//#endregion
//#region src/islands/configuration.tsx
-var qe = "/api/configuration", Je = "/api/pick-folder", Ye = 8e3, Xe = (e, t) => Ce(qe, t), H = ({ html: e, class: t }) => /* @__PURE__ */ V("div", {
+var Ge = "/api/configuration", Ke = "/api/pick-folder", qe = 8e3, Je = (e, t) => I(Ge, t), W = ({ html: e, class: t }) => /* @__PURE__ */ U("div", {
class: t,
dangerouslySetInnerHTML: { __html: e }
-}), Ze = (e) => !(e instanceof xe) || e.status !== 400 ? null : e.body?.errors ?? null;
-function Qe({ facts: e }) {
- return /* @__PURE__ */ V("section", {
+}), Ye = (e) => !(e instanceof be) || e.status !== 400 ? null : e.body?.errors ?? null;
+function Xe({ facts: e }) {
+ return /* @__PURE__ */ U("section", {
class: "configfieldset",
"data-geist-fieldset": !0,
"aria-labelledby": "configFactsTitle",
- children: /* @__PURE__ */ V("div", {
+ children: /* @__PURE__ */ U("div", {
class: "geist-fieldset-content",
- children: [/* @__PURE__ */ V(H, { html: t("configFactsTitle", "运行信息") }), /* @__PURE__ */ V("dl", {
+ children: [/* @__PURE__ */ U(W, { html: t("configFactsTitle", "运行信息") }), /* @__PURE__ */ U("dl", {
class: "configfacts",
- children: e.map((e) => /* @__PURE__ */ V(j, { children: [/* @__PURE__ */ V("dt", { children: e.term }), /* @__PURE__ */ V("dd", { children: e.value })] }))
+ children: e.map((e) => /* @__PURE__ */ U(M, { children: [/* @__PURE__ */ U("dt", { children: e.term }), /* @__PURE__ */ U("dd", { children: e.value })] }))
})]
})
});
}
-function $e({ data: e, receipt: r }) {
- let [a, o] = z(e.media_dirs.length ? e.media_dirs : [""]), [s, c] = z(String(e.port)), [l, u] = z(!1), [d, f] = z([]), [p, m] = z(""), [h, g] = z(""), [_, v] = z(null), [y, b] = z(null), x = B(!1), S = B(e.revision), C = B([]), w = B(null);
- Le(() => {
- y !== null && (C.current[y]?.focus(), b(null));
- }, [y]), Ie(() => {
- if (!_) return;
- let e = setTimeout(() => location.assign(_.url), Ye);
+function Ze({ data: e }) {
+ let [n, r] = V(e.media_sources), [a, o] = V(""), s = H(null);
+ Pe(() => () => s.current?.abort(), []);
+ let c = async (e) => {
+ if (s.current) return;
+ let t = new AbortController();
+ s.current = t, i(e, !0), o("");
+ try {
+ let e = await I(Ge, t.signal);
+ t.signal.aborted || r(e.media_sources);
+ } catch (e) {
+ t.signal.aborted || o(F(e));
+ } finally {
+ s.current = null, i(e, !1);
+ }
+ };
+ return n ? /* @__PURE__ */ U("section", {
+ class: "configfieldset",
+ "aria-labelledby": "configMountsTitle",
+ children: /* @__PURE__ */ U("div", {
+ class: "geist-fieldset-content",
+ children: [
+ /* @__PURE__ */ U(W, { html: t("configMountsTitle", "挂载状态") }),
+ /* @__PURE__ */ U("dl", {
+ class: "configfacts",
+ children: n.map((e) => /* @__PURE__ */ U(M, { children: [/* @__PURE__ */ U("dt", { children: [
+ e.location,
+ " · ",
+ e.root
+ ] }), /* @__PURE__ */ U("dd", { children: [
+ e.path || "未配置挂载点",
+ " · ",
+ e.online ? "在线" : "离线"
+ ] })] }))
+ }),
+ a ? /* @__PURE__ */ U("p", {
+ class: "configbad",
+ role: "alert",
+ children: a
+ }) : null,
+ /* @__PURE__ */ U("button", {
+ type: "button",
+ class: "geist-button",
+ onClick: (e) => c(e.currentTarget),
+ children: "刷新挂载状态"
+ })
+ ]
+ })
+ }) : null;
+}
+function Qe({ data: e, receipt: r }) {
+ let a = e.media_sources?.filter((e) => [
+ "local",
+ "115",
+ "pikpak"
+ ].includes(e.location)), [o, s] = V(a?.length ? a.map((e) => e.path) : e.media_dirs.length ? e.media_dirs : [""]), [c, l] = V(a?.map((e) => e.location) ?? []), [u, d] = V(a?.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 = H(!1), D = H(e.revision), O = H([]), k = H(null);
+ Fe(() => {
+ w !== null && (O.current[w]?.focus(), T(null));
+ }, [w]), Pe(() => {
+ if (!S) return;
+ let e = setTimeout(() => location.assign(S.url), qe);
return () => clearTimeout(e);
- }, [_]);
- let T = (e, t) => {
- o((n) => n.map((n, r) => r === e ? t : n));
- }, E = () => {
- b(a.length), o((e) => [...e, ""]);
- }, D = (e) => {
- o((t) => t.filter((t, n) => n !== e)), f((t) => t.filter((t, n) => n !== e));
- }, O = (e, t) => {
- f((n) => {
+ }, [S]);
+ let A = (e, t) => {
+ s((n) => n.map((n, r) => r === e ? t : n));
+ }, j = () => {
+ T(o.length), s((e) => [...e, ""]);
+ }, M = (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));
+ }, N = (e, t) => {
+ _((n) => {
let r = [...n];
for (; r.length <= e;) r.push("");
return r[e] = t, r;
});
- }, ee = async (e, t) => {
+ }, P = async (e, t) => {
if (t.getAttribute("aria-busy") !== "true") {
i(t, !0);
try {
- let { path: t } = await F(Je, { initial: a[e] ?? "" });
- t && (T(e, t), O(e, ""));
+ let { path: t } = await L(Ke, { initial: o[e] ?? "" });
+ t && (A(e, t), N(e, ""));
} catch (t) {
- O(e, P(t));
+ N(e, F(t));
} finally {
i(t, !1);
}
}
};
- return _ ? /* @__PURE__ */ V("div", {
+ return S ? /* @__PURE__ */ U("div", {
class: "configsaved",
role: "status",
- children: [/* @__PURE__ */ V(H, { html: n("配置已保存,Peach 正在重新启动。", {
+ children: [/* @__PURE__ */ U(W, { html: n("配置已保存,Peach 正在重新启动。", {
variant: "success",
label: "已保存"
- }) }), /* @__PURE__ */ V("p", {
+ }) }), /* @__PURE__ */ U("p", {
class: "confighelp",
children: [
"几秒后自动打开新地址;没跳转就点 ",
- /* @__PURE__ */ V("a", {
- href: _.url,
+ /* @__PURE__ */ U("a", {
+ href: S.url,
children: "进入馆藏"
}),
"。"
]
})]
- }) : /* @__PURE__ */ V("form", {
+ }) : /* @__PURE__ */ U("form", {
class: "configfieldset",
"data-geist-fieldset": !0,
"aria-labelledby": "configTitle",
- onSubmit: async (e) => {
- if (e.preventDefault(), !x.current) {
- x.current = !0, i(w.current, !0), g("");
+ onSubmit: async (t) => {
+ if (t.preventDefault(), !E.current) {
+ E.current = !0, i(k.current, !0), x("");
try {
- let e = await F(qe, {
- revision: S.current,
- media_dirs: a,
- port: s,
- scan_now: l
+ let t = await L(Ge, {
+ revision: D.current,
+ media_dirs: o,
+ ...e.media_sources ? { media_sources: o.map((e, t) => ({
+ path: e,
+ location: c[t] || "local",
+ root: u[t] || ""
+ })) } : {},
+ port: f,
+ scan_now: m
});
- S.current = e.revision, f([]), m(""), r("已保存配置"), v(e);
+ D.current = t.revision, _([]), y(""), r("已保存配置"), C(t);
} catch (e) {
- let t = Ze(e);
- t ? (f(t.media_dirs ?? []), m(t.port ?? "")) : (f([]), m(""), g(P(e)));
+ let t = Ye(e);
+ t ? (_(t.media_dirs ?? []), y(t.port ?? "")) : (_([]), y(""), x(F(e)));
} finally {
- x.current = !1, i(w.current, !1);
+ E.current = !1, i(k.current, !1);
}
}
},
noValidate: !0,
- children: [/* @__PURE__ */ V("div", {
+ children: [/* @__PURE__ */ U("div", {
class: "geist-fieldset-content",
children: [
- /* @__PURE__ */ V(H, { html: t("configTitle", "这台电脑") }),
- /* @__PURE__ */ V("div", {
+ /* @__PURE__ */ U(W, { html: t("configTitle", "这台电脑") }),
+ /* @__PURE__ */ U("div", {
class: "configfield",
children: [
- /* @__PURE__ */ V("span", {
+ /* @__PURE__ */ U("span", {
class: "configlabel",
id: "configDirsLabel",
children: "媒体文件夹"
}),
- /* @__PURE__ */ V("div", {
+ /* @__PURE__ */ U("div", {
class: "configdirs",
role: "group",
"aria-labelledby": "configDirsLabel",
- children: a.map((e, t) => /* @__PURE__ */ V("div", {
+ children: o.map((t, n) => /* @__PURE__ */ U("div", {
class: "configdir",
children: [
- /* @__PURE__ */ V("input", {
+ /* @__PURE__ */ U("input", {
class: "geist-input",
type: "text",
- value: e,
- "aria-label": `媒体文件夹 ${t + 1}`,
- "aria-invalid": d[t] ? "true" : void 0,
- onInput: (e) => T(t, e.currentTarget.value),
+ value: t,
+ "aria-label": `媒体文件夹 ${n + 1}`,
+ "aria-invalid": g[n] ? "true" : void 0,
+ onInput: (e) => A(n, e.currentTarget.value),
ref: (e) => {
- C.current[t] = e;
+ O.current[n] = e;
}
}),
- /* @__PURE__ */ V("button", {
+ /* @__PURE__ */ U("button", {
type: "button",
class: "geist-button configpick",
"aria-label": "选择文件夹",
- onClick: (e) => ee(t, e.currentTarget),
- children: /* @__PURE__ */ V("svg", {
+ onClick: (e) => P(n, e.currentTarget),
+ children: /* @__PURE__ */ U("svg", {
viewBox: "0 0 24 24",
"aria-hidden": "true",
- children: /* @__PURE__ */ V("use", { href: "#i-folder-search" })
+ children: /* @__PURE__ */ U("use", { href: "#i-folder-search" })
})
}),
- a.length > 1 ? /* @__PURE__ */ V("button", {
+ o.length > 1 ? /* @__PURE__ */ U("button", {
type: "button",
class: "geist-button configrm",
"aria-label": "移除这个文件夹",
- onClick: () => D(t),
- children: /* @__PURE__ */ V("svg", {
+ onClick: () => M(n),
+ children: /* @__PURE__ */ U("svg", {
viewBox: "0 0 24 24",
"aria-hidden": "true",
- children: /* @__PURE__ */ V("use", { href: "#i-x" })
+ children: /* @__PURE__ */ U("use", { href: "#i-x" })
})
}) : null,
- d[t] ? /* @__PURE__ */ V("p", {
+ /* @__PURE__ */ U("div", {
+ class: "configsource",
+ children: [/* @__PURE__ */ U("label", { children: ["媒体来源", /* @__PURE__ */ U("select", {
+ class: "geist-input",
+ "aria-label": `媒体来源 ${n + 1}`,
+ value: c[n] || "local",
+ onChange: (e) => {
+ let t = [...c];
+ t[n] = e.currentTarget.value, l(t);
+ },
+ children: [
+ /* @__PURE__ */ U("option", {
+ value: "local",
+ children: "本地磁盘"
+ }),
+ /* @__PURE__ */ U("option", {
+ value: "115",
+ children: "CloudDrive · 115"
+ }),
+ /* @__PURE__ */ U("option", {
+ value: "pikpak",
+ children: "CloudDrive · PikPak"
+ })
+ ]
+ })] }), e.windows === !1 ? /* @__PURE__ */ U("label", { children: ["账本根目录", /* @__PURE__ */ U("input", {
+ class: "geist-input",
+ "aria-label": `账本根目录 ${n + 1}`,
+ value: u[n] || "",
+ placeholder: "例如 B:\\\\",
+ onInput: (e) => {
+ let t = [...u];
+ t[n] = e.currentTarget.value, d(t);
+ }
+ })] }) : null]
+ }),
+ g[n] ? /* @__PURE__ */ U("p", {
class: "configbad",
role: "alert",
- children: d[t]
+ children: g[n]
}) : null
]
- }, t))
+ }, n))
}),
- /* @__PURE__ */ V("button", {
+ /* @__PURE__ */ U("button", {
type: "button",
class: "geist-button configadd",
- onClick: E,
+ onClick: j,
children: "添加文件夹"
}),
- /* @__PURE__ */ V("p", {
+ /* @__PURE__ */ U("p", {
class: "confighelp",
- children: "Peach 从这些文件夹读取视频和图片。可以是外置硬盘上的文件夹,但必须已经存在。"
+ children: ["CloudDrive:先登录网盘并挂载,再选择对应的 115 或 PikPak 来源。macOS 填本机挂载点与对应的账本盘符根。", /* @__PURE__ */ U("a", {
+ href: "https://www.clouddrive2.com/help.html",
+ target: "_blank",
+ rel: "noreferrer",
+ children: "挂载帮助"
+ })]
})
]
}),
- /* @__PURE__ */ V("div", {
+ /* @__PURE__ */ U("div", {
class: "configfield",
children: [
- /* @__PURE__ */ V("label", {
+ /* @__PURE__ */ U("label", {
for: "configPort",
children: "本机访问端口"
}),
- /* @__PURE__ */ V("input", {
+ /* @__PURE__ */ U("input", {
id: "configPort",
class: "geist-input",
type: "text",
inputMode: "numeric",
- value: s,
- "aria-invalid": p ? "true" : void 0,
- onInput: (e) => c(e.currentTarget.value)
+ value: f,
+ "aria-invalid": v ? "true" : void 0,
+ onInput: (e) => p(e.currentTarget.value)
}),
- p ? /* @__PURE__ */ V("p", {
+ v ? /* @__PURE__ */ U("p", {
class: "configbad",
role: "alert",
- children: p
+ children: v
}) : null,
- /* @__PURE__ */ V("p", {
+ /* @__PURE__ */ U("p", {
class: "confighelp",
children: "浏览器地址里冒号后面的数字,一般不用改。"
})
]
}),
- /* @__PURE__ */ V("label", {
+ /* @__PURE__ */ U("label", {
class: "configcheck",
- children: [/* @__PURE__ */ V("span", {
+ children: [/* @__PURE__ */ U("span", {
class: "pcheck",
- children: [/* @__PURE__ */ V("input", {
+ children: [/* @__PURE__ */ U("input", {
type: "checkbox",
- checked: l,
- onChange: (e) => u(e.currentTarget.checked)
- }), /* @__PURE__ */ V("span", {
+ checked: m,
+ onChange: (e) => h(e.currentTarget.checked)
+ }), /* @__PURE__ */ U("span", {
"aria-hidden": "true",
- children: /* @__PURE__ */ V("svg", {
+ children: /* @__PURE__ */ U("svg", {
viewBox: "0 0 24 24",
- children: /* @__PURE__ */ V("use", { href: "#i-check" })
+ children: /* @__PURE__ */ U("use", { href: "#i-check" })
})
})]
- }), /* @__PURE__ */ V("span", { children: "保存后扫描媒体文件夹" })]
+ }), /* @__PURE__ */ U("span", { children: "保存后扫描媒体文件夹" })]
}),
- h ? /* @__PURE__ */ V(H, { html: n(h, {
+ b ? /* @__PURE__ */ U(W, { html: n(b, {
variant: "error",
label: "没有保存"
}) }) : null
]
- }), /* @__PURE__ */ V("div", {
+ }), /* @__PURE__ */ U("div", {
class: "geist-fieldset-footer",
"data-geist-fieldset-footer": !0,
- children: [/* @__PURE__ */ V("p", { children: "保存后 Peach 会重新启动,端口改了就用新地址打开。" }), /* @__PURE__ */ V("button", {
+ children: [/* @__PURE__ */ U("p", { children: "保存后 Peach 会重新启动,端口改了就用新地址打开。" }), /* @__PURE__ */ U("button", {
type: "submit",
class: "geist-button primary",
- ref: w,
+ ref: k,
children: "保存配置"
})]
})]
});
}
-function et({ receipt: e, data: t, error: r }) {
- return r || !t ? /* @__PURE__ */ V(H, {
+function $e({ receipt: e, data: t, error: r }) {
+ return r || !t ? /* @__PURE__ */ U(W, {
class: "configpage",
html: n(r || "没有读到配置", {
variant: "error",
label: "打不开配置"
})
- }) : /* @__PURE__ */ V("div", {
+ }) : /* @__PURE__ */ U("div", {
class: "configpage",
- children: [t.editable ? /* @__PURE__ */ V($e, {
- data: t,
- receipt: e
- }) : /* @__PURE__ */ V(H, { html: n(t.notice, {
- variant: "secondary",
- label: "只读"
- }) }), /* @__PURE__ */ V(Qe, { facts: t.facts })]
+ children: [
+ t.editable ? /* @__PURE__ */ U(Qe, {
+ data: t,
+ receipt: e
+ }) : /* @__PURE__ */ U(W, { html: n(t.notice, {
+ variant: "secondary",
+ label: "只读"
+ }) }),
+ /* @__PURE__ */ U(Xe, { facts: t.facts }),
+ /* @__PURE__ */ U(Ze, { data: t })
+ ]
});
}
//#endregion
//#region node_modules/@preact/signals-core/dist/signals-core.module.js
-var tt = Symbol.for("preact-signals");
-function nt() {
- if (K > 1) K--;
+var et = Symbol.for("preact-signals");
+function tt() {
+ if (J > 1) J--;
else {
var e, t = !1;
for ((function() {
- var e = ct;
- for (ct = void 0; e !== void 0;) {
+ var e = st;
+ for (st = 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;
}
- })(); G !== void 0;) {
- var n = G;
- for (G = void 0, at++; n !== void 0;) {
+ })(); q !== void 0;) {
+ var n = q;
+ for (q = void 0, it++; n !== void 0;) {
var r = n.u;
- if (n.u = void 0, n.f &= -3, !(8 & n.f) && ft(n)) try {
+ if (n.u = void 0, n.f &= -3, !(8 & n.f) && dt(n)) try {
n.c();
} catch (n) {
t ||= (e = n, !0);
@@ -737,116 +840,116 @@ function nt() {
n = r;
}
}
- if (at = 0, K--, t) throw e;
+ if (it = 0, J--, t) throw e;
}
}
-function rt(e) {
- if (K > 0) return e();
- st = ++ot, K++;
+function nt(e) {
+ if (J > 0) return e();
+ ot = ++at, J++;
try {
return e();
} finally {
- nt();
+ tt();
}
}
-var U, W = void 0;
-function it(e) {
- var t = W, n = U;
- W = void 0, U = void 0;
+var G, K = void 0;
+function rt(e) {
+ var t = K, n = G;
+ K = void 0, G = void 0;
try {
return e();
} finally {
- W = t, U = n;
+ K = t, G = n;
}
}
-var G = void 0, K = 0, at = 0, ot = 0, st = 0, ct = void 0, lt = 0;
-function ut(e) {
- if (W !== void 0) {
+var q = void 0, J = 0, it = 0, at = 0, ot = 0, st = void 0, ct = 0;
+function lt(e) {
+ if (K !== void 0) {
var t = e.n;
- if (t === void 0 || t.t !== W) return t = {
+ if (t === void 0 || t.t !== K) return t = {
i: 0,
S: e,
- p: W.s,
+ p: K.s,
n: void 0,
- t: W,
+ t: K,
e: void 0,
x: void 0,
r: t
- }, W.s !== void 0 && (W.s.n = t), W.s = t, e.n = t, 32 & W.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 = W.s, t.n = void 0, W.s.n = t, W.s = t), 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;
}
}
-function q(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;
}
-q.prototype.brand = tt, q.prototype.h = function() {
+Y.prototype.brand = et, Y.prototype.h = function() {
return !0;
-}, q.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 ? it(function() {
+ n !== e && e.e === void 0 && (e.x = n, this.t = e, n === void 0 ? rt(function() {
var e;
(e = t.W) == null || e.call(t);
}) : n.e = e);
-}, q.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 && it(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 && rt(function() {
var e;
(e = t.Z) == null || e.call(t);
}));
}
-}, q.prototype.subscribe = function(e) {
+}, Y.prototype.subscribe = function(e) {
var t = this;
- return X(function() {
+ return Q(function() {
var n = t.value;
- it(function() {
+ rt(function() {
return e(n);
});
}, { name: "sub" });
-}, q.prototype.valueOf = function() {
+}, Y.prototype.valueOf = function() {
return this.value;
-}, q.prototype.toString = function() {
+}, Y.prototype.toString = function() {
return this.value + "";
-}, q.prototype.toJSON = function() {
+}, Y.prototype.toJSON = function() {
return this.value;
-}, q.prototype.peek = function() {
+}, Y.prototype.peek = function() {
var e = this;
- return it(function() {
+ return rt(function() {
return e.value;
});
-}, Object.defineProperty(q.prototype, "value", {
+}, Object.defineProperty(Y.prototype, "value", {
get: function() {
- var e = ut(this);
+ var e = lt(this);
return e !== void 0 && (e.i = this.i), this.v;
},
set: function(e) {
if (e !== this.v) {
- if (at > 100) throw Error("Cycle detected");
+ if (it > 100) throw Error("Cycle detected");
(function(e) {
- K !== 0 && at === 0 && e.l !== st && (e.l = st, ct = {
+ J !== 0 && it === 0 && e.l !== ot && (e.l = ot, st = {
S: e,
v: e.v,
i: e.i,
- o: ct
+ o: st
});
- })(this), this.v = e, this.i++, lt++, K++;
+ })(this), this.v = e, this.i++, ct++, J++;
try {
for (var t = this.t; t !== void 0; t = t.x) t.t.N();
} finally {
- nt();
+ tt();
}
}
}
});
-function dt(e, t) {
- return new q(e, t);
+function ut(e, t) {
+ return new Y(e, t);
}
-function ft(e) {
+function dt(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 pt(e) {
+function ft(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) {
@@ -855,81 +958,81 @@ function pt(e) {
}
}
}
-function mt(e) {
+function pt(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 J(e, t) {
- q.call(this, void 0, t), this.x = e, this.s = void 0, this.g = lt - 1, this.f = 4;
+function X(e, t) {
+ Y.call(this, void 0, t), this.x = e, this.s = void 0, this.g = ct - 1, this.f = 4;
}
-J.prototype = new q(), J.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 === lt)) return !0;
- if (this.g = lt, this.f |= 1, this.i > 0 && !ft(this)) return this.f &= -2, !0;
- var e = W;
+ if ((36 & this.f) == 32 || (this.f &= -5, this.g === ct)) return !0;
+ if (this.g = ct, this.f |= 1, this.i > 0 && !dt(this)) return this.f &= -2, !0;
+ var e = K;
try {
- pt(this), W = this;
+ ft(this), K = 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 W = e, mt(this), this.f &= -2, !0;
-}, J.prototype.S = function(e) {
+ return K = e, pt(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);
}
- q.prototype.S.call(this, e);
-}, J.prototype.U = function(e) {
- if (this.t !== void 0 && (q.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);
}
-}, J.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(J.prototype, "value", { get: function() {
+}, Object.defineProperty(X.prototype, "value", { get: function() {
if (1 & this.f) throw Error("Cycle detected");
- var e = ut(this);
+ var e = lt(this);
if (this.h(), e !== void 0 && (e.i = this.i), 16 & this.f) throw this.v;
return this.v;
} });
-function ht(e, t) {
- return new J(e, t);
+function mt(e, t) {
+ return new X(e, t);
}
-function gt(e) {
+function ht(e) {
var t = e.m;
if (e.m = void 0, typeof t == "function") {
- K++;
- var n = W;
- W = void 0;
+ J++;
+ var n = K;
+ K = void 0;
try {
t();
} catch (t) {
- throw e.f &= -2, e.f |= 8, _t(e), t;
+ throw e.f &= -2, e.f |= 8, gt(e), t;
} finally {
- W = n, nt();
+ K = n, tt();
}
}
}
-function _t(e) {
+function gt(e) {
for (var t = e.s; t !== void 0; t = t.n) t.S.U(t);
- e.x = void 0, e.s = void 0, gt(e);
+ e.x = void 0, e.s = void 0, ht(e);
}
-function vt(e) {
- if (W !== this) throw Error("Out-of-order effect");
- mt(this), W = e, this.f &= -2, 8 & this.f && _t(this), nt();
+function _t(e) {
+ if (K !== this) throw Error("Out-of-order effect");
+ pt(this), K = e, this.f &= -2, 8 & this.f && gt(this), tt();
}
-function Y(e, t) {
- this.x = e, this.m = void 0, this.s = void 0, this.u = void 0, this.f = 32, this.name = t?.name, U && U.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, G && G.push(this);
}
-Y.prototype.c = function() {
+Z.prototype.c = function() {
var e = this.S();
try {
if (8 & this.f || this.x === void 0) return;
@@ -938,20 +1041,20 @@ Y.prototype.c = function() {
} finally {
e();
}
-}, Y.prototype.S = function() {
+}, Z.prototype.S = function() {
if (1 & this.f) throw Error("Cycle detected");
- this.f |= 1, this.f &= -9, gt(this), pt(this), K++;
- var e = W;
- return W = this, vt.bind(this, e);
-}, Y.prototype.N = function() {
- 2 & this.f || (this.f |= 2, this.u = G, G = this);
-}, Y.prototype.d = function() {
- this.f |= 8, 1 & this.f || _t(this);
-}, Y.prototype.dispose = function() {
+ this.f |= 1, this.f &= -9, ht(this), ft(this), J++;
+ var e = K;
+ return K = this, _t.bind(this, e);
+}, Z.prototype.N = function() {
+ 2 & this.f || (this.f |= 2, this.u = q, q = this);
+}, Z.prototype.d = function() {
+ this.f |= 8, 1 & this.f || gt(this);
+}, Z.prototype.dispose = function() {
this.d();
};
-function X(e, t) {
- var n = new Y(e, t);
+function Q(e, t) {
+ var n = new Z(e, t);
try {
n.c();
} catch (e) {
@@ -962,35 +1065,35 @@ function X(e, t) {
}
//#endregion
//#region node_modules/@preact/signals/dist/signals.module.js
-var yt, bt, xt = typeof window < "u" && !!window.__PREACT_SIGNALS_DEVTOOLS__, St = [];
-X(function() {
- yt = this.N;
+var vt, yt, bt = typeof window < "u" && !!window.__PREACT_SIGNALS_DEVTOOLS__, xt = [];
+Q(function() {
+ vt = this.N;
})();
-function Z(e, t) {
+function $(e, t) {
u[e] = t.bind(null, u[e] || function() {});
}
-function Ct(e) {
- if (bt) {
- var t = bt;
- bt = void 0, t();
+function St(e) {
+ if (yt) {
+ var t = yt;
+ yt = void 0, t();
}
- bt = e && e.S();
+ yt = e && e.S();
}
-function wt(e) {
- var t = this, n = e.data, r = Et(n);
+function Ct(e) {
+ var t = this, n = e.data, r = Tt(n);
r.name = "ReactiveDom", r.value = n;
- var i = Re(function() {
+ var i = Ie(function() {
for (var e = t, n = t.__v; n = n.__;) if (n.__c) {
n.__c.__$f |= 4;
break;
}
- var i = ht(function() {
+ var i = mt(function() {
var e = r.value.value;
return e === 0 ? 0 : !0 === e ? "" : e || "";
- }), a = ht(function() {
+ }), a = mt(function() {
return !Array.isArray(i.value) && !f(i.value);
- }), o = X(function() {
- if (this.N = kt, a.value) {
+ }), o = Q(function() {
+ if (this.N = Ot, a.value) {
var t = i.value;
e.__v && e.__v.__e && e.__v.__e.nodeType === 3 && (e.__v.__e.data = t);
}
@@ -1001,14 +1104,14 @@ function wt(e) {
}, []), a = i[0], o = i[1];
return a.value ? o.peek() : o.value;
}
-wt.displayName = "ReactiveTextNode", Object.defineProperties(q.prototype, {
+Ct.displayName = "ReactiveTextNode", Object.defineProperties(Y.prototype, {
constructor: {
configurable: !0,
value: void 0
},
type: {
configurable: !0,
- value: wt
+ value: Ct
},
props: {
configurable: !0,
@@ -1023,35 +1126,35 @@ wt.displayName = "ReactiveTextNode", Object.defineProperties(q.prototype, {
configurable: !0,
value: 1
}
-}), Z("__b", function(e, t) {
+}), $("__b", function(e, t) {
if (typeof t.type == "string") {
var n, r = t.props;
for (var i in r) if (i !== "children") {
var a = r[i];
- a instanceof q && (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);
-}), Z("__r", function(e, t) {
- if (e(t), t.type !== j) {
- Ct();
+}), $("__r", function(e, t) {
+ if (e(t), t.type !== M) {
+ St();
var n, r = t.__c;
r && (r.__$f &= -2, (n = r.__$u) === void 0 && (r.__$u = n = function(e, t) {
var n;
- return X(function() {
+ return Q(function() {
n = this;
}, { name: t }), n.c = e, n;
}(function(e) {
return function() {
var t;
- xt && ((t = this.y) == null || t.call(this)), e.__$f |= 1, e.setState({});
+ bt && ((t = this.y) == null || t.call(this)), e.__$f |= 1, e.setState({});
};
- }(r), typeof t.type == "function" ? t.type.displayName || t.type.name : ""))), Ct(n);
+ }(r), typeof t.type == "function" ? t.type.displayName || t.type.name : ""))), St(n);
}
-}), Z("__e", function(e, t, n, r) {
- Ct(), e(t, n, r);
-}), Z("diffed", function(e, t) {
- Ct();
+}), $("__e", function(e, t, n, r) {
+ St(), e(t, n, r);
+}), $("diffed", function(e, t) {
+ St();
var n;
if (typeof t.type == "string" && (n = t.__e)) {
var r = t.__np, i = t.props, a = n.U;
@@ -1061,25 +1164,25 @@ wt.displayName = "ReactiveTextNode", Object.defineProperties(q.prototype, {
}
if (r) for (var c in a || (a = {}, n.U = a), r) {
var l = a[c], u = r[c];
- l === void 0 ? (l = Tt(n, c, u, i), a[c] = l) : l.o(u, i);
+ l === void 0 ? (l = wt(n, c, u, i), a[c] = l) : l.o(u, i);
}
}
e(t);
});
-function Tt(e, t, n, r) {
- var i = t in e && e.ownerSVGElement === void 0, a = dt(n);
+function wt(e, t, n, r) {
+ var i = t in e && e.ownerSVGElement === void 0, a = ut(n);
return {
o: function(e, t) {
a.value = e, r = t;
},
- d: X(function() {
- this.N = kt;
+ d: Q(function() {
+ this.N = Ot;
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));
})
};
}
-Z("unmount", function(e, t) {
+$("unmount", function(e, t) {
if (typeof t.type == "string") {
var n = t.__e;
if (n) {
@@ -1103,9 +1206,9 @@ Z("unmount", function(e, t) {
}
}
e(t);
-}), Z("__h", function(e, t, n, r) {
+}), $("__h", function(e, t, n, r) {
r < 3 && (t.__$f |= 2), e(t, n, r);
-}), M.prototype.shouldComponentUpdate = function(e, t) {
+}), N.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;
@@ -1117,46 +1220,46 @@ Z("unmount", function(e, t) {
for (var s in this.props) if (!(s in e)) return !0;
return !1;
};
-function Et(e, t) {
- return Re(function() {
- return dt(e, t);
+function Tt(e, t) {
+ return Ie(function() {
+ return ut(e, t);
}, []);
}
-var Dt = function(e) {
+var Et = function(e) {
queueMicrotask(function() {
queueMicrotask(e);
});
};
-function Ot() {
- rt(function() {
- for (var e; e = St.shift();) yt.call(e);
+function Dt() {
+ nt(function() {
+ for (var e; e = xt.shift();) vt.call(e);
});
}
-function kt() {
- St.push(this) === 1 && (u.requestAnimationFrame || Dt)(Ot);
+function Ot() {
+ xt.push(this) === 1 && (u.requestAnimationFrame || Et)(Dt);
}
//#endregion
//#region src/state/quality-goals.ts
-var At = "/api/quality-goals?limit=200", jt = {
+var kt = "/api/quality-goals?limit=200", At = {
data: null,
error: ""
-}, Q = dt(jt), Mt = 0, Nt = ht(() => Q.value);
-ht(() => Q.value.data?.total ?? null);
+}, jt = ut(At), Mt = 0, Nt = mt(() => jt.value);
+mt(() => jt.value.data?.total ?? null);
function Pt() {
- Mt += 1, Q.value = jt;
+ Mt += 1, jt.value = At;
}
async function Ft(e) {
let t = Mt += 1;
try {
- let n = await Ce(At, e);
- return t === Mt && (Q.value = {
+ let n = await I(kt, e);
+ return t === Mt && (jt.value = {
data: n,
error: ""
}), n;
} catch (n) {
- throw !e?.aborted && t === Mt && (Q.value = {
+ throw !e?.aborted && t === Mt && (jt.value = {
data: null,
- error: P(n)
+ error: F(n)
}), n;
}
}
@@ -1165,7 +1268,7 @@ async function Ft(e) {
var It = (e, t) => Ft(t), Lt = (e) => e.has_cover ? `/cover?code=${encodeURIComponent(e.code ?? "")}` : `/poster?id=${e.id}&c=4`;
function Rt({ openItem: t, javTitleHtml: r, javDisplayName: i, srcBadge: a }) {
let { data: l, error: u } = Nt.value;
- if (u) return /* @__PURE__ */ V("div", {
+ if (u) return /* @__PURE__ */ U("div", {
class: "qualitylist",
dangerouslySetInnerHTML: { __html: n(u, {
variant: "error",
@@ -1173,44 +1276,44 @@ function Rt({ openItem: t, javTitleHtml: r, javDisplayName: i, srcBadge: a }) {
}) }
});
let d = l?.items ?? [];
- return d.length ? /* @__PURE__ */ V("div", {
+ return d.length ? /* @__PURE__ */ U("div", {
class: "qualitylist",
- children: d.map((e) => /* @__PURE__ */ V("article", {
+ children: d.map((e) => /* @__PURE__ */ U("article", {
class: "qualityitem",
- children: [/* @__PURE__ */ V("button", {
+ children: [/* @__PURE__ */ U("button", {
class: "qualitycover",
type: "button",
"aria-label": `打开 ${i(e)}`,
onClick: () => t(e.id),
- children: /* @__PURE__ */ V("img", {
+ children: /* @__PURE__ */ U("img", {
src: Lt(e),
alt: "",
loading: "lazy",
onError: (e) => e.currentTarget.remove()
})
- }), /* @__PURE__ */ V("div", { children: [
- /* @__PURE__ */ V("h3", { children: /* @__PURE__ */ V("button", {
+ }), /* @__PURE__ */ U("div", { children: [
+ /* @__PURE__ */ U("h3", { children: /* @__PURE__ */ U("button", {
type: "button",
"data-middle-truncate": !0,
onClick: () => t(e.id),
dangerouslySetInnerHTML: { __html: r(e) }
}) }),
- /* @__PURE__ */ V("p", {
+ /* @__PURE__ */ U("p", {
class: "mono",
children: [
- /* @__PURE__ */ V("span", {
+ /* @__PURE__ */ U("span", {
style: "display:contents",
dangerouslySetInnerHTML: { __html: a(e.location, e.cost) }
}),
- /* @__PURE__ */ V("span", { children: o[e.location] ?? e.location }),
- /* @__PURE__ */ V("span", { children: s(e.duration) }),
- /* @__PURE__ */ V("span", { children: c(e.size ?? 0) })
+ /* @__PURE__ */ U("span", { children: o[e.location] ?? e.location }),
+ /* @__PURE__ */ U("span", { children: s(e.duration) }),
+ /* @__PURE__ */ U("span", { children: c(e.size ?? 0) })
]
}),
- e.reason ? /* @__PURE__ */ V("p", { children: e.reason }) : null
+ e.reason ? /* @__PURE__ */ U("p", { children: e.reason }) : null
] })]
}, e.id))
- }) : /* @__PURE__ */ V("div", {
+ }) : /* @__PURE__ */ U("div", {
class: "qualitylist",
dangerouslySetInnerHTML: { __html: e("sparkles", "没有标记中的高清版目标", "现有版本都已满足条件,或还没有加入追踪。") }
});
@@ -1262,10 +1365,10 @@ function Bt(e) {
}
//#endregion
//#region src/islands/scraping.tsx
-var Vt = (e, t) => Ce("/api/scraping", t);
+var Vt = (e, t) => I("/api/scraping", t);
function Ht({ value: e, onChange: t }) {
- let n = B(null), i = B(t);
- return i.current = t, Le(() => {
+ let n = H(null), i = H(t);
+ return i.current = t, Fe(() => {
let t = n.current;
t.innerHTML = r([
["environment", "系统代理"],
@@ -1276,27 +1379,27 @@ function Ht({ value: e, onChange: t }) {
return o.addEventListener("change", s), () => {
o.disabled = !0, o.removeEventListener("change", s), t.replaceChildren();
};
- }, []), /* @__PURE__ */ V("div", {
+ }, []), /* @__PURE__ */ U("div", {
ref: n,
class: "scraping-network"
});
}
function Ut({ source: e, toast: r }) {
- let [a, o] = z(e), [s, c] = z(e.network), [l, u] = z(""), [d, f] = z(""), [p, m] = z(""), [h, g] = z("paste"), [_, v] = z(""), [y, b] = z(!1), [x, S] = z(""), [C, w] = z([]), T = B(null), E = B(null);
- Le(() => {
+ let [a, o] = 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 = H(null), E = H(null);
+ Fe(() => {
E.current?.querySelectorAll("footer button").forEach((e) => i(e, y));
}, [y]);
- let D = B(new AbortController());
- Ie(() => () => D.current.abort(), []);
+ let D = H(new AbortController());
+ Pe(() => () => D.current.abort(), []);
async function O(t) {
if (!y) {
b(!0), S(""), w([]);
try {
if (t === "check") {
- let t = await F("/api/scraping/check", { source: e.source }, "POST", D.current.signal);
+ let t = await L("/api/scraping/check", { source: e.source }, "POST", D.current.signal);
D.current.signal.aborted || w(t.results);
} else {
- let n = await F("/api/scraping/settings", {
+ let n = await L("/api/scraping/settings", {
source: e.source,
network: s,
proxy: l,
@@ -1307,40 +1410,40 @@ function Ut({ source: e, toast: r }) {
D.current.signal.aborted || (o(n.saved), u(""), f(""), m(""), v(""), T.current && (T.current.value = ""), r(t === "revoke" ? "Cookie 已撤销" : "来源设置已保存"));
}
} catch (e) {
- D.current.signal.aborted || S(P(e));
+ D.current.signal.aborted || S(F(e));
} finally {
D.current.signal.aborted || b(!1);
}
}
}
- return /* @__PURE__ */ V("section", {
+ return /* @__PURE__ */ U("section", {
class: "scraping-source",
- children: /* @__PURE__ */ V("form", {
+ children: /* @__PURE__ */ U("form", {
ref: E,
class: "cleanupfieldset",
"data-geist-fieldset": !0,
onSubmit: (e) => {
e.preventDefault(), O("save");
},
- children: [/* @__PURE__ */ V("div", {
+ children: [/* @__PURE__ */ U("div", {
class: "geist-fieldset-content scraping-fields",
children: [
- /* @__PURE__ */ V("div", { dangerouslySetInnerHTML: { __html: t(`scraping-${e.source}`, e.label) } }),
- /* @__PURE__ */ V("a", {
+ /* @__PURE__ */ U("div", { dangerouslySetInnerHTML: { __html: t(`scraping-${e.source}`, e.label) } }),
+ /* @__PURE__ */ U("a", {
class: "scraping-url",
href: e.login,
target: "_blank",
rel: "noopener noreferrer",
children: e.login
}),
- /* @__PURE__ */ V("div", {
+ /* @__PURE__ */ U("div", {
class: "scraping-label",
- children: ["连接方式", /* @__PURE__ */ V(Ht, {
+ children: ["连接方式", /* @__PURE__ */ U(Ht, {
value: s,
onChange: c
})]
}),
- s === "proxy" && /* @__PURE__ */ V("label", { children: ["代理地址", /* @__PURE__ */ V("input", {
+ s === "proxy" && /* @__PURE__ */ U("label", { children: ["代理地址", /* @__PURE__ */ U("input", {
class: "geist-input",
type: "password",
autoComplete: "off",
@@ -1349,13 +1452,13 @@ function Ut({ source: e, toast: r }) {
disabled: y,
onInput: (e) => u(e.currentTarget.value)
})] }),
- e.accepts_cookie && /* @__PURE__ */ V(j, { children: [
- /* @__PURE__ */ V("p", { children: a.cookie_saved ? "Cookie 已保存,登录是否有效请在抓取时确认。" : "需要登录时,任选一种方式提供 Cookie。" }),
- /* @__PURE__ */ V("div", {
+ e.accepts_cookie && /* @__PURE__ */ U(M, { children: [
+ /* @__PURE__ */ U("p", { children: a.cookie_saved ? "Cookie 已保存,登录是否有效请在抓取时确认。" : "需要登录时,任选一种方式提供 Cookie。" }),
+ /* @__PURE__ */ U("div", {
class: "insightswitch scraping-cookie-method",
role: "radiogroup",
"aria-label": "提供 Cookie 的方式(二选一)",
- children: [["paste", "粘贴 Cookie"], ["file", "导入文件"]].map(([t, n]) => /* @__PURE__ */ V("label", { children: [/* @__PURE__ */ V("input", {
+ children: [["paste", "粘贴 Cookie"], ["file", "导入文件"]].map(([t, n]) => /* @__PURE__ */ U("label", { children: [/* @__PURE__ */ U("input", {
type: "radio",
name: `cookie-method-${e.source}`,
value: t,
@@ -1363,29 +1466,29 @@ function Ut({ source: e, toast: r }) {
onChange: () => {
g(t), f(""), m(""), v("");
}
- }), /* @__PURE__ */ V("span", { children: n })] }, t))
+ }), /* @__PURE__ */ U("span", { children: n })] }, t))
}),
- h === "paste" ? /* @__PURE__ */ V("label", { children: ["Cookie", /* @__PURE__ */ V("input", {
+ h === "paste" ? /* @__PURE__ */ U("label", { children: ["Cookie", /* @__PURE__ */ U("input", {
class: "geist-input",
type: "password",
autoComplete: "off",
value: d,
disabled: y,
onInput: (e) => f(e.currentTarget.value)
- })] }) : /* @__PURE__ */ V("label", {
+ })] }) : /* @__PURE__ */ U("label", {
class: "scraping-file",
- children: ["Netscape Cookie 文件(.txt)", /* @__PURE__ */ V("span", {
+ children: ["Netscape Cookie 文件(.txt)", /* @__PURE__ */ U("span", {
class: "scraping-file-control",
children: [
- /* @__PURE__ */ V("span", {
+ /* @__PURE__ */ U("span", {
class: "geist-button",
children: "选择文件"
}),
- /* @__PURE__ */ V("span", {
+ /* @__PURE__ */ U("span", {
class: "scraping-file-name",
children: _ || "未选择文件"
}),
- /* @__PURE__ */ V("input", {
+ /* @__PURE__ */ U("input", {
ref: T,
type: "file",
accept: ".txt",
@@ -1415,31 +1518,31 @@ function Ut({ source: e, toast: r }) {
})]
})
] }),
- x && /* @__PURE__ */ V("div", {
+ x && /* @__PURE__ */ U("div", {
role: "alert",
dangerouslySetInnerHTML: { __html: n(x, { variant: "error" }) }
}),
- C.map((t) => /* @__PURE__ */ V("div", {
+ C.map((t) => /* @__PURE__ */ U("div", {
role: "status",
dangerouslySetInnerHTML: { __html: n(`${e.label}${t.label === "来源页面" ? "" : " 高清图片"}:${t.ok ? "可连接" : "不能连接"}` + (t.width ? ` · ${t.width} × ${t.height}` : "") + (t.message ? `。${t.message}` : ""), { variant: t.ok ? "success" : "error" }) }
}, t.label))
]
- }), /* @__PURE__ */ V("footer", {
+ }), /* @__PURE__ */ U("footer", {
class: "geist-fieldset-footer",
"data-geist-fieldset-footer": !0,
children: [
- /* @__PURE__ */ V("button", {
+ /* @__PURE__ */ U("button", {
class: "geist-button primary",
type: "submit",
children: "保存"
}),
- /* @__PURE__ */ V("button", {
+ /* @__PURE__ */ U("button", {
class: "geist-button",
type: "button",
onClick: () => void O("check"),
children: "检查连接"
}),
- e.accepts_cookie && a.cookie_saved && /* @__PURE__ */ V("button", {
+ e.accepts_cookie && a.cookie_saved && /* @__PURE__ */ U("button", {
class: "geist-button",
type: "button",
onClick: () => void O("revoke"),
@@ -1451,13 +1554,13 @@ function Ut({ source: e, toast: r }) {
});
}
function Wt({ data: e, error: r, toast: a }) {
- let [o, s] = z(""), [c, l] = z(!1), [u, d] = z(""), f = B(null);
- Le(() => i(f.current, c), [c]);
- let p = B(new AbortController()), m = B(0);
+ let [o, s] = V(""), [c, l] = V(!1), [u, d] = V(""), f = H(null);
+ Fe(() => i(f.current, c), [c]);
+ let p = H(new AbortController()), m = H(0);
async function h(e = !1) {
let t = ++m.current;
await zt({
- read: (e) => Ce("/api/scraping/cover", e),
+ read: (e) => I("/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 && a(t.result || "封面采集完成");
@@ -1465,37 +1568,37 @@ function Wt({ data: e, error: r, toast: a }) {
disconnected: () => d("连接中断,正在重新读取后台进度")
});
}
- Ie(() => (h(!0), () => p.current.abort()), []);
+ Pe(() => (h(!0), () => p.current.abort()), []);
async function g() {
if (!c) {
m.current++, l(!0), d("");
try {
- await F("/api/scraping/cover", { code: o }, "POST", p.current.signal), await h();
+ await L("/api/scraping/cover", { code: o }, "POST", p.current.signal), await h();
} catch (e) {
- p.current.signal.aborted || (l(!1), d(P(e)));
+ p.current.signal.aborted || (l(!1), d(F(e)));
}
}
}
- return r ? /* @__PURE__ */ V("div", {
+ return r ? /* @__PURE__ */ U("div", {
role: "alert",
dangerouslySetInnerHTML: { __html: n(r, { variant: "error" }) }
- }) : /* @__PURE__ */ V("div", {
+ }) : /* @__PURE__ */ U("div", {
class: "scraping-page",
children: [
- /* @__PURE__ */ V("p", { children: "高清图片可能需要代理才能下载,请先检查连接。" }),
- /* @__PURE__ */ V("section", {
+ /* @__PURE__ */ U("p", { children: "高清图片可能需要代理才能下载,请先检查连接。" }),
+ /* @__PURE__ */ U("section", {
class: "cleanupfieldset scraping-source",
"data-geist-fieldset": !0,
- children: /* @__PURE__ */ V("div", {
+ children: /* @__PURE__ */ U("div", {
class: "geist-fieldset-content scraping-fields",
children: [
- /* @__PURE__ */ V("div", { dangerouslySetInnerHTML: { __html: t("scraping-cover", "高清封面") } }),
- /* @__PURE__ */ V("form", {
+ /* @__PURE__ */ U("div", { dangerouslySetInnerHTML: { __html: t("scraping-cover", "高清封面") } }),
+ /* @__PURE__ */ U("form", {
class: "scraping-cover-form",
onSubmit: (e) => {
e.preventDefault(), g();
},
- children: [/* @__PURE__ */ V("input", {
+ children: [/* @__PURE__ */ U("input", {
class: "geist-input",
"aria-label": "馆藏番号",
required: !0,
@@ -1503,21 +1606,21 @@ function Wt({ data: e, error: r, toast: a }) {
disabled: c,
placeholder: "输入馆藏番号,如 ABW-232",
onInput: (e) => s(e.currentTarget.value)
- }), /* @__PURE__ */ V("button", {
+ }), /* @__PURE__ */ U("button", {
ref: f,
class: "geist-button primary",
type: "submit",
children: "抓取封面"
})]
}),
- u && /* @__PURE__ */ V("div", {
+ u && /* @__PURE__ */ U("div", {
role: "alert",
dangerouslySetInnerHTML: { __html: n(u, { variant: "error" }) }
})
]
})
}),
- e?.sources.map((e) => /* @__PURE__ */ V(Ut, {
+ e?.sources.map((e) => /* @__PURE__ */ U(Ut, {
source: e,
toast: a
}, e.source))
@@ -1571,19 +1674,19 @@ var Zt = {
component: Rt
},
configuration: {
- load: Xe,
- component: et
+ load: Je,
+ component: $e
}
-}, Qt = () => Object.keys(Zt), $ = /* @__PURE__ */ new Map();
-async function $t(e, t, n, r = {}) {
+}, Qt = () => Object.keys(Zt), $t = /* @__PURE__ */ new Map();
+async function en(e, t, n, r = {}) {
let i = Zt[e];
if (!i) throw Error(`未注册的 island:${String(e)}`);
- en(t);
+ tn(t);
let a = {
controller: new AbortController(),
painted: !1
};
- $.set(t, a);
+ $t.set(t, a);
let o;
try {
o = {
@@ -1594,12 +1697,12 @@ async function $t(e, t, n, r = {}) {
if (a.controller.signal.aborted) return;
o = {
data: null,
- error: P(e)
+ error: F(e)
};
}
- if ($.get(t) !== a) return;
+ if ($t.get(t) !== a) return;
if (r.isCurrent && !r.isCurrent()) {
- $.delete(t);
+ $t.delete(t);
return;
}
t.textContent = "", a.painted = !0;
@@ -1607,11 +1710,11 @@ async function $t(e, t, n, r = {}) {
...n,
...o
};
- be(k(i.component, s), t);
+ ye(A(i.component, s), t);
}
-function en(e) {
- let t = $.get(e);
- t && (t.controller.abort(), $.delete(e), t.painted && be(null, e));
+function tn(e) {
+ let t = $t.get(e);
+ t && (t.controller.abort(), $t.delete(e), t.painted && ye(null, e));
}
//#endregion
-export { Bt as followJobProgress, Qt as islandNames, $t as mountIsland, qt as refreshStore, Jt as sidebarHasCatalogContent, Xt as sidebarTagCounts, Kt as storeNames, Yt as syncSidebarSurface, en as unmountIsland, zt as watchJob };
+export { Bt as followJobProgress, Qt as islandNames, en as mountIsland, qt as refreshStore, Jt as sidebarHasCatalogContent, Xt as sidebarTagCounts, Kt as storeNames, Yt as syncSidebarSurface, tn as unmountIsland, zt as watchJob };