Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix: 完善配置与首启来源控件及视觉层次

Codex325770ecd57b
diff --git a/README.md b/README.md
index b7b5a3863..d9b92e47b 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,7 @@ Peach 在一台机器上就能完整运行,目前处于 pre-1.0 阶段。Windo
CloudDrive 在首次设置页与配置页按文件夹选择「CloudDrive · 115」或「CloudDrive · PikPak」。
先在 CloudDrive 登录对应网盘并完成挂载,再把本机文件夹填入 Peach;Windows 使用盘符路径,
-macOS 同时填写本机挂载点及对应的 Windows 账本根目录。配置页的「挂载状态」可刷新检查各来源。
+macOS 在「本机文件夹」填挂载点,在「Windows 中的对应路径」填馆藏已有的盘符路径。配置页的「挂载状态」可刷新检查各来源。
离线来源可保存,恢复挂载后再扫描。详细步骤见 [CloudDrive 配置](docs/OPERATIONS.md#clouddrive-配置)。
Ledger 是资产、身份、行为和复核决定的真相源。CloudDrive、在线站点和 AI 都是适配器或候选来源,不能直接改写真相字段。
diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md
index 3e10f863a..605726bdd 100644
--- a/docs/HANDOFF.md
+++ b/docs/HANDOFF.md
@@ -81,7 +81,7 @@ React 渲染的规格页、用户截图这类给不出可重抓字节的实测
- 相关推荐算法:`openaver-related-ranking`,固定 revision,只参考 Tag IDF 与结构化共同点,MMR 和稳定破同分是 Peach 自加,不复制上游界面或源码。
- 网格、控件半径、语义 token 与中间省略:`vercel-geist-grid`、`vercel-geist-controls-measured`、`vercel-geist-middle-truncate`;中间省略只用于路径、URL、ID、SHA 这类首尾都有信息的值,必须显式 `data-middle-truncate`,标题、说明、人名和标签保留末尾省略。
-- 统计与口味两页的层级,Note/Progress/Switch/Fieldset/Scroller/Empty State 的语义,按钮尺寸档与三态、主题选择器与下拉几何:`vercel-geist-semantics-measured`、`vercel-geist-note-progress-switch-analytics`、`vercel-geist-fieldset-scroller-empty-state`。
+- 统计与口味层级,Note/Progress/Switch/Fieldset/Scroller/Empty State 语义与控件:`vercel-geist-semantics-measured`、`vercel-geist-note-progress-switch-analytics`、`vercel-geist-fieldset-scroller-empty-state`;配置页截图补证:`vercel-geist-controls-measured`。
- 分类切换条属于 Tabs 的 secondary 变体而不是分段器:`vercel-geist-tabs-secondary-measured`。
- 表格、排行与面包屑:`vercel-geist-table-ranking`、`vercel-geist-breadcrumbs`;同形可比较数据才用语义 `table` 并保持 tabular numerals,内容标签是固定 Top 排行和直接筛选,不伪装成可排序数据表。
- 设置 Dialog 动效、搜索期 Spinner、后台 Loading Dots 与 busy 按钮:`vercel-geist-command-search-loading`;中性说明 Note:`vercel-notifications-note`;具名动作 Toast:`vercel-geist-toast`;写操作前的确认弹层:`vercel-geist-modal-measured`。
diff --git a/docs/OPERATIONS.md b/docs/OPERATIONS.md
index 6f40b0d24..2576cc8ed 100644
--- a/docs/OPERATIONS.md
+++ b/docs/OPERATIONS.md
@@ -17,9 +17,9 @@
[CloudDrive 官方帮助](https://www.clouddrive2.com/help.html)。
2. 在 Peach 首次设置页或独立包的「管理 → 配置」中添加文件夹,选择对应来源。
115 使用来源 ID `115`,PikPak 使用 `pikpak`,本地磁盘使用 `local`;每个来源可有多个互不重叠的根。
-3. Windows 填本机盘符路径。macOS 的文件夹填本机挂载点,「账本根目录」填该来源原有的
+3. Windows 填本机盘符路径。macOS 的「本机文件夹」填本机挂载点,「Windows 中的对应路径」填该来源原有的
Windows 盘符根,例如 `B:\` 对应 `/Volumes/CloudDrive/115`、`A:\` 对应
- `/Volumes/CloudDrive/PikPak`。已有馆藏必须沿用原账本根目录。
+ `/Volumes/CloudDrive/PikPak`。已有馆藏必须沿用原盘符路径。
4. 保存配置,由托盘重新载入。配置页「挂载状态」逐根显示在线或离线;刷新状态保留尚未保存的输入。
Windows 的 Peach 与 CloudDrive 应在同一普通用户会话下运行;提升权限的进程可能看不到挂载盘。
5. 勾选扫描时,托盘顺序扫描配置内的在线来源,离线根跳过。恢复挂载后可再次勾选扫描并保存。
diff --git a/docs/reference-snapshots/vercel-geist-controls-measured.md b/docs/reference-snapshots/vercel-geist-controls-measured.md
index 0537b66cd..46199d2fc 100644
--- a/docs/reference-snapshots/vercel-geist-controls-measured.md
+++ b/docs/reference-snapshots/vercel-geist-controls-measured.md
@@ -9,6 +9,17 @@
## 实测值
+Peach 配置页的产品取值(根据用户于 2026-09-05 提出的间距要求):文字按钮左右内边距为 14px,
+纯图标按钮保留正方形;下拉箭头距右边框 14px,文字右侧预留 42px。以下上游测量值保留为证据,
+实现采用这里的产品取值。删除用危险色,在线与离线用成功色与危险色,并保留文字状态。
+系统说明只在当前运行系统适用时显示;配置页验收使用完整主站外壳与完整运行信息。
+
+配置页补充取证(2026-09-05):用户提供 Vercel Toolbar 的当前截图;浅色页面与底栏为浅灰、
+正文为白色,外边框与底栏分隔线同色。Peach 对应使用 `--page`/`--surface`、`--ground`、
+`--line` 和 6px 控件圆角;深色沿用项目色板。截图没有提供展开菜单的上游画面,展开行为沿用
+已取证的 `selectFieldHtml`/`wireSelectField`,不能只重画原生 select 的箭头。
+链接默认无下划线,悬停允许下划线;外链附右上角箭头图标。验收必须包含明暗主题和展开菜单。
+
| 项 | 值 |
| --- | --- |
| 输入框高 | 32 px |
diff --git a/frontend/src/islands/configuration.tsx b/frontend/src/islands/configuration.tsx
index 45b0f6628..cfd2ccf68 100644
--- a/frontend/src/islands/configuration.tsx
+++ b/frontend/src/islands/configuration.tsx
@@ -10,7 +10,7 @@
import { useEffect, useLayoutEffect, useRef, useState } from 'preact/hooks';
import type { JSX } from 'preact';
-import { fieldsetTitle, noteHtml, setActionBusy } from '@peach/legacy/ui';
+import { fieldsetTitle, noteHtml, setActionBusy, selectFieldHtml, wireSelectField } from '@peach/legacy/ui';
import { ApiError, apiGet, apiSend, errorMessage } from '../api';
export interface ConfigurationProps {
@@ -108,12 +108,30 @@ function MountStatus({ data }: { data: ConfigurationData }) {
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>
+ <dl class="configfacts">{sources.map((row) => <><dt>{({local: '本地磁盘', '115': 'CloudDrive · 115', pikpak: 'CloudDrive · PikPak'} as Record<string, string>)[row.location] || row.location}</dt><dd>{row.path || '未配置挂载点'} <span class={`configstatus ${row.online === true ? 'online' : row.online === false ? 'offline' : 'unknown'}`}>{row.online === true ? '在线' : row.online === false ? '离线' : '未检测'}</span></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 MediaSourceSelect({ value, label, onChange }: { value: string; label: string; onChange(value: string): void }) {
+ const mount = useRef<HTMLDivElement>(null);
+ const control = useRef<HTMLElement & { value: string; disabled: boolean } | null>(null);
+ const callback = useRef(onChange);
+ callback.current = onChange;
+ useLayoutEffect(() => {
+ const root = mount.current!;
+ root.innerHTML = selectFieldHtml([['local', '本地磁盘'], ['115', 'CloudDrive · 115'], ['pikpak', 'CloudDrive · PikPak']], value, { label });
+ const field = wireSelectField(root.firstElementChild!);
+ control.current = field;
+ const change = () => callback.current(field.value);
+ field.addEventListener('change', change);
+ return () => { control.current = null; field.disabled = true; field.removeEventListener('change', change); root.replaceChildren(); };
+ }, [label]);
+ useLayoutEffect(() => { if (control.current) control.current.value = value; }, [value]);
+ return <div ref={mount} class="configsourcecontrol" />;
+}
+
function ConfigurationForm({ data, receipt }: { data: ConfigurationData; receipt: ConfigurationProps['receipt'] }) {
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 : ['']);
@@ -237,6 +255,7 @@ function ConfigurationForm({ data, receipt }: { data: ConfigurationData; receipt
<div class="configdirs" role="group" aria-labelledby="configDirsLabel">
{dirs.map((value, index) => (
<div class="configdir" key={index}>
+ <span class="configpathlabel">本机文件夹 {index + 1}</span>
<input
class="geist-input"
type="text"
@@ -255,14 +274,12 @@ function ConfigurationForm({ data, receipt }: { data: ConfigurationData; receipt
</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:\\"
+ <div class="configsourcelabel">媒体来源
+ <MediaSourceSelect label={`媒体来源 ${index + 1}`} value={kinds[index] || 'local'}
+ onChange={(value) => { const next = [...kinds]; next[index] = value; setKinds(next); }} />
+ </div>
+ {data.windows === false ? <label>Windows 中的对应路径
+ <input class="geist-input" aria-label={`Windows 中的对应路径 ${index + 1}`} value={roots[index] || ''} placeholder="例如 B:\\"
onInput={(event) => { const next = [...roots]; next[index] = event.currentTarget.value; setRoots(next); }} />
</label> : null}
</div>
@@ -271,7 +288,8 @@ function ConfigurationForm({ data, receipt }: { data: ConfigurationData; receipt
))}
</div>
<button type="button" class="geist-button configadd" onClick={add}>添加文件夹</button>
- <p class="confighelp">CloudDrive:先登录网盘并挂载,再选择对应的 115 或 PikPak 来源。macOS 填本机挂载点与对应的账本盘符根。<a href="https://www.clouddrive2.com/help.html" target="_blank" rel="noreferrer">挂载帮助</a></p>
+ {kinds.some((kind) => kind === '115' || kind === 'pikpak') ? <p class="confighelp">先在 CloudDrive 登录网盘并完成挂载。<a href="https://www.clouddrive2.com/help.html" target="_blank" rel="noreferrer">挂载帮助<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-external-link" /></svg></a></p> : null}
+ {data.windows === false ? <p class="confighelp">本机文件夹是这台电脑读取媒体的位置。Windows 中的对应路径用于匹配馆藏中已有的路径,例如 B:\ 对应本机挂载文件夹。</p> : null}
</div>
<div class="configfield">
<label for="configPort">本机访问端口</label>
diff --git a/frontend/test/configuration.test.tsx b/frontend/test/configuration.test.tsx
index 9199e92b8..3568bedc6 100644
--- a/frontend/test/configuration.test.tsx
+++ b/frontend/test/configuration.test.tsx
@@ -55,6 +55,28 @@ describe('配置页取数', () => {
});
describe('媒体文件夹列表', () => {
+ it('Windows 只显示本机路径,CloudDrive 帮助跟随来源', async () => {
+ const { el } = mount({ windows: true, media_sources: [{location:'local',root:'D:/',path:'D:/'}] });
+ expect(el.textContent).not.toContain('Windows 中的对应路径');
+ expect(el.textContent).not.toContain('挂载帮助');
+ expect(el.querySelector('select')).toBeNull();
+ const select = el.querySelector<HTMLElement>('.gselect')!;
+ select.dataset.value = '115'; select.dispatchEvent(new Event('change')); await settle();
+ expect(el.textContent).toContain('挂载帮助');
+ expect(el.textContent).not.toContain('macOS');
+ });
+ it('映射路径与本机文件夹成组,挂载状态保留文字与颜色', () => {
+ const { el } = mount({windows:false, media_sources:[
+ {location:'115',root:'B:/',path:'/Volumes/115',online:true},
+ {location:'pikpak',root:'A:/',path:'/Volumes/PikPak',online:false},
+ {location:'local',root:'D:/',path:'/Volumes/Media'},
+ ]});
+ expect(el.querySelectorAll('.configdir')).toHaveLength(3);
+ expect(el.querySelectorAll('[aria-label^="Windows 中的对应路径"]')).toHaveLength(3);
+ expect(el.querySelector('.configstatus.online')?.textContent).toBe('在线');
+ expect(el.querySelector('.configstatus.offline')?.textContent).toBe('离线');
+ expect(el.querySelector('.configstatus.unknown')?.textContent).toBe('未检测');
+ });
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 }]})));
@@ -112,7 +134,7 @@ describe('选择文件夹', () => {
const { el } = mount();
const pickButtons = el.querySelectorAll('.configpick');
expect(pickButtons).toHaveLength(1);
- expect(el.querySelector('.configdir')?.children[1]).toBe(pickButtons[0]);
+ expect(inputs(el)[0]?.nextElementSibling).toBe(pickButtons[0]);
el.querySelector<HTMLButtonElement>('.configpick')?.click();
await settle();
const [url, init] = fetch.mock.calls[0] ?? [];
diff --git a/frontend/test/stubs/legacy-ui.ts b/frontend/test/stubs/legacy-ui.ts
index db496c9f4..a0b35d815 100644
--- a/frontend/test/stubs/legacy-ui.ts
+++ b/frontend/test/stubs/legacy-ui.ts
@@ -17,7 +17,7 @@ export const fieldsetTitle = (id: string, title: string): string =>
export const selectFieldHtml = (items: string[][], value: string, options: { label?: string } = {}): string =>
`<div class="gselect" data-value="${value}"><button type="button" aria-haspopup="listbox" aria-label="${options.label}">${items.find(item => item[0] === value)?.[1]}</button></div>`;
export const wireSelectField = (root: HTMLElement) => {
- Object.defineProperty(root, 'value', { get: () => root.dataset.value });
+ Object.defineProperty(root, 'value', { get: () => root.dataset.value, set: (value: string) => { root.dataset.value = value; } });
return root as HTMLElement & { value: string; disabled: boolean };
};
diff --git a/src/peach/media_configuration.py b/src/peach/media_configuration.py
index 2dccb1405..baf0f57e3 100644
--- a/src/peach/media_configuration.py
+++ b/src/peach/media_configuration.py
@@ -41,7 +41,7 @@ def validate(raws: object, *, windows: bool) -> tuple[dict, dict, list[str]]:
if any(ord(char) < 32 for char in text + root):
raise ValueError("路径不能包含控制字符")
if not platform.is_windows_path(root) or ".." in PureWindowsPath(root).parts:
- raise ValueError("账本根目录必须是绝对盘符路径,例如 B:\\")
+ raise ValueError("Windows 中的对应路径必须包含盘符,例如 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("请填写本机挂载点的绝对路径")
@@ -51,7 +51,7 @@ def validate(raws: object, *, windows: bool) -> tuple[dict, dict, list[str]]:
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("账本根目录与另一行重复或重叠")
+ raise ValueError("Windows 中的对应路径与另一文件夹重复或重叠")
if path == other_path or path.is_relative_to(other_path) or other_path.is_relative_to(path):
raise ValueError("本机挂载点与另一行重复或重叠")
seen.append((declared, path))
diff --git a/src/peach/routes_pages.py b/src/peach/routes_pages.py
index ade95eae7..743f0689c 100644
--- a/src/peach/routes_pages.py
+++ b/src/peach/routes_pages.py
@@ -125,21 +125,29 @@ font:500 var(--fs-md) system-ui,sans-serif}
button[type=submit]:hover{background:color-mix(in srgb,var(--ink) 88%,var(--ground));color:var(--ground)}
/* 一行:输入框、选择文件夹、移除。flex 而不是 grid:只剩一行时移除键隐藏,
grid 的空轨道会留下一段 gap。 */
-.dir{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}
+.dir{display:flex;flex-wrap:wrap;gap:10px;padding:16px;border:1px solid var(--line-soft);border-radius:var(--control-radius);margin-top:16px}
.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}
+.sourcefields select{appearance:none;padding-right:42px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5'/%3E%3C/svg%3E");background-repeat:no-repeat;background-size:16px;background-position:right 14px center}
+.sourcefields label{display:grid;gap:6px;color:var(--muted);font-size:var(--fs-sm)}
+.sourcefields input[type=text]{width:100%;box-sizing:border-box}
+.help a{text-decoration:none}.help a:hover{text-decoration:underline;text-underline-offset:3px}
+.help a svg{width:14px;height:14px;margin-inline-start:4px;vertical-align:-2px;stroke:currentColor;fill:none;stroke-width:2}
+.sourcefields .gselect{display:flex;width:100%}.sourcefields .gselectfield{padding-inline:14px}
+.sourcefields select[hidden]{display:none}
.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)}
.rm svg,.pick svg{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;
stroke-linejoin:round}
.pick[aria-busy=true]{color:var(--muted);cursor:progress}
-.add{margin-top:8px;padding:0 12px}
+.add{margin-top:8px;padding:0 14px}
.rm:hover,.pick:hover,.add:hover{background:var(--hover);color:var(--ink)}
+.rm{color:var(--drop)}.rm:hover{background:var(--drop);border-color:var(--drop);color:white}
.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}}
@@ -192,7 +200,10 @@ _SETUP_SCRIPT = """<script>
row.querySelector('.rm').hidden=all.length<2;
row.querySelector('.pick').hidden=false;
});
+ var cloudHelp=document.getElementById('cloudHelp');
+ if(cloudHelp){cloudHelp.hidden=!Array.from(list.querySelectorAll('select[name="media_location"]')).some(function(select){return select.value!=='local';});}
};
+ list.addEventListener('change',refresh);
/* 「选择文件夹」让运行 Peach 的这台电脑弹系统对话框,把选中的绝对路径填回这一行:
浏览器自己拿不到本机绝对路径。等待期间按钮置忙,再点不发第二个请求。 */
var pickFolder=function(row,button){
@@ -254,9 +265,17 @@ _CHEVRON_SVG = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m6 9 6 6 6-
#: 两样东西借自站内共用控件:整页的覆盖式滚动条(原生那条藏掉,滑块浮在内容上),
#: 以及高级设置的折叠(原生 <details> 不过渡高度)。页面里没有 <details> 时 wireCollapse
#: 什么也不做,所以每张页面都挂同一段脚本。
-_SHARED_SCRIPT = ('<script type="module">import{attachOverlayScrollbar,wireCollapse}from"/js/ui-components.js";'
+_SHARED_SCRIPT = ('<script type="module">import{attachOverlayScrollbar,wireCollapse,selectFieldHtml,wireSelectField}from"/js/ui-components.js";'
'attachOverlayScrollbar(document.documentElement,{variant:"page"});'
- 'wireCollapse(document,"details","setup-collapse");</script>')
+ 'wireCollapse(document,"details","setup-collapse");'
+ 'const enhance=()=>document.querySelectorAll("select[name=media_location]:not([hidden])").forEach(select=>{'
+ 'const holder=document.createElement("div");'
+ 'holder.innerHTML=selectFieldHtml(Array.from(select.options,o=>[o.value,o.text]),select.value,{label:select.getAttribute("aria-label")||"媒体来源"});'
+ 'select.after(holder);const field=wireSelectField(holder.firstElementChild);'
+ 'field.addEventListener("change",()=>{select.value=field.value;select.dispatchEvent(new Event("change",{bubbles:true}));});'
+ 'select.hidden=true;});enhance();'
+ 'const dirs=document.getElementById("dirs");if(dirs)new MutationObserver(enhance).observe(dirs,{childList:true});'
+ '</script>')
def _theme_tokens() -> str:
@@ -295,13 +314,15 @@ def error_page(status: int, message: str) -> str:
def _button_rules() -> str:
"""独立页面直接使用主站的 Geist Button 规则。"""
base = (PROJECT_ROOT / "web/css/01-base.css").read_text(encoding="utf-8")
- return '\n'.join(re.findall(r'^\.geist-button[^{}]*\{[^}]*\}', base, re.M))
+ return '\n'.join(re.findall(r'^\.(?:geist-button|gselect|popmenu)[^{}]*\{[^}]*\}', base, re.M))
def _document(title: str, body: str) -> str:
# 页内脚本对两张页面都生效:找不到对应控件时它什么也不做。
+ index = (PROJECT_ROOT / "web/index.html").read_text(encoding="utf-8")
+ symbols = ''.join(re.findall(r'<symbol id="i-(?:check|chevron-down)"[^>]*>.*?</symbol>', index))
return (f"{_SETUP_HEAD}<title>{title}</title><style>{_theme_tokens()}{_scrollbar_rules()}</style>"
- f"{_SETUP_STYLE}<style>{_button_rules()}</style></head><body><main>{body}</main>{_SETUP_SCRIPT}{_SHARED_SCRIPT}</body></html>\n")
+ f'{_SETUP_STYLE}<style>{_button_rules()}</style></head><body><svg width="0" height="0" aria-hidden="true" style="position:absolute">{symbols}</svg><main>{body}</main>{_SETUP_SCRIPT}{_SHARED_SCRIPT}</body></html>\n')
def _check_html(name: str, text_html: str, *, checked: bool) -> str:
@@ -314,12 +335,14 @@ def _check_html(name: str, text_html: str, *, checked: bool) -> str:
def runtime_facts(config) -> tuple[tuple[str, str], ...]:
"""这台机器上 Peach 的位置与版本:设置完成页和 `/api/configuration` 共用同一份。"""
from . import __version__
+ import platform as system_platform
from .ffmpeg import FFmpegResolver
available = FFmpegResolver(config.directory("tools") / "ffmpeg").ffmpeg() is not None
ffmpeg = "可用" if available else "未安装;MP4 可直接播放,转码和缩略图需要安装 FFmpeg。"
return (
("版本", __version__),
+ ("操作系统", system_platform.system()),
("数据目录", str(config.data_root)),
("设置文件", str(config.path)),
("日志目录", str(config.directory("logs"))),
@@ -343,8 +366,8 @@ def _media_dir_row(value: str, error: str, *, first: bool, location: str = "loca
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 ''
+ mapping = (f'<label>Windows 中的对应路径<input name="media_root" type="text" aria-label="Windows 中的对应路径" '
+ f'placeholder="例如 B:\\" value="{escape(root, quote=True)}"></label>') 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"}" '
@@ -352,7 +375,7 @@ def _media_dir_row(value: str, error: str, *, first: bool, location: str = "loca
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 "")
- + f'<div class="sourcefields">{source}{mapping}</div></div>')
+ + f'<div class="sourcefields"><label>媒体来源{source}</label>{mapping}</div></div>')
def _media_dirs_html(values: Sequence[str], errors: Sequence[str], note: str, *, locations=(), roots=(), windows=True) -> str:
@@ -375,8 +398,9 @@ def _media_dirs_html(values: Sequence[str], errors: Sequence[str], note: str, *,
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, windows=windows)}</template>'
- '<p class="help">CloudDrive:先在 CloudDrive 登录网盘并挂载,再选择对应的 115 或 PikPak 来源。'
- '<a href="https://www.clouddrive2.com/help.html" target="_blank" rel="noreferrer">挂载帮助</a></p>'
+ '<p class="help" id="cloudHelp" hidden>先在 CloudDrive 登录网盘并完成挂载。'
+ '<a href="https://www.clouddrive2.com/help.html" target="_blank" rel="noreferrer">挂载帮助'
+ '<svg aria-hidden="true" viewBox="0 0 24 24"><path d="M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/></svg></a></p>'
+ "".join(f'<p class="help">{escape(line)}</p>' for line in (help_text, note) if line)
+ "</div>"
)
@@ -444,7 +468,7 @@ def setup_page(
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), "" if windows else
- "本机文件夹填写 macOS 挂载点;账本根目录填写对应的 Windows 盘符路径。",
+ "本机文件夹是这台电脑读取媒体的位置;Windows 中的对应路径用于匹配馆藏中已有的路径。",
locations=values.get("media_location", ()), roots=values.get("media_root", ()), windows=windows))
continue
value = str(values.get(question.key, question.default))
diff --git a/tests/test_configuration_sources.py b/tests/test_configuration_sources.py
index 68172e096..d0ebffa60 100644
--- a/tests/test_configuration_sources.py
+++ b/tests/test_configuration_sources.py
@@ -10,6 +10,23 @@ from peach import media_configuration as media_config, onboarding, settings_file
class MediaConfigurationTests(unittest.TestCase):
+ def test_setup_mapping_fields_follow_the_server_operating_system(self):
+ from peach import routes_pages
+ with tempfile.TemporaryDirectory() as directory:
+ config = settings_file.load_config(environ={"PEACH_DATA_ROOT": str(Path(directory).resolve())})
+ windows = routes_pages.setup_page(config, windows=True)
+ other = routes_pages.setup_page(config, windows=False)
+ self.assertNotIn('name="media_root"', windows)
+ self.assertNotIn('Windows 中的对应路径', windows)
+ self.assertIn('Windows 中的对应路径', other)
+ self.assertIn('wireSelectField', windows)
+ self.assertIn('new MutationObserver(enhance)', windows)
+ self.assertIn('id="i-chevron-down"', windows)
+ self.assertIn('.help a:hover{text-decoration:underline;', windows)
+ facts = dict(routes_pages.runtime_facts(config))
+ self.assertIn('操作系统', facts)
+ self.assertIn('设置文件', facts)
+
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:/"},
diff --git a/tests/test_onboarding.py b/tests/test_onboarding.py
index 723120525..991b8ba28 100644
--- a/tests/test_onboarding.py
+++ b/tests/test_onboarding.py
@@ -600,7 +600,7 @@ class SetupPageTests(_Case):
"""高级设置是 Geist Collapse:借主站的 wireCollapse,chevron 与高度都 200ms;滚动条也是主站那条。"""
body = self._get("/").text
self.assertIn('<summary><span>高级设置</span><svg viewBox="0 0 24 24" aria-hidden="true">', body)
- self.assertIn('import{attachOverlayScrollbar,wireCollapse}from"/js/ui-components.js";'
+ self.assertIn('import{attachOverlayScrollbar,wireCollapse,selectFieldHtml,wireSelectField}from"/js/ui-components.js";'
'attachOverlayScrollbar(document.documentElement,{variant:"page"});'
'wireCollapse(document,"details","setup-collapse");', body)
self.assertIn('.fcollapse{overflow:hidden;transition:height .2s ease-in-out;margin:0 -6px;padding:0 6px}', body)
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 7e05daa72..39370f931 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -352,7 +352,7 @@ class WebUiSourceTests(unittest.TestCase):
".geist-progress", ".watchprogress", ".vjs-play-progress", ".vjs-progress-holder",
".range-fill", "slider-thumb", "range-thumb", ".trace .bar", ".tokbar", # 进度与数据
"#censorSetting:checked", # Toggle 开态:Geist Toggle 实测轨道 rgb(0,112,243)
- ".entitylink", ".flink", ".fsourcelink", ".fcred a", ".tokauthor>a", # 真正的链接
+ ".entitylink", ".flink", ".fsourcelink", ".fcred a", ".tokauthor>a", ".confighelp a", # 真正的链接
)
def test_tungsten_is_reserved_for_focus_links_progress_and_toggle(self):
@@ -432,7 +432,7 @@ class WebUiSourceTests(unittest.TestCase):
白字不带描边,次级 `#FFFFFF` 底 `#171717` 字加 `0 0 0 1px #EBEBEB`。次级不是透明的
——压在 `#FAFAFA` 的操作条上时,透明会让按钮和条子连成一片,只剩一条边框在飘。
"""
- self.assertCode(".geist-button{box-sizing:border-box;height:32px;padding:0 6px;"
+ self.assertCode(".geist-button{box-sizing:border-box;height:32px;padding:0 14px;"
"border:1px solid var(--line-soft);border-radius:var(--control-radius);"
"background:var(--ground);color:var(--ink);display:inline-flex;")
self.assertPageContains(".geist-button:hover:not(:disabled){background:var(--surface)}")
@@ -2311,11 +2311,24 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("padding-top:max(18px,env(safe-area-inset-top))")
self.assertPageContains("padding-bottom:max(18px,env(safe-area-inset-bottom))")
- def test_links_never_use_underlines(self):
- """Peach 的链接反馈只用颜色、背景或描边,任何表面都不画下划线。"""
+ def test_links_only_use_underlines_on_hover(self):
+ """文字链接允许悬停下划线,默认状态保持清爽。"""
self.assertPageContains(".entitylink:hover{color:var(--ink);text-decoration:none}")
self.assertPageContains(".idcell.entitylink:hover,.mav.entitylink:hover{text-decoration:none}")
- self.assertPageLacks("text-decoration:underline")
+ self.assertPageContains(".confighelp a:hover{text-decoration:underline;")
+ for selector, declarations in re.findall(r'([^{}]+)\{([^{}]*)\}', stylesheet_source()):
+ if "text-decoration:underline" in declarations:
+ self.assertIn(":hover", selector)
+
+ def test_configuration_uses_fieldset_surfaces_and_shared_select(self):
+ css = stylesheet_source()
+ for selector, expected in ((".configfieldset", "background:var(--ground)"),
+ (".configfieldset>.geist-fieldset-footer", "background:var(--surface)")):
+ start = css.index(selector + "{")
+ rule = css[start:css.index("}", start)]
+ self.assertIn(expected, rule)
+ self.assertIn("solid var(--line)", rule)
+ self.assertIn(".configsourcecontrol .gselectfield{padding-inline:14px}", css)
def test_every_identity_cell_can_carry_its_own_portrait(self):
# 人物格走和顶栏圆头像同一个 entityFaceImg;这一格没有代表作头像可退,
@@ -4430,9 +4443,10 @@ class WebUiSourceTests(unittest.TestCase):
def test_anchored_menu_fits_the_room_it_has_instead_of_covering_its_toggle(self):
# 资料页的统称菜单挂在标题上,上方只有一条顶栏的距离、下方也未必够高。
# 两侧都放不下时压到宽的那一侧、内部滚,不横跨触发钮。
- self.assertCode("const downward=under>=menu.scrollHeight||under>=over;")
+ self.assertCode("const naturalHeight=menu.scrollHeight+menu.offsetHeight-menu.clientHeight;")
+ self.assertCode("const downward=under>=naturalHeight||under>=over;")
self.assertCode(
- "const height=Math.min(menu.scrollHeight,Math.max(downward?under:over,0));")
+ "const height=Math.min(naturalHeight,Math.max(downward?under:over,0));")
self.assertCode("menu.style.maxHeight=height+'px';")
self.assertCode(
"menu.style.top=(downward?anchor.bottom+8:anchor.top-8-height)+'px'")
diff --git a/web/css/01-base.css b/web/css/01-base.css
index 4a1574266..10625d26c 100644
--- a/web/css/01-base.css
+++ b/web/css/01-base.css
@@ -164,7 +164,7 @@ button,a,input,textarea,select,summary{touch-action:manipulation}
次级是 --ds-background-100 的白面加一圈 1px #EBEBEB,主动作是 #171717 实底白字、
不带描边,禁用态落到 #F2F2F2 底 #8F8F8F 字。所以次级不是透明的——它自己是一块面,
压在 fieldset 的操作条上时要比条子亮,不能透出条子的底。 */
-.geist-button{box-sizing:border-box;height:32px;padding:0 6px;border:1px solid var(--line-soft);
+.geist-button{box-sizing:border-box;height:32px;padding:0 14px;border:1px solid var(--line-soft);
border-radius:var(--control-radius);background:var(--ground);color:var(--ink);display:inline-flex;
align-items:center;justify-content:center;gap:6px;font:inherit;font-size:var(--fs-md);font-weight:500;
line-height:1;white-space:nowrap;cursor:pointer;
diff --git a/web/css/23-configuration.css b/web/css/23-configuration.css
index 0dfa5db1b..7624f28fc 100644
--- a/web/css/23-configuration.css
+++ b/web/css/23-configuration.css
@@ -3,30 +3,42 @@
底部操作条 --fieldset-bar-h、左说明右动作。 */
.configuration-layout .managetitle,.configuration-layout .pagelede{width:min(812px,100%);margin-left:auto;margin-right:auto}
.configpage{width:min(812px,100%);margin:0 auto;display:grid;gap:20px}
+.configpage .geist-button{min-height:var(--control-h)}
.configfieldset{display:flex;flex-direction:column;min-width:0;margin:0;padding:0;overflow:hidden;
- border:1px solid var(--line-soft);border-radius:var(--floating-radius);background:var(--surface)}
+ border:1px solid var(--line);border-radius:var(--control-radius);background:var(--ground)}
.configfieldset>.geist-fieldset-content{flex:1;min-height:0;padding:20px;display:grid;gap:24px}
.configfieldset .geist-fieldset-title{margin:0}
.configfieldset>.geist-fieldset-footer{box-sizing:border-box;min-height:var(--fieldset-bar-h);
margin:0;padding:8px 16px 8px 20px;display:flex;align-items:center;justify-content:flex-end;gap:8px;
- border-top:1px solid var(--border-10);background:var(--overlay-5)}
+ border-top:1px solid var(--line);background:var(--surface)}
.configfieldset>.geist-fieldset-footer>p{min-width:0;margin:0 auto 0 0;color:var(--muted);font-size:var(--fs-sm)}
.configfield>label,.configfield>.configlabel{display:block;margin:0 0 8px;font-weight:500;color:var(--ink)}
.confighelp{margin:8px 0 0;color:var(--muted);font-size:var(--fs-sm);line-height:1.5}
+.confighelp a{color:var(--tungsten);text-decoration:none;margin-inline-start:6px}
+.confighelp a:hover{text-decoration:underline;text-underline-offset:3px}
+.confighelp a svg{display:inline-block;width:14px;height:14px;margin-inline-start:4px;vertical-align:-2px;stroke:currentColor;fill:none;stroke-width:2}
.configbad{margin:6px 0 0;color:var(--drop);font-size:var(--fs-sm)}
/* 一行一个文件夹:输入框、选择文件夹、移除,三者共用 --control-h,差 3px 就不是一行了。
flex 而不是 grid:只剩一行时移除键不画,grid 的空轨道会留下一段 gap。 */
-.configdir{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}
+.configdir{display:flex;flex-wrap:wrap;gap:10px;padding:16px;border:1px solid var(--line-soft);border-radius:var(--control-radius);margin-top:16px}
+.configpathlabel{flex-basis:100%;font-weight:500}
.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)}
+.configpick.geist-button:hover:not(:disabled){color:var(--ink)}
+.configrm.geist-button{color:var(--drop)}
+.configrm.geist-button:hover:not(:disabled){color:white;background:var(--drop);border-color:var(--drop)}
+.configstatus{display:inline-block;margin-inline-start:8px;font-size:var(--fs-sm)}
+.configstatus.online{color:var(--success)}.configstatus.offline{color:var(--drop)}.configstatus.unknown{color:var(--muted)}
.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 label,.configsourcelabel{min-width:0;display:grid;gap:6px;font-size:var(--fs-sm);color:var(--muted)}
+.configsourcecontrol .gselect{display:flex;width:100%}
+.configsourcecontrol .gselectfield{padding-inline:14px}
.configsource .geist-input{width:100%;box-sizing:border-box}
+.configsource select.geist-input{appearance:none;padding-right:42px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5'/%3E%3C/svg%3E");background-repeat:no-repeat;background-size:16px;background-position:right 14px center}
.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}
diff --git a/web/dist/peach-ui.js b/web/dist/peach-ui.js
index a554bcddd..cd5277774 100644
--- a/web/dist/peach-ui.js
+++ b/web/dist/peach-ui.js
@@ -313,11 +313,11 @@ function Me(e, t) {
return e >= n.__.length && n.__.push({}), n.__[e];
}
function V(e) {
- return we = 1, Ne(Ue, e);
+ return we = 1, Ne(He, 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) {
+ if (r.t = e, !r.__c && (r.__ = [n ? n(t) : He(void 0, t), function(e) {
var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
t !== n && (r.__N = [n, r.__[1]], r.__c.setState({}));
}], r.__c = z, !z.__f)) {
@@ -350,26 +350,26 @@ function Ne(e, t, 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));
+ !B.__s && Ve(n.__H, t) && (n.__ = e, n.u = t, z.__H.__h.push(n));
}
-function Fe(e, t) {
+function H(e, t) {
var n = Me(R++, 4);
- !B.__s && He(n.__H, t) && (n.__ = e, n.u = t, z.__h.push(n));
+ !B.__s && Ve(n.__H, t) && (n.__ = e, n.u = t, z.__h.push(n));
}
-function H(e) {
- return we = 5, Ie(function() {
+function U(e) {
+ return we = 5, Fe(function() {
return { current: e };
}, []);
}
-function Ie(e, t) {
+function Fe(e, t) {
var n = Me(R++, 7);
- return He(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
+ return Ve(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
}
-function Le() {
+function Ie() {
for (var e; e = Te.shift();) {
var t = e.__H;
if (e.__P && t) try {
- t.__h.some(Be), t.__h.some(Ve), t.__h = [];
+ t.__h.some(ze), t.__h.some(Be), t.__h = [];
} catch (n) {
t.__h = [], B.__e(n, e.__v);
}
@@ -384,18 +384,18 @@ B.__b = function(e) {
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(Be), t.__h.some(Ve), t.__h = [], R = 0)), Se = z;
+ })) : (t.__h.some(ze), t.__h.some(Be), t.__h = [], R = 0)), Se = z;
}, B.diffed = function(e) {
Oe && Oe(e);
var t = e.__c;
- t && t.__H && (t.__H.__h.length && (Te.push(t) !== 1 && Ce === B.requestAnimationFrame || ((Ce = B.requestAnimationFrame) || ze)(Le)), t.__H.__.some(function(e) {
+ t && t.__H && (t.__H.__h.length && (Te.push(t) !== 1 && Ce === B.requestAnimationFrame || ((Ce = B.requestAnimationFrame) || Re)(Ie)), t.__H.__.some(function(e) {
e.u &&= (e.__H = e.u, void 0);
})), Se = z = null;
}, B.__c = function(e, t) {
t.some(function(e) {
try {
- e.__h.some(Be), e.__h = e.__h.filter(function(e) {
- return !e.__ || Ve(e);
+ e.__h.some(ze), e.__h = e.__h.filter(function(e) {
+ return !e.__ || Be(e);
});
} catch (n) {
t.some(function(e) {
@@ -408,40 +408,40 @@ B.__b = function(e) {
var t, n = e.__c;
n && n.__H && (n.__H.__.some(function(e) {
try {
- Be(e);
+ ze(e);
} catch (e) {
t = e;
}
}), n.__H = void 0, t && B.__e(t, n.__v));
};
-var Re = typeof requestAnimationFrame == "function";
-function ze(e) {
+var Le = typeof requestAnimationFrame == "function";
+function Re(e) {
var t, n = function() {
- clearTimeout(r), Re && cancelAnimationFrame(t), setTimeout(e);
+ clearTimeout(r), Le && cancelAnimationFrame(t), setTimeout(e);
}, r = setTimeout(n, 35);
- Re && (t = requestAnimationFrame(n));
+ Le && (t = requestAnimationFrame(n));
}
-function Be(e) {
+function ze(e) {
var t = z, n = e.__c;
typeof n == "function" && (e.__c = void 0, n()), z = t;
}
-function Ve(e) {
+function Be(e) {
var t = z;
e.__c = e.__(), z = t;
}
-function He(e, t) {
+function Ve(e, t) {
return !e || e.length !== t.length || t.some(function(t, n) {
return t !== e[n];
});
}
-function Ue(e, t) {
+function He(e, t) {
return typeof t == "function" ? t(e) : t;
}
//#endregion
//#region node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
-var We = 0;
+var Ue = 0;
Array.isArray;
-function U(e, t, n, r, i, a) {
+function W(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 U(e, t, n, r, i, a) {
__e: null,
__c: null,
constructor: void 0,
- __v: --We,
+ __v: --Ue,
__i: -1,
__u: 0,
__source: i,
@@ -467,33 +467,33 @@ function U(e, t, n, r, i, a) {
}
//#endregion
//#region src/islands/configuration.tsx
-var Ge = "/api/configuration", Ke = "/api/pick-folder", qe = 8e3, Je = (e, t) => I(Ge, t), W = ({ html: e, class: t }) => /* @__PURE__ */ U("div", {
+var We = "/api/configuration", Ge = "/api/pick-folder", Ke = 8e3, qe = (e, t) => I(We, t), G = ({ html: e, class: t }) => /* @__PURE__ */ W("div", {
class: t,
dangerouslySetInnerHTML: { __html: e }
-}), Ye = (e) => !(e instanceof be) || e.status !== 400 ? null : e.body?.errors ?? null;
-function Xe({ facts: e }) {
- return /* @__PURE__ */ U("section", {
+}), Je = (e) => !(e instanceof be) || e.status !== 400 ? null : e.body?.errors ?? null;
+function Ye({ facts: e }) {
+ return /* @__PURE__ */ W("section", {
class: "configfieldset",
"data-geist-fieldset": !0,
"aria-labelledby": "configFactsTitle",
- children: /* @__PURE__ */ U("div", {
+ children: /* @__PURE__ */ W("div", {
class: "geist-fieldset-content",
- children: [/* @__PURE__ */ U(W, { html: t("configFactsTitle", "运行信息") }), /* @__PURE__ */ U("dl", {
+ children: [/* @__PURE__ */ W(G, { html: t("configFactsTitle", "运行信息") }), /* @__PURE__ */ W("dl", {
class: "configfacts",
- children: e.map((e) => /* @__PURE__ */ U(M, { children: [/* @__PURE__ */ U("dt", { children: e.term }), /* @__PURE__ */ U("dd", { children: e.value })] }))
+ children: e.map((e) => /* @__PURE__ */ W(M, { children: [/* @__PURE__ */ W("dt", { children: e.term }), /* @__PURE__ */ W("dd", { children: e.value })] }))
})]
})
});
}
-function Ze({ data: e }) {
- let [n, r] = V(e.media_sources), [a, o] = V(""), s = H(null);
+function Xe({ data: e }) {
+ let [n, r] = V(e.media_sources), [a, o] = V(""), s = U(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);
+ let e = await I(We, t.signal);
t.signal.aborted || r(e.media_sources);
} catch (e) {
t.signal.aborted || o(F(e));
@@ -501,31 +501,34 @@ function Ze({ data: e }) {
s.current = null, i(e, !1);
}
};
- return n ? /* @__PURE__ */ U("section", {
+ return n ? /* @__PURE__ */ W("section", {
class: "configfieldset",
"aria-labelledby": "configMountsTitle",
- children: /* @__PURE__ */ U("div", {
+ children: /* @__PURE__ */ W("div", {
class: "geist-fieldset-content",
children: [
- /* @__PURE__ */ U(W, { html: t("configMountsTitle", "挂载状态") }),
- /* @__PURE__ */ U("dl", {
+ /* @__PURE__ */ W(G, { html: t("configMountsTitle", "挂载状态") }),
+ /* @__PURE__ */ W("dl", {
class: "configfacts",
- children: n.map((e) => /* @__PURE__ */ U(M, { children: [/* @__PURE__ */ U("dt", { children: [
- e.location,
- " · ",
- e.root
- ] }), /* @__PURE__ */ U("dd", { children: [
+ children: n.map((e) => /* @__PURE__ */ W(M, { children: [/* @__PURE__ */ W("dt", { children: {
+ local: "本地磁盘",
+ 115: "CloudDrive · 115",
+ pikpak: "CloudDrive · PikPak"
+ }[e.location] || e.location }), /* @__PURE__ */ W("dd", { children: [
e.path || "未配置挂载点",
- " · ",
- e.online ? "在线" : "离线"
+ " ",
+ /* @__PURE__ */ W("span", {
+ class: `configstatus ${e.online === !0 ? "online" : e.online === !1 ? "offline" : "unknown"}`,
+ children: e.online === !0 ? "在线" : e.online === !1 ? "离线" : "未检测"
+ })
] })] }))
}),
- a ? /* @__PURE__ */ U("p", {
+ a ? /* @__PURE__ */ W("p", {
class: "configbad",
role: "alert",
children: a
}) : null,
- /* @__PURE__ */ U("button", {
+ /* @__PURE__ */ W("button", {
type: "button",
class: "geist-button",
onClick: (e) => c(e.currentTarget),
@@ -535,17 +538,39 @@ function Ze({ data: e }) {
})
}) : null;
}
+function Ze({ value: e, label: t, onChange: n }) {
+ let i = U(null), o = U(null), s = U(n);
+ return s.current = n, H(() => {
+ let n = i.current;
+ n.innerHTML = r([
+ ["local", "本地磁盘"],
+ ["115", "CloudDrive · 115"],
+ ["pikpak", "CloudDrive · PikPak"]
+ ], e, { label: t });
+ let c = a(n.firstElementChild);
+ o.current = c;
+ let l = () => s.current(c.value);
+ return c.addEventListener("change", l), () => {
+ o.current = null, c.disabled = !0, c.removeEventListener("change", l), n.replaceChildren();
+ };
+ }, [t]), H(() => {
+ o.current && (o.current.value = e);
+ }, [e]), /* @__PURE__ */ W("div", {
+ ref: i,
+ class: "configsourcecontrol"
+ });
+}
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(() => {
+ ].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 = U(!1), D = U(e.revision), O = U([]), k = U(null);
+ H(() => {
w !== null && (O.current[w]?.focus(), T(null));
}, [w]), Pe(() => {
if (!S) return;
- let e = setTimeout(() => location.assign(S.url), qe);
+ let e = setTimeout(() => location.assign(S.url), Ke);
return () => clearTimeout(e);
}, [S]);
let A = (e, t) => {
@@ -564,7 +589,7 @@ function Qe({ data: e, receipt: r }) {
if (t.getAttribute("aria-busy") !== "true") {
i(t, !0);
try {
- let { path: t } = await L(Ke, { initial: o[e] ?? "" });
+ let { path: t } = await L(Ge, { initial: o[e] ?? "" });
t && (A(e, t), N(e, ""));
} catch (t) {
N(e, F(t));
@@ -573,24 +598,24 @@ function Qe({ data: e, receipt: r }) {
}
}
};
- return S ? /* @__PURE__ */ U("div", {
+ return S ? /* @__PURE__ */ W("div", {
class: "configsaved",
role: "status",
- children: [/* @__PURE__ */ U(W, { html: n("配置已保存,Peach 正在重新启动。", {
+ children: [/* @__PURE__ */ W(G, { html: n("配置已保存,Peach 正在重新启动。", {
variant: "success",
label: "已保存"
- }) }), /* @__PURE__ */ U("p", {
+ }) }), /* @__PURE__ */ W("p", {
class: "confighelp",
children: [
"几秒后自动打开新地址;没跳转就点 ",
- /* @__PURE__ */ U("a", {
+ /* @__PURE__ */ W("a", {
href: S.url,
children: "进入馆藏"
}),
"。"
]
})]
- }) : /* @__PURE__ */ U("form", {
+ }) : /* @__PURE__ */ W("form", {
class: "configfieldset",
"data-geist-fieldset": !0,
"aria-labelledby": "configTitle",
@@ -598,7 +623,7 @@ function Qe({ data: e, receipt: r }) {
if (t.preventDefault(), !E.current) {
E.current = !0, i(k.current, !0), x("");
try {
- let t = await L(Ge, {
+ let t = await L(We, {
revision: D.current,
media_dirs: o,
...e.media_sources ? { media_sources: o.map((e, t) => ({
@@ -611,7 +636,7 @@ function Qe({ data: e, receipt: r }) {
});
D.current = t.revision, _([]), y(""), r("已保存配置"), C(t);
} catch (e) {
- let t = Ye(e);
+ let t = Je(e);
t ? (_(t.media_dirs ?? []), y(t.port ?? "")) : (_([]), y(""), x(F(e)));
} finally {
E.current = !1, i(k.current, !1);
@@ -619,26 +644,30 @@ function Qe({ data: e, receipt: r }) {
}
},
noValidate: !0,
- children: [/* @__PURE__ */ U("div", {
+ children: [/* @__PURE__ */ W("div", {
class: "geist-fieldset-content",
children: [
- /* @__PURE__ */ U(W, { html: t("configTitle", "这台电脑") }),
- /* @__PURE__ */ U("div", {
+ /* @__PURE__ */ W(G, { html: t("configTitle", "这台电脑") }),
+ /* @__PURE__ */ W("div", {
class: "configfield",
children: [
- /* @__PURE__ */ U("span", {
+ /* @__PURE__ */ W("span", {
class: "configlabel",
id: "configDirsLabel",
children: "媒体文件夹"
}),
- /* @__PURE__ */ U("div", {
+ /* @__PURE__ */ W("div", {
class: "configdirs",
role: "group",
"aria-labelledby": "configDirsLabel",
- children: o.map((t, n) => /* @__PURE__ */ U("div", {
+ children: o.map((t, n) => /* @__PURE__ */ W("div", {
class: "configdir",
children: [
- /* @__PURE__ */ U("input", {
+ /* @__PURE__ */ W("span", {
+ class: "configpathlabel",
+ children: ["本机文件夹 ", n + 1]
+ }),
+ /* @__PURE__ */ W("input", {
class: "geist-input",
type: "text",
value: t,
@@ -649,55 +678,43 @@ function Qe({ data: e, receipt: r }) {
O.current[n] = e;
}
}),
- /* @__PURE__ */ U("button", {
+ /* @__PURE__ */ W("button", {
type: "button",
class: "geist-button configpick",
"aria-label": "选择文件夹",
onClick: (e) => P(n, e.currentTarget),
- children: /* @__PURE__ */ U("svg", {
+ children: /* @__PURE__ */ W("svg", {
viewBox: "0 0 24 24",
"aria-hidden": "true",
- children: /* @__PURE__ */ U("use", { href: "#i-folder-search" })
+ children: /* @__PURE__ */ W("use", { href: "#i-folder-search" })
})
}),
- o.length > 1 ? /* @__PURE__ */ U("button", {
+ o.length > 1 ? /* @__PURE__ */ W("button", {
type: "button",
class: "geist-button configrm",
"aria-label": "移除这个文件夹",
onClick: () => M(n),
- children: /* @__PURE__ */ U("svg", {
+ children: /* @__PURE__ */ W("svg", {
viewBox: "0 0 24 24",
"aria-hidden": "true",
- children: /* @__PURE__ */ U("use", { href: "#i-x" })
+ children: /* @__PURE__ */ W("use", { href: "#i-x" })
})
}) : null,
- /* @__PURE__ */ U("div", {
+ /* @__PURE__ */ W("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", {
+ children: [/* @__PURE__ */ W("div", {
+ class: "configsourcelabel",
+ children: ["媒体来源", /* @__PURE__ */ W(Ze, {
+ label: `媒体来源 ${n + 1}`,
+ value: c[n] || "local",
+ onChange: (e) => {
+ let t = [...c];
+ t[n] = e, l(t);
+ }
+ })]
+ }), e.windows === !1 ? /* @__PURE__ */ W("label", { children: ["Windows 中的对应路径", /* @__PURE__ */ W("input", {
class: "geist-input",
- "aria-label": `账本根目录 ${n + 1}`,
+ "aria-label": `Windows 中的对应路径 ${n + 1}`,
value: u[n] || "",
placeholder: "例如 B:\\\\",
onInput: (e) => {
@@ -706,7 +723,7 @@ function Qe({ data: e, receipt: r }) {
}
})] }) : null]
}),
- g[n] ? /* @__PURE__ */ U("p", {
+ g[n] ? /* @__PURE__ */ W("p", {
class: "configbad",
role: "alert",
children: g[n]
@@ -714,31 +731,39 @@ function Qe({ data: e, receipt: r }) {
]
}, n))
}),
- /* @__PURE__ */ U("button", {
+ /* @__PURE__ */ W("button", {
type: "button",
class: "geist-button configadd",
onClick: j,
children: "添加文件夹"
}),
- /* @__PURE__ */ U("p", {
+ c.some((e) => e === "115" || e === "pikpak") ? /* @__PURE__ */ W("p", {
class: "confighelp",
- children: ["CloudDrive:先登录网盘并挂载,再选择对应的 115 或 PikPak 来源。macOS 填本机挂载点与对应的账本盘符根。", /* @__PURE__ */ U("a", {
+ children: ["先在 CloudDrive 登录网盘并完成挂载。", /* @__PURE__ */ W("a", {
href: "https://www.clouddrive2.com/help.html",
target: "_blank",
rel: "noreferrer",
- children: "挂载帮助"
+ children: ["挂载帮助", /* @__PURE__ */ W("svg", {
+ "aria-hidden": "true",
+ viewBox: "0 0 24 24",
+ children: /* @__PURE__ */ W("use", { href: "#i-external-link" })
+ })]
})]
- })
+ }) : null,
+ e.windows === !1 ? /* @__PURE__ */ W("p", {
+ class: "confighelp",
+ children: "本机文件夹是这台电脑读取媒体的位置。Windows 中的对应路径用于匹配馆藏中已有的路径,例如 B:\\ 对应本机挂载文件夹。"
+ }) : null
]
}),
- /* @__PURE__ */ U("div", {
+ /* @__PURE__ */ W("div", {
class: "configfield",
children: [
- /* @__PURE__ */ U("label", {
+ /* @__PURE__ */ W("label", {
for: "configPort",
children: "本机访问端口"
}),
- /* @__PURE__ */ U("input", {
+ /* @__PURE__ */ W("input", {
id: "configPort",
class: "geist-input",
type: "text",
@@ -747,43 +772,43 @@ function Qe({ data: e, receipt: r }) {
"aria-invalid": v ? "true" : void 0,
onInput: (e) => p(e.currentTarget.value)
}),
- v ? /* @__PURE__ */ U("p", {
+ v ? /* @__PURE__ */ W("p", {
class: "configbad",
role: "alert",
children: v
}) : null,
- /* @__PURE__ */ U("p", {
+ /* @__PURE__ */ W("p", {
class: "confighelp",
children: "浏览器地址里冒号后面的数字,一般不用改。"
})
]
}),
- /* @__PURE__ */ U("label", {
+ /* @__PURE__ */ W("label", {
class: "configcheck",
- children: [/* @__PURE__ */ U("span", {
+ children: [/* @__PURE__ */ W("span", {
class: "pcheck",
- children: [/* @__PURE__ */ U("input", {
+ children: [/* @__PURE__ */ W("input", {
type: "checkbox",
checked: m,
onChange: (e) => h(e.currentTarget.checked)
- }), /* @__PURE__ */ U("span", {
+ }), /* @__PURE__ */ W("span", {
"aria-hidden": "true",
- children: /* @__PURE__ */ U("svg", {
+ children: /* @__PURE__ */ W("svg", {
viewBox: "0 0 24 24",
- children: /* @__PURE__ */ U("use", { href: "#i-check" })
+ children: /* @__PURE__ */ W("use", { href: "#i-check" })
})
})]
- }), /* @__PURE__ */ U("span", { children: "保存后扫描媒体文件夹" })]
+ }), /* @__PURE__ */ W("span", { children: "保存后扫描媒体文件夹" })]
}),
- b ? /* @__PURE__ */ U(W, { html: n(b, {
+ b ? /* @__PURE__ */ W(G, { html: n(b, {
variant: "error",
label: "没有保存"
}) }) : null
]
- }), /* @__PURE__ */ U("div", {
+ }), /* @__PURE__ */ W("div", {
class: "geist-fieldset-footer",
"data-geist-fieldset-footer": !0,
- children: [/* @__PURE__ */ U("p", { children: "保存后 Peach 会重新启动,端口改了就用新地址打开。" }), /* @__PURE__ */ U("button", {
+ children: [/* @__PURE__ */ W("p", { children: "保存后 Peach 会重新启动,端口改了就用新地址打开。" }), /* @__PURE__ */ W("button", {
type: "submit",
class: "geist-button primary",
ref: k,
@@ -793,24 +818,24 @@ function Qe({ data: e, receipt: r }) {
});
}
function $e({ receipt: e, data: t, error: r }) {
- return r || !t ? /* @__PURE__ */ U(W, {
+ return r || !t ? /* @__PURE__ */ W(G, {
class: "configpage",
html: n(r || "没有读到配置", {
variant: "error",
label: "打不开配置"
})
- }) : /* @__PURE__ */ U("div", {
+ }) : /* @__PURE__ */ W("div", {
class: "configpage",
children: [
- t.editable ? /* @__PURE__ */ U(Qe, {
+ t.editable ? /* @__PURE__ */ W(Qe, {
data: t,
receipt: e
- }) : /* @__PURE__ */ U(W, { html: n(t.notice, {
+ }) : /* @__PURE__ */ W(G, { html: n(t.notice, {
variant: "secondary",
label: "只读"
}) }),
- /* @__PURE__ */ U(Xe, { facts: t.facts }),
- /* @__PURE__ */ U(Ze, { data: t })
+ /* @__PURE__ */ W(Ye, { facts: t.facts }),
+ /* @__PURE__ */ W(Xe, { data: t })
]
});
}
@@ -818,7 +843,7 @@ function $e({ receipt: e, data: t, error: r }) {
//#region node_modules/@preact/signals-core/dist/signals-core.module.js
var et = Symbol.for("preact-signals");
function tt() {
- if (J > 1) J--;
+ if (Y > 1) Y--;
else {
var e, t = !1;
for ((function() {
@@ -828,9 +853,9 @@ function tt() {
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;
}
- })(); q !== void 0;) {
- var n = q;
- for (q = void 0, it++; n !== void 0;) {
+ })(); J !== void 0;) {
+ var n = J;
+ for (J = void 0, it++; n !== void 0;) {
var r = n.u;
if (n.u = void 0, n.f &= -3, !(8 & n.f) && dt(n)) try {
n.c();
@@ -840,57 +865,57 @@ function tt() {
n = r;
}
}
- if (it = 0, J--, t) throw e;
+ if (it = 0, Y--, t) throw e;
}
}
function nt(e) {
- if (J > 0) return e();
- ot = ++at, J++;
+ if (Y > 0) return e();
+ ot = ++at, Y++;
try {
return e();
} finally {
tt();
}
}
-var G, K = void 0;
+var K, q = void 0;
function rt(e) {
- var t = K, n = G;
- K = void 0, G = void 0;
+ var t = q, n = K;
+ q = void 0, K = void 0;
try {
return e();
} finally {
- K = t, G = n;
+ q = t, K = n;
}
}
-var q = void 0, J = 0, it = 0, at = 0, ot = 0, st = void 0, ct = 0;
+var J = void 0, Y = 0, it = 0, at = 0, ot = 0, st = void 0, ct = 0;
function lt(e) {
- if (K !== void 0) {
+ if (q !== void 0) {
var t = e.n;
- if (t === void 0 || t.t !== K) return t = {
+ if (t === void 0 || t.t !== q) return t = {
i: 0,
S: e,
- p: K.s,
+ p: q.s,
n: void 0,
- t: K,
+ t: q,
e: void 0,
x: void 0,
r: t
- }, K.s !== void 0 && (K.s.n = t), K.s = t, e.n = t, 32 & K.f && e.S(t), t;
- if (t.i === -1) return t.i = 0, t.n !== void 0 && (t.n.p = t.p, t.p !== void 0 && (t.p.n = t.n), t.p = K.s, t.n = void 0, K.s.n = t, K.s = t), t;
+ }, q.s !== void 0 && (q.s.n = t), q.s = t, e.n = t, 32 & q.f && e.S(t), t;
+ if (t.i === -1) return t.i = 0, t.n !== void 0 && (t.n.p = t.p, t.p !== void 0 && (t.p.n = t.n), t.p = q.s, t.n = void 0, q.s.n = t, q.s = t), t;
}
}
-function Y(e, t) {
+function X(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;
}
-Y.prototype.brand = et, Y.prototype.h = function() {
+X.prototype.brand = et, X.prototype.h = function() {
return !0;
-}, Y.prototype.S = function(e) {
+}, X.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 ? rt(function() {
var e;
(e = t.W) == null || e.call(t);
}) : n.e = e);
-}, Y.prototype.U = function(e) {
+}, X.prototype.U = function(e) {
var t = this;
if (this.t !== void 0) {
var n = e.e, r = e.x;
@@ -899,26 +924,26 @@ Y.prototype.brand = et, Y.prototype.h = function() {
(e = t.Z) == null || e.call(t);
}));
}
-}, Y.prototype.subscribe = function(e) {
+}, X.prototype.subscribe = function(e) {
var t = this;
- return Q(function() {
+ return vt(function() {
var n = t.value;
rt(function() {
return e(n);
});
}, { name: "sub" });
-}, Y.prototype.valueOf = function() {
+}, X.prototype.valueOf = function() {
return this.value;
-}, Y.prototype.toString = function() {
+}, X.prototype.toString = function() {
return this.value + "";
-}, Y.prototype.toJSON = function() {
+}, X.prototype.toJSON = function() {
return this.value;
-}, Y.prototype.peek = function() {
+}, X.prototype.peek = function() {
var e = this;
return rt(function() {
return e.value;
});
-}, Object.defineProperty(Y.prototype, "value", {
+}, Object.defineProperty(X.prototype, "value", {
get: function() {
var e = lt(this);
return e !== void 0 && (e.i = this.i), this.v;
@@ -927,13 +952,13 @@ Y.prototype.brand = et, Y.prototype.h = function() {
if (e !== this.v) {
if (it > 100) throw Error("Cycle detected");
(function(e) {
- J !== 0 && it === 0 && e.l !== ot && (e.l = ot, st = {
+ Y !== 0 && it === 0 && e.l !== ot && (e.l = ot, st = {
S: e,
v: e.v,
i: e.i,
o: st
});
- })(this), this.v = e, this.i++, ct++, J++;
+ })(this), this.v = e, this.i++, ct++, Y++;
try {
for (var t = this.t; t !== void 0; t = t.x) t.t.N();
} finally {
@@ -943,7 +968,7 @@ Y.prototype.brand = et, Y.prototype.h = function() {
}
});
function ut(e, t) {
- return new Y(e, t);
+ return new X(e, t);
}
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;
@@ -965,59 +990,59 @@ function pt(e) {
}
e.s = n;
}
-function X(e, t) {
- Y.call(this, void 0, t), this.x = e, this.s = void 0, this.g = ct - 1, this.f = 4;
+function Z(e, t) {
+ X.call(this, void 0, t), this.x = e, this.s = void 0, this.g = ct - 1, this.f = 4;
}
-X.prototype = new Y(), X.prototype.h = function() {
+Z.prototype = new X(), Z.prototype.h = function() {
if (this.f &= -3, 1 & this.f) return !1;
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;
+ var e = q;
try {
- ft(this), K = this;
+ ft(this), q = this;
var t = this.x();
(16 & this.f || this.v !== t || this.i === 0) && (this.v = t, this.f &= -17, this.i++);
} catch (e) {
this.v = e, this.f |= 16, this.i++;
}
- return K = e, pt(this), this.f &= -2, !0;
-}, X.prototype.S = function(e) {
+ return q = e, pt(this), this.f &= -2, !0;
+}, Z.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);
}
- 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)) {
+ X.prototype.S.call(this, e);
+}, Z.prototype.U = function(e) {
+ if (this.t !== void 0 && (X.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);
}
-}, X.prototype.N = function() {
+}, Z.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(X.prototype, "value", { get: function() {
+}, Object.defineProperty(Z.prototype, "value", { get: function() {
if (1 & this.f) throw Error("Cycle detected");
var e = lt(this);
if (this.h(), e !== void 0 && (e.i = this.i), 16 & this.f) throw this.v;
return this.v;
} });
function mt(e, t) {
- return new X(e, t);
+ return new Z(e, t);
}
function ht(e) {
var t = e.m;
if (e.m = void 0, typeof t == "function") {
- J++;
- var n = K;
- K = void 0;
+ Y++;
+ var n = q;
+ q = void 0;
try {
t();
} catch (t) {
throw e.f &= -2, e.f |= 8, gt(e), t;
} finally {
- K = n, tt();
+ q = n, tt();
}
}
}
@@ -1026,13 +1051,13 @@ function gt(e) {
e.x = void 0, e.s = void 0, ht(e);
}
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();
+ if (q !== this) throw Error("Out-of-order effect");
+ pt(this), q = e, this.f &= -2, 8 & this.f && gt(this), tt();
}
-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);
+function Q(e, t) {
+ this.x = e, this.m = void 0, this.s = void 0, this.u = void 0, this.f = 32, this.name = t?.name, K && K.push(this);
}
-Z.prototype.c = function() {
+Q.prototype.c = function() {
var e = this.S();
try {
if (8 & this.f || this.x === void 0) return;
@@ -1041,20 +1066,20 @@ Z.prototype.c = function() {
} finally {
e();
}
-}, Z.prototype.S = function() {
+}, Q.prototype.S = function() {
if (1 & this.f) throw Error("Cycle detected");
- 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 |= 1, this.f &= -9, ht(this), ft(this), Y++;
+ var e = q;
+ return q = this, _t.bind(this, e);
+}, Q.prototype.N = function() {
+ 2 & this.f || (this.f |= 2, this.u = J, J = this);
+}, Q.prototype.d = function() {
this.f |= 8, 1 & this.f || gt(this);
-}, Z.prototype.dispose = function() {
+}, Q.prototype.dispose = function() {
this.d();
};
-function Q(e, t) {
- var n = new Z(e, t);
+function vt(e, t) {
+ var n = new Q(e, t);
try {
n.c();
} catch (e) {
@@ -1065,24 +1090,24 @@ function Q(e, t) {
}
//#endregion
//#region node_modules/@preact/signals/dist/signals.module.js
-var vt, yt, bt = typeof window < "u" && !!window.__PREACT_SIGNALS_DEVTOOLS__, xt = [];
-Q(function() {
- vt = this.N;
+var yt, bt, xt = typeof window < "u" && !!window.__PREACT_SIGNALS_DEVTOOLS__, St = [];
+vt(function() {
+ yt = this.N;
})();
function $(e, t) {
u[e] = t.bind(null, u[e] || function() {});
}
-function St(e) {
- if (yt) {
- var t = yt;
- yt = void 0, t();
+function Ct(e) {
+ if (bt) {
+ var t = bt;
+ bt = void 0, t();
}
- yt = e && e.S();
+ bt = e && e.S();
}
-function Ct(e) {
- var t = this, n = e.data, r = Tt(n);
+function wt(e) {
+ var t = this, n = e.data, r = Et(n);
r.name = "ReactiveDom", r.value = n;
- var i = Ie(function() {
+ var i = Fe(function() {
for (var e = t, n = t.__v; n = n.__;) if (n.__c) {
n.__c.__$f |= 4;
break;
@@ -1092,8 +1117,8 @@ function Ct(e) {
return e === 0 ? 0 : !0 === e ? "" : e || "";
}), a = mt(function() {
return !Array.isArray(i.value) && !f(i.value);
- }), o = Q(function() {
- if (this.N = Ot, a.value) {
+ }), o = vt(function() {
+ if (this.N = kt, a.value) {
var t = i.value;
e.__v && e.__v.__e && e.__v.__e.nodeType === 3 && (e.__v.__e.data = t);
}
@@ -1104,14 +1129,14 @@ function Ct(e) {
}, []), a = i[0], o = i[1];
return a.value ? o.peek() : o.value;
}
-Ct.displayName = "ReactiveTextNode", Object.defineProperties(Y.prototype, {
+wt.displayName = "ReactiveTextNode", Object.defineProperties(X.prototype, {
constructor: {
configurable: !0,
value: void 0
},
type: {
configurable: !0,
- value: Ct
+ value: wt
},
props: {
configurable: !0,
@@ -1131,30 +1156,30 @@ Ct.displayName = "ReactiveTextNode", Object.defineProperties(Y.prototype, {
var n, r = t.props;
for (var i in r) if (i !== "children") {
var a = r[i];
- a instanceof Y && (n || (t.__np = n = {}), n[i] = a, r[i] = a.peek());
+ a instanceof X && (n || (t.__np = n = {}), n[i] = a, r[i] = a.peek());
}
}
e(t);
}), $("__r", function(e, t) {
if (e(t), t.type !== M) {
- St();
+ Ct();
var n, r = t.__c;
r && (r.__$f &= -2, (n = r.__$u) === void 0 && (r.__$u = n = function(e, t) {
var n;
- return Q(function() {
+ return vt(function() {
n = this;
}, { name: t }), n.c = e, n;
}(function(e) {
return function() {
var t;
- bt && ((t = this.y) == null || t.call(this)), e.__$f |= 1, e.setState({});
+ xt && ((t = this.y) == null || t.call(this)), e.__$f |= 1, e.setState({});
};
- }(r), typeof t.type == "function" ? t.type.displayName || t.type.name : ""))), St(n);
+ }(r), typeof t.type == "function" ? t.type.displayName || t.type.name : ""))), Ct(n);
}
}), $("__e", function(e, t, n, r) {
- St(), e(t, n, r);
+ Ct(), e(t, n, r);
}), $("diffed", function(e, t) {
- St();
+ Ct();
var n;
if (typeof t.type == "string" && (n = t.__e)) {
var r = t.__np, i = t.props, a = n.U;
@@ -1164,19 +1189,19 @@ Ct.displayName = "ReactiveTextNode", Object.defineProperties(Y.prototype, {
}
if (r) for (var c in a || (a = {}, n.U = a), r) {
var l = a[c], u = r[c];
- l === void 0 ? (l = wt(n, c, u, i), a[c] = l) : l.o(u, i);
+ l === void 0 ? (l = Tt(n, c, u, i), a[c] = l) : l.o(u, i);
}
}
e(t);
});
-function wt(e, t, n, r) {
+function Tt(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: Q(function() {
- this.N = Ot;
+ d: vt(function() {
+ this.N = kt;
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));
})
@@ -1220,44 +1245,44 @@ $("unmount", function(e, t) {
for (var s in this.props) if (!(s in e)) return !0;
return !1;
};
-function Tt(e, t) {
- return Ie(function() {
+function Et(e, t) {
+ return Fe(function() {
return ut(e, t);
}, []);
}
-var Et = function(e) {
+var Dt = function(e) {
queueMicrotask(function() {
queueMicrotask(e);
});
};
-function Dt() {
+function Ot() {
nt(function() {
- for (var e; e = xt.shift();) vt.call(e);
+ for (var e; e = St.shift();) yt.call(e);
});
}
-function Ot() {
- xt.push(this) === 1 && (u.requestAnimationFrame || Et)(Dt);
+function kt() {
+ St.push(this) === 1 && (u.requestAnimationFrame || Dt)(Ot);
}
//#endregion
//#region src/state/quality-goals.ts
-var kt = "/api/quality-goals?limit=200", At = {
+var At = "/api/quality-goals?limit=200", jt = {
data: null,
error: ""
-}, jt = ut(At), Mt = 0, Nt = mt(() => jt.value);
-mt(() => jt.value.data?.total ?? null);
-function Pt() {
- Mt += 1, jt.value = At;
+}, Mt = ut(jt), Nt = 0, Pt = mt(() => Mt.value);
+mt(() => Mt.value.data?.total ?? null);
+function Ft() {
+ Nt += 1, Mt.value = jt;
}
-async function Ft(e) {
- let t = Mt += 1;
+async function It(e) {
+ let t = Nt += 1;
try {
- let n = await I(kt, e);
- return t === Mt && (jt.value = {
+ let n = await I(At, e);
+ return t === Nt && (Mt.value = {
data: n,
error: ""
}), n;
} catch (n) {
- throw !e?.aborted && t === Mt && (jt.value = {
+ throw !e?.aborted && t === Nt && (Mt.value = {
data: null,
error: F(n)
}), n;
@@ -1265,10 +1290,10 @@ async function Ft(e) {
}
//#endregion
//#region src/islands/quality-goals.tsx
-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__ */ U("div", {
+var Lt = (e, t) => It(t), Rt = (e) => e.has_cover ? `/cover?code=${encodeURIComponent(e.code ?? "")}` : `/poster?id=${e.id}&c=4`;
+function zt({ openItem: t, javTitleHtml: r, javDisplayName: i, srcBadge: a }) {
+ let { data: l, error: u } = Pt.value;
+ if (u) return /* @__PURE__ */ W("div", {
class: "qualitylist",
dangerouslySetInnerHTML: { __html: n(u, {
variant: "error",
@@ -1276,51 +1301,51 @@ function Rt({ openItem: t, javTitleHtml: r, javDisplayName: i, srcBadge: a }) {
}) }
});
let d = l?.items ?? [];
- return d.length ? /* @__PURE__ */ U("div", {
+ return d.length ? /* @__PURE__ */ W("div", {
class: "qualitylist",
- children: d.map((e) => /* @__PURE__ */ U("article", {
+ children: d.map((e) => /* @__PURE__ */ W("article", {
class: "qualityitem",
- children: [/* @__PURE__ */ U("button", {
+ children: [/* @__PURE__ */ W("button", {
class: "qualitycover",
type: "button",
"aria-label": `打开 ${i(e)}`,
onClick: () => t(e.id),
- children: /* @__PURE__ */ U("img", {
- src: Lt(e),
+ children: /* @__PURE__ */ W("img", {
+ src: Rt(e),
alt: "",
loading: "lazy",
onError: (e) => e.currentTarget.remove()
})
- }), /* @__PURE__ */ U("div", { children: [
- /* @__PURE__ */ U("h3", { children: /* @__PURE__ */ U("button", {
+ }), /* @__PURE__ */ W("div", { children: [
+ /* @__PURE__ */ W("h3", { children: /* @__PURE__ */ W("button", {
type: "button",
"data-middle-truncate": !0,
onClick: () => t(e.id),
dangerouslySetInnerHTML: { __html: r(e) }
}) }),
- /* @__PURE__ */ U("p", {
+ /* @__PURE__ */ W("p", {
class: "mono",
children: [
- /* @__PURE__ */ U("span", {
+ /* @__PURE__ */ W("span", {
style: "display:contents",
dangerouslySetInnerHTML: { __html: a(e.location, e.cost) }
}),
- /* @__PURE__ */ U("span", { children: o[e.location] ?? e.location }),
- /* @__PURE__ */ U("span", { children: s(e.duration) }),
- /* @__PURE__ */ U("span", { children: c(e.size ?? 0) })
+ /* @__PURE__ */ W("span", { children: o[e.location] ?? e.location }),
+ /* @__PURE__ */ W("span", { children: s(e.duration) }),
+ /* @__PURE__ */ W("span", { children: c(e.size ?? 0) })
]
}),
- e.reason ? /* @__PURE__ */ U("p", { children: e.reason }) : null
+ e.reason ? /* @__PURE__ */ W("p", { children: e.reason }) : null
] })]
}, e.id))
- }) : /* @__PURE__ */ U("div", {
+ }) : /* @__PURE__ */ W("div", {
class: "qualitylist",
dangerouslySetInnerHTML: { __html: e("sparkles", "没有标记中的高清版目标", "现有版本都已满足条件,或还没有加入追踪。") }
});
}
//#endregion
//#region src/jobs.ts
-async function zt(e) {
+async function Bt(e) {
let t = e.pause || ((e) => new Promise((t) => setTimeout(t, e))), n = 0;
for (; e.active();) {
let r;
@@ -1335,11 +1360,11 @@ async function zt(e) {
await t(2e3);
}
}
-function Bt(e) {
+function Vt(e) {
let t = document.createElement("div");
e.host.hidden = !0, t.dataset.followJob = "", t.setAttribute("aria-live", "polite"), e.host.prepend(t);
let n = e.storageKey || "peach-follow-job", r = sessionStorage.getItem(n) || void 0, i = !1;
- zt({
+ Bt({
read: e.read,
active: () => !i && e.active() && t.isConnected,
keepWatching: e.watchIdle !== !1,
@@ -1365,10 +1390,10 @@ function Bt(e) {
}
//#endregion
//#region src/islands/scraping.tsx
-var Vt = (e, t) => I("/api/scraping", t);
-function Ht({ value: e, onChange: t }) {
- let n = H(null), i = H(t);
- return i.current = t, Fe(() => {
+var Ht = (e, t) => I("/api/scraping", t);
+function Ut({ value: e, onChange: t }) {
+ let n = U(null), i = U(t);
+ return i.current = t, H(() => {
let t = n.current;
t.innerHTML = r([
["environment", "系统代理"],
@@ -1379,17 +1404,17 @@ function Ht({ value: e, onChange: t }) {
return o.addEventListener("change", s), () => {
o.disabled = !0, o.removeEventListener("change", s), t.replaceChildren();
};
- }, []), /* @__PURE__ */ U("div", {
+ }, []), /* @__PURE__ */ W("div", {
ref: n,
class: "scraping-network"
});
}
-function Ut({ source: e, toast: r }) {
- 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(() => {
+function Wt({ source: e, toast: r }) {
+ 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 = U(null), E = U(null);
+ H(() => {
E.current?.querySelectorAll("footer button").forEach((e) => i(e, y));
}, [y]);
- let D = H(new AbortController());
+ let D = U(new AbortController());
Pe(() => () => D.current.abort(), []);
async function O(t) {
if (!y) {
@@ -1416,34 +1441,34 @@ function Ut({ source: e, toast: r }) {
}
}
}
- return /* @__PURE__ */ U("section", {
+ return /* @__PURE__ */ W("section", {
class: "scraping-source",
- children: /* @__PURE__ */ U("form", {
+ children: /* @__PURE__ */ W("form", {
ref: E,
class: "cleanupfieldset",
"data-geist-fieldset": !0,
onSubmit: (e) => {
e.preventDefault(), O("save");
},
- children: [/* @__PURE__ */ U("div", {
+ children: [/* @__PURE__ */ W("div", {
class: "geist-fieldset-content scraping-fields",
children: [
- /* @__PURE__ */ U("div", { dangerouslySetInnerHTML: { __html: t(`scraping-${e.source}`, e.label) } }),
- /* @__PURE__ */ U("a", {
+ /* @__PURE__ */ W("div", { dangerouslySetInnerHTML: { __html: t(`scraping-${e.source}`, e.label) } }),
+ /* @__PURE__ */ W("a", {
class: "scraping-url",
href: e.login,
target: "_blank",
rel: "noopener noreferrer",
children: e.login
}),
- /* @__PURE__ */ U("div", {
+ /* @__PURE__ */ W("div", {
class: "scraping-label",
- children: ["连接方式", /* @__PURE__ */ U(Ht, {
+ children: ["连接方式", /* @__PURE__ */ W(Ut, {
value: s,
onChange: c
})]
}),
- s === "proxy" && /* @__PURE__ */ U("label", { children: ["代理地址", /* @__PURE__ */ U("input", {
+ s === "proxy" && /* @__PURE__ */ W("label", { children: ["代理地址", /* @__PURE__ */ W("input", {
class: "geist-input",
type: "password",
autoComplete: "off",
@@ -1452,13 +1477,13 @@ function Ut({ source: e, toast: r }) {
disabled: y,
onInput: (e) => u(e.currentTarget.value)
})] }),
- e.accepts_cookie && /* @__PURE__ */ U(M, { children: [
- /* @__PURE__ */ U("p", { children: a.cookie_saved ? "Cookie 已保存,登录是否有效请在抓取时确认。" : "需要登录时,任选一种方式提供 Cookie。" }),
- /* @__PURE__ */ U("div", {
+ e.accepts_cookie && /* @__PURE__ */ W(M, { children: [
+ /* @__PURE__ */ W("p", { children: a.cookie_saved ? "Cookie 已保存,登录是否有效请在抓取时确认。" : "需要登录时,任选一种方式提供 Cookie。" }),
+ /* @__PURE__ */ W("div", {
class: "insightswitch scraping-cookie-method",
role: "radiogroup",
"aria-label": "提供 Cookie 的方式(二选一)",
- children: [["paste", "粘贴 Cookie"], ["file", "导入文件"]].map(([t, n]) => /* @__PURE__ */ U("label", { children: [/* @__PURE__ */ U("input", {
+ children: [["paste", "粘贴 Cookie"], ["file", "导入文件"]].map(([t, n]) => /* @__PURE__ */ W("label", { children: [/* @__PURE__ */ W("input", {
type: "radio",
name: `cookie-method-${e.source}`,
value: t,
@@ -1466,29 +1491,29 @@ function Ut({ source: e, toast: r }) {
onChange: () => {
g(t), f(""), m(""), v("");
}
- }), /* @__PURE__ */ U("span", { children: n })] }, t))
+ }), /* @__PURE__ */ W("span", { children: n })] }, t))
}),
- h === "paste" ? /* @__PURE__ */ U("label", { children: ["Cookie", /* @__PURE__ */ U("input", {
+ h === "paste" ? /* @__PURE__ */ W("label", { children: ["Cookie", /* @__PURE__ */ W("input", {
class: "geist-input",
type: "password",
autoComplete: "off",
value: d,
disabled: y,
onInput: (e) => f(e.currentTarget.value)
- })] }) : /* @__PURE__ */ U("label", {
+ })] }) : /* @__PURE__ */ W("label", {
class: "scraping-file",
- children: ["Netscape Cookie 文件(.txt)", /* @__PURE__ */ U("span", {
+ children: ["Netscape Cookie 文件(.txt)", /* @__PURE__ */ W("span", {
class: "scraping-file-control",
children: [
- /* @__PURE__ */ U("span", {
+ /* @__PURE__ */ W("span", {
class: "geist-button",
children: "选择文件"
}),
- /* @__PURE__ */ U("span", {
+ /* @__PURE__ */ W("span", {
class: "scraping-file-name",
children: _ || "未选择文件"
}),
- /* @__PURE__ */ U("input", {
+ /* @__PURE__ */ W("input", {
ref: T,
type: "file",
accept: ".txt",
@@ -1518,31 +1543,31 @@ function Ut({ source: e, toast: r }) {
})]
})
] }),
- x && /* @__PURE__ */ U("div", {
+ x && /* @__PURE__ */ W("div", {
role: "alert",
dangerouslySetInnerHTML: { __html: n(x, { variant: "error" }) }
}),
- C.map((t) => /* @__PURE__ */ U("div", {
+ C.map((t) => /* @__PURE__ */ W("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__ */ U("footer", {
+ }), /* @__PURE__ */ W("footer", {
class: "geist-fieldset-footer",
"data-geist-fieldset-footer": !0,
children: [
- /* @__PURE__ */ U("button", {
+ /* @__PURE__ */ W("button", {
class: "geist-button primary",
type: "submit",
children: "保存"
}),
- /* @__PURE__ */ U("button", {
+ /* @__PURE__ */ W("button", {
class: "geist-button",
type: "button",
onClick: () => void O("check"),
children: "检查连接"
}),
- e.accepts_cookie && a.cookie_saved && /* @__PURE__ */ U("button", {
+ e.accepts_cookie && a.cookie_saved && /* @__PURE__ */ W("button", {
class: "geist-button",
type: "button",
onClick: () => void O("revoke"),
@@ -1553,13 +1578,13 @@ function Ut({ source: e, toast: r }) {
})
});
}
-function Wt({ data: e, error: r, toast: a }) {
- 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);
+function Gt({ data: e, error: r, toast: a }) {
+ let [o, s] = V(""), [c, l] = V(!1), [u, d] = V(""), f = U(null);
+ H(() => i(f.current, c), [c]);
+ let p = U(new AbortController()), m = U(0);
async function h(e = !1) {
let t = ++m.current;
- await zt({
+ await Bt({
read: (e) => I("/api/scraping/cover", e),
active: () => !p.current.signal.aborted && t === m.current,
render: (t) => {
@@ -1579,26 +1604,26 @@ function Wt({ data: e, error: r, toast: a }) {
}
}
}
- return r ? /* @__PURE__ */ U("div", {
+ return r ? /* @__PURE__ */ W("div", {
role: "alert",
dangerouslySetInnerHTML: { __html: n(r, { variant: "error" }) }
- }) : /* @__PURE__ */ U("div", {
+ }) : /* @__PURE__ */ W("div", {
class: "scraping-page",
children: [
- /* @__PURE__ */ U("p", { children: "高清图片可能需要代理才能下载,请先检查连接。" }),
- /* @__PURE__ */ U("section", {
+ /* @__PURE__ */ W("p", { children: "高清图片可能需要代理才能下载,请先检查连接。" }),
+ /* @__PURE__ */ W("section", {
class: "cleanupfieldset scraping-source",
"data-geist-fieldset": !0,
- children: /* @__PURE__ */ U("div", {
+ children: /* @__PURE__ */ W("div", {
class: "geist-fieldset-content scraping-fields",
children: [
- /* @__PURE__ */ U("div", { dangerouslySetInnerHTML: { __html: t("scraping-cover", "高清封面") } }),
- /* @__PURE__ */ U("form", {
+ /* @__PURE__ */ W("div", { dangerouslySetInnerHTML: { __html: t("scraping-cover", "高清封面") } }),
+ /* @__PURE__ */ W("form", {
class: "scraping-cover-form",
onSubmit: (e) => {
e.preventDefault(), g();
},
- children: [/* @__PURE__ */ U("input", {
+ children: [/* @__PURE__ */ W("input", {
class: "geist-input",
"aria-label": "馆藏番号",
required: !0,
@@ -1606,21 +1631,21 @@ function Wt({ data: e, error: r, toast: a }) {
disabled: c,
placeholder: "输入馆藏番号,如 ABW-232",
onInput: (e) => s(e.currentTarget.value)
- }), /* @__PURE__ */ U("button", {
+ }), /* @__PURE__ */ W("button", {
ref: f,
class: "geist-button primary",
type: "submit",
children: "抓取封面"
})]
}),
- u && /* @__PURE__ */ U("div", {
+ u && /* @__PURE__ */ W("div", {
role: "alert",
dangerouslySetInnerHTML: { __html: n(u, { variant: "error" }) }
})
]
})
}),
- e?.sources.map((e) => /* @__PURE__ */ U(Ut, {
+ e?.sources.map((e) => /* @__PURE__ */ W(Wt, {
source: e,
toast: a
}, e.source))
@@ -1629,12 +1654,12 @@ function Wt({ data: e, error: r, toast: a }) {
}
//#endregion
//#region src/state/index.ts
-var Gt = { "quality-goals": {
- refresh: Ft,
- reset: Pt
-} }, Kt = () => Object.keys(Gt);
-async function qt(e) {
- let t = Gt[e];
+var Kt = { "quality-goals": {
+ refresh: It,
+ reset: Ft
+} }, qt = () => Object.keys(Kt);
+async function Jt(e) {
+ let t = Kt[e];
if (!t) throw Error(`未登记的共享 store:${String(e)}`);
try {
return await t.refresh(), !0;
@@ -1644,7 +1669,7 @@ async function qt(e) {
}
//#endregion
//#region src/sidebar.ts
-function Jt(e) {
+function Yt(e) {
return [
"/",
"/unseen",
@@ -1654,39 +1679,39 @@ function Jt(e) {
"/junk-files"
].includes(e) || /^\/(item|mix|parts|editions)\//.test(e) || /^\/playlists\/\d+\/\d+$/.test(e) || /^\/(performers|studios|creators|series|agencies)\/.+/.test(e);
}
-function Yt(e, t) {
+function Xt(e, t) {
return e.dataset.surface === t && e.querySelector(".dnav") ? !1 : (e.dataset.surface = t, e.replaceChildren(), !0);
}
-function Xt(e) {
+function Zt(e) {
let t = /* @__PURE__ */ new Map();
for (let n of e) for (let e of new Set(n.tags || [])) t.set(e, (t.get(e) || 0) + 1);
return [...t].sort((e, t) => t[1] - e[1]).slice(0, 30);
}
//#endregion
//#region src/islands.ts
-var Zt = {
+var Qt = {
scraping: {
- load: Vt,
- component: Wt
+ load: Ht,
+ component: Gt
},
"quality-goals": {
- load: It,
- component: Rt
+ load: Lt,
+ component: zt
},
configuration: {
- load: Je,
+ load: qe,
component: $e
}
-}, Qt = () => Object.keys(Zt), $t = /* @__PURE__ */ new Map();
-async function en(e, t, n, r = {}) {
- let i = Zt[e];
+}, $t = () => Object.keys(Qt), en = /* @__PURE__ */ new Map();
+async function tn(e, t, n, r = {}) {
+ let i = Qt[e];
if (!i) throw Error(`未注册的 island:${String(e)}`);
- tn(t);
+ nn(t);
let a = {
controller: new AbortController(),
painted: !1
};
- $t.set(t, a);
+ en.set(t, a);
let o;
try {
o = {
@@ -1700,9 +1725,9 @@ async function en(e, t, n, r = {}) {
error: F(e)
};
}
- if ($t.get(t) !== a) return;
+ if (en.get(t) !== a) return;
if (r.isCurrent && !r.isCurrent()) {
- $t.delete(t);
+ en.delete(t);
return;
}
t.textContent = "", a.painted = !0;
@@ -1712,9 +1737,9 @@ async function en(e, t, n, r = {}) {
};
ye(A(i.component, s), t);
}
-function tn(e) {
- let t = $t.get(e);
- t && (t.controller.abort(), $t.delete(e), t.painted && ye(null, e));
+function nn(e) {
+ let t = en.get(e);
+ t && (t.controller.abort(), en.delete(e), t.painted && ye(null, e));
}
//#endregion
-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 };
+export { Vt as followJobProgress, $t as islandNames, tn as mountIsland, Jt as refreshStore, Yt as sidebarHasCatalogContent, Zt as sidebarTagCounts, qt as storeNames, Xt as syncSidebarSurface, nn as unmountIsland, Bt as watchJob };
diff --git a/web/js/ui-components.js b/web/js/ui-components.js
index e160fcc76..ea0c1ec32 100644
--- a/web/js/ui-components.js
+++ b/web/js/ui-components.js
@@ -500,8 +500,9 @@ export function wireAnchoredMenu(mount,toggle,menu){
/* 下方放不下就改到上方;两侧都放不下时取宽的那一侧,并把菜单压到那一侧的高度,
内容在菜单内滚。不压高度的话它会横跨触发钮盖住自己,点开之后连改的是哪一个
名字都看不见。 */
- const downward=under>=menu.scrollHeight||under>=over;
- const height=Math.min(menu.scrollHeight,Math.max(downward?under:over,0));
+ const naturalHeight=menu.scrollHeight+menu.offsetHeight-menu.clientHeight;
+ const downward=under>=naturalHeight||under>=over;
+ const height=Math.min(naturalHeight,Math.max(downward?under:over,0));
menu.style.maxHeight=height+'px';
menu.style.left=Math.max(8,Math.min(anchor.right-width,innerWidth-width-8))+'px';
menu.style.top=(downward?anchor.bottom+8:anchor.top-8-height)+'px'};