Peach: Local-first video metadata scraper and media manager.
fix(settings): 维护页改用任务中心链接、读数过渡与 GitHub 发布页
longmeidao7733bf58136b
diff --git a/docs/JAV_BROWSER.md b/docs/JAV_BROWSER.mdindex eaabb02e3..cad6c7b0c 100644--- a/docs/JAV_BROWSER.md+++ b/docs/JAV_BROWSER.md@@ -22,7 +22,7 @@ CloudDrive2 分别返回提交云下载和管理离线任务的能力。支持4. 打开已登记站点,点击右下角「配置 Peach」或设置按钮,在「Peach 地址」中粘贴配对信息,自动填好地址与令牌,再保存设置。也可从脚本菜单「配置 Peach 地址与令牌」打开设置面板,分别填写地址和令牌。目标浏览器必须信任 Peach 的 HTTPS 证书;HTTP 只允许回环地址。5. 允许脚本管理器连接自己的 Peach 地址。远程设备填写该设备能访问的 Peach HTTPS 地址。-专用令牌仅允许查询作品添加状态、发起 JAV 添加和写入受限的脚本错误记录,网盘账号仍由 Peach 管理。点击「关闭浏览器添加」会撤销令牌并停止队列里尚未开始提交的添加;正在提交或已经提交的云下载从活动页查看和取消。+专用令牌仅允许查询作品添加状态、发起 JAV 添加和写入受限的脚本错误记录,网盘账号仍由 Peach 管理。点击「关闭浏览器添加」会撤销令牌并停止队列里尚未开始提交的添加;正在提交或已经提交的云下载从任务中心查看和取消。脚本从 GM 存储读取已保存配置,设置面板中令牌留空可保留,更换地址时须重新填写令牌。服务端只保存令牌哈希,不能读回明文。配对信息包含地址与专用令牌,应按令牌保管;导入仅填充表单,点击「保存设置」后生效。配置校验与选中番号的提示显示在页面内,浅色与暗色随系统切换。@@ -32,7 +32,7 @@ Peach 配置页通过同源桥接页检测脚本版本和是否已为当前地1. 打开影片详情页,点击「加入 Peach 馆藏」。2. 脚本用整体进度显示排队、搜索、下载、入库与整理五个阶段,完成阶段打勾、当前阶段高亮,并显示提交网盘、文件可访问等具体状态。网盘百分比仅属于下载阶段,其他阶段按真实状态推进。馆藏已有的影片显示「馆藏已有该番号影片」,按钮显示「已有该影片」。同一番号的进行中任务会复用。-3. 云下载提交后,在 Peach 活动页查看下载与入库后整理进度。+3. 云下载提交后,在 Peach 任务中心查看下载与入库后整理进度。搜索期间可以关闭源站页面,队列由 Peach 保存;Peach 重启后继续尚未完成的搜索。未找到资源和失败的添加,需要在原站点击「重试加入 Peach 馆藏」。网络超时只提供状态查询,确认服务器结果后再决定是否重试。@@ -70,7 +70,7 @@ DMM / FANZA 的 `/av/content/?id=…` 与旧版数字、DVD 详情路径,以| 令牌无效或无权限 | 在本机下载渠道更新令牌,并重新配置脚本;reader 不能接收添加 || 下载渠道未配置 | 保存网盘账号与目标目录后启用 || 未找到资源 | 在 Peach 云下载弹层手动查找或选择其他版本,之后可再次主动添加 |-| 云下载或入库失败 | 在 Peach 活动页查看具体原因,按现有云下载流程重试 |+| 云下载或入库失败 | 在 Peach 任务中心查看具体原因,按现有云下载流程重试 |来源地址保存页面协议、主机、路径及清单允许的作品标识参数,例如 JavLibrary 的 `v`、FANZA 的 `id`。其他查询参数、片段、Cookie 和网站播放器地址不提交给 Peach。直接播放外来在线来源属于后续功能,见[公开路线图](https://github.com/orgs/peach-mitao/projects/7)。diff --git a/frontend/src/react/components/animated-number.tsx b/frontend/src/react/components/animated-number.tsxnew file mode 100644index 000000000..c1d374706--- /dev/null+++ b/frontend/src/react/components/animated-number.tsx@@ -0,0 +1,32 @@+/* 会跟着轮询变的读数:新值到达时从旧值滚到新值,而不是一帧跳过去。+ *+ * 首次挂载直接画终值,只有值变了才过渡;过渡用 Motion 的 `animate` 逐帧写文字,+ * 系统开了减弱动态效果时直接画终值。数字一律等宽,滚动时整行不抖。 */+import { useEffect, useRef, useState } from 'react';+import { animate } from 'motion';+import { useReducedMotion } from 'motion/react';++/** 过渡时长,秒。短于各处最快的轮询间隔(1.5 秒),下一次新值到达前一定已经停稳。 */+const DURATION = 0.6;++export function AnimatedNumber(+ { value, format = (at) => Math.round(at).toLocaleString(), className }:+ { value: number; format?: (value: number) => string; className?: string },+) {+ const reduced = useReducedMotion();+ const [shown, setShown] = useState(value);+ const from = useRef(value);+ useEffect(() => {+ if (reduced || from.current === value) {+ from.current = value;+ setShown(value);+ return;+ }+ const controls = animate(from.current, value, {+ duration: DURATION, ease: 'easeOut',+ onUpdate: (at) => { from.current = at; setShown(at); },+ });+ return () => controls.stop();+ }, [value, reduced]);+ return <span className={className ? `tabular-nums ${className}` : 'tabular-nums'}>{format(shown)}</span>;+}diff --git a/frontend/src/react/settings/release-updates.tsx b/frontend/src/react/settings/release-updates.tsxindex b1a1715d7..d26bd963f 100644--- a/frontend/src/react/settings/release-updates.tsx+++ b/frontend/src/react/settings/release-updates.tsx@@ -17,6 +17,8 @@ import { busyProps, useAction } from './use-action';const ACTIVE = new Set(['downloading', 'verifying', 'extracting', 'preparing', 'restarting', 'installing']);const STOPS = [65, 75, 90];const MAX_FAILURES = 120;+/** 服务端没给发布页时的去处;检查到新版本后服务端给的是那一版自己的发布页。 */+const RELEASES_URL = 'https://github.com/peach-mitao/peach/releases';export function ReleaseUpdates({ initial, initialJob }: { initial: ReleaseState; initialJob?: UpdateJob | undefined }) {const [data, setData] = useState(initial);@@ -120,11 +122,8 @@ export function ReleaseUpdates({ initial, initialJob }: { initial: ReleaseState;</Stack>}<Footer status={<div className="flex flex-wrap items-center gap-3"><ExternalLink href="https://peach.video/#download">官网</ExternalLink>- <span className="inline-flex flex-wrap items-center gap-2">- <ExternalLink href="https://github.com/peach-mitao/peach">GitHub</ExternalLink>- <StatusLabel>暂无法更新</StatusLabel>- </span>- <ExternalLink href="https://gitgud.io/peach-mitao/peach/-/releases">查看发布页</ExternalLink>+ <ExternalLink href="https://github.com/peach-mitao/peach">GitHub</ExternalLink>+ <ExternalLink href={data.release_url || RELEASES_URL}>查看发布页</ExternalLink></div>}><Button variant={job.state === 'ready' || (data.state === 'available' && data.installation === '独立测试包') ? 'secondary' : 'primary'}disabled={running} onClick={check} {...busyProps(action.busy === 'check')}>检查更新</Button>diff --git a/frontend/src/react/settings/section.tsx b/frontend/src/react/settings/section.tsxindex 8b1c1bcbd..349dc6092 100644--- a/frontend/src/react/settings/section.tsx+++ b/frontend/src/react/settings/section.tsx@@ -5,7 +5,7 @@* 提示与进度条另有页面共用的一份,在 `../components/`。 */import { useId, useLayoutEffect, useRef, useState } from 'react';import type { ComponentType, FormEvent, MouseEvent, ReactNode } from 'react';-import { RiArrowRightSLine, RiExternalLinkLine } from '@remixicon/react';+import { RiArrowRightLine, RiArrowRightSLine, RiExternalLinkLine } from '@remixicon/react';import { setCollapseOpen } from '@peach/legacy/ui';import { SettingsCard, SettingsSectionLabel } from '@/components/application/settings/settings-rows';@@ -104,6 +104,15 @@ export function ExternalLink({ href, children, leadingIcon }: {);}+/** 后台任务的进度在任务中心看:说明句后面跟这一颗,点了站内跳过去。 */+export function TaskCenterLink() {+ return (+ <LinkButton href="/tasks" size="small" trailingIcon={RiArrowRightLine} className="self-start">+ 在任务中心查看进度+ </LinkButton>+ );+}+/** 只读的名目与读数,一行一对,行距与分隔线同 `SettingsRow`。 */export function FactList({ children }: { children: ReactNode }) {return <dl className="ui-settings-facts flex flex-col empty:hidden">{children}</dl>;diff --git a/frontend/src/react/settings/service-preferences.tsx b/frontend/src/react/settings/service-preferences.tsxindex ad4b70c41..739f6e85b 100644--- a/frontend/src/react/settings/service-preferences.tsx+++ b/frontend/src/react/settings/service-preferences.tsx@@ -19,7 +19,7 @@ import {fetchFollowSchedule, fetchSettings, fetchThumbnailJobs, schedulePollInterval, useRunSchedule,useSaveFollowSchedule, useSaveSettings, useSaveThumbnailMode, type FollowScheduleStatus,} from '../settings-panel/settings-data';-import { ErrorText, Help, Rows, Section, Stack } from './section';+import { ErrorText, Help, Rows, Section, Stack, TaskCenterLink } from './section';import { busyProps } from './use-action';const THUMBNAIL_OPTIONS = [['off', '关闭'], ['precise', '每 10 秒一张'], ['coarse', '每 30 秒一张']] as const;@@ -49,7 +49,10 @@ export function VideoThumbnailControls({ epoch = 0, disabled = false }: { epoch?</SettingsRow></Rows>{save.isPending || data?.status === 'running'- ? <Stack divided><Help role="status">{save.isPending ? '正在保存…' : '正在采集,进度在活动页查看。'}</Help></Stack>+ ? <Stack divided>+ <Help role="status">{save.isPending ? '正在保存…' : '正在采集。'}</Help>+ {save.isPending ? null : <TaskCenterLink />}+ </Stack>: null}{error ? <Stack divided><ErrorText>{errorMessage(error)}</ErrorText></Stack> : null}</>diff --git a/frontend/src/react/settings/upgrade-repairs.tsx b/frontend/src/react/settings/upgrade-repairs.tsxindex 39bd23927..2e6fd11f3 100644--- a/frontend/src/react/settings/upgrade-repairs.tsx+++ b/frontend/src/react/settings/upgrade-repairs.tsx@@ -4,8 +4,9 @@ import { Button } from '@/components/base/buttons/button';import { apiSend } from '../../api';import { useClientUpdates } from '../client-updates';import type { ClientUpdates } from '../client-updates';+import { AnimatedNumber } from '../components/animated-number';import { StatusLabel } from '../components/status-label';-import { ErrorText, ExternalLink, Fact, FactList, Footer, Help, Section, Stack } from './section';+import { ErrorText, ExternalLink, Fact, FactList, Footer, Help, Section, Stack, TaskCenterLink } from './section';import { useAction } from './use-action';const LABELS: Record<string, string> = { pending: '等待修复', running: '正在修复', failed: '需要重试',@@ -32,12 +33,12 @@ export function UpgradeRepairs() {data-copy-key={`upgradeRepairs.${state}.status`}>{LABELS[state] || '未取得'}</span></StatusLabel>}><Stack><Help>升级后自动修正资料、更新缓存。</Help></Stack><FactList>- <Fact term="待完成">{pending} 项</Fact>- <Fact term="失败">{failed} 项</Fact>- <Fact term="待复核">{review} 项</Fact>+ <Fact term="待完成"><span><AnimatedNumber value={pending} /> 项</span></Fact>+ <Fact term="失败"><span><AnimatedNumber value={failed} /> 项</span></Fact>+ <Fact term="待复核"><span><AnimatedNumber value={review} /> 项</span></Fact></FactList>{data?.message || action.error ? <Stack><ErrorText>{action.error || data?.message}</ErrorText></Stack> : null}- {state === 'running' ? <Stack><Help>资料与预览正在后台补全,可在活动页查看进度。</Help></Stack> : null}+ {state === 'running' ? <Stack><Help>资料与预览正在后台补全。</Help><TaskCenterLink /></Stack> : null}<Footer status={review ? <ExternalLink href="/api/configuration/upgrade-repairs/review">下载复核记录</ExternalLink> : undefined}><Button size="small" variant="secondary" disabled={!data?.available || state === 'running' || !!action.busy || (!failed && state !== 'failed')}onClick={retry}>重试失败项</Button>diff --git a/frontend/test/react/maintenance-settings.test.tsx b/frontend/test/react/maintenance-settings.test.tsxindex 4d0908d73..9afc4ea0a 100644--- a/frontend/test/react/maintenance-settings.test.tsx+++ b/frontend/test/react/maintenance-settings.test.tsx@@ -12,7 +12,7 @@ import { actionOrder, buttonNamed, choose, click, fetchMock, mount, section, senconst automatic = { mode: 'off', interval_hours: 24, available: true, download_available: true };const release: ReleaseState = {current_version: '0.9.0', latest_version: null, channel: '测试版', installation: '独立测试包',- state: 'unchecked', message: '尚未检查', release_url: 'https://github.com/longmeidao/peach/releases',+ state: 'unchecked', message: '尚未检查', release_url: 'https://github.com/peach-mitao/peach/releases',};const uninstall = { available: true, full_available: true, message: '', data_root: 'fixture', directories: ['fixture', 'fixture/cache'] };@@ -123,9 +123,9 @@ describe('检查更新', () => {.toEqual([['官网', 'https://peach.video/#download'],['GitHub', 'https://github.com/peach-mitao/peach'],- ['查看发布页', 'https://gitgud.io/peach-mitao/peach/-/releases'],+ ['查看发布页', 'https://github.com/peach-mitao/peach/releases'],]);- expect(updates.textContent).toContain('GitHub暂无法更新');+ expect(updates.textContent).not.toContain('暂无法更新');expect(document.activeElement).toBe(check);vi.stubGlobal('fetch', fetchMock(503, { detail: '连接失败' }));await click(check);diff --git a/src/peach/diagnostics.py b/src/peach/diagnostics.pyindex a5d14df7d..af05ebb9a 100644--- a/src/peach/diagnostics.py+++ b/src/peach/diagnostics.py@@ -170,7 +170,7 @@ def recent_failure(path):# 不公开任务 error、参数或结果原文,它们可能包含凭据和媒体路径。moment = str(row[1] or "")safe_time = moment if len(moment) <= 32 and all(c in "0123456789-:+.TZ " for c in moment) else None- return item("后台任务", "warning", "存在已记录的任务失败", action="在活动页查看失败任务",+ return item("后台任务", "warning", "存在已记录的任务失败", action="在任务中心查看失败任务",target="/tasks", details={"id": row[0], "finished_at": safe_time})