Peach: Local-first video metadata scraper and media manager.
chore(test): 精简重复断言并启用前端基础 lint
longmeidao3976dd0c4b7f
diff --git a/docs/FRONTEND.md b/docs/FRONTEND.mdindex f0150407d..43d77146c 100644--- a/docs/FRONTEND.md+++ b/docs/FRONTEND.md@@ -197,7 +197,7 @@ CI 由 `web-e2e` job 在 `windows-latest` 上执行 `web` 域,矩阵扩成全React 子树读到 BoardUI 的 token 原值、持久警示是状态色块、一张卡底下只有写入那一颗是主按钮。页面迁到 React 时,旧的源码字符串断言按 ADR-0031分三类再删:设计决定进这里或 lint,行为进 vitest,布局与运行期进冒烟。-`npm --prefix frontend run lint` 检查 `src/react/` 的设计系统规则,`web` 域与 CI 都跑。`no-restyle` 报在+`npm --prefix frontend run lint` 检查 `src/`、`test/`、`e2e/` 的 correctness 规则、严格相等比较和累积展开;`== null` 保留同时匹配 null 与 undefined 的语义。设计系统规则只作用于 `src/react/`,排除 BoardUI 与 EvilCharts 的上游副本。`web` 域与 CI 都跑。`no-restyle` 报在BoardUI 组件上的间距或外观,处理办法是在组件外面套一层普通元素,不给规则加例外。`src/react/boardui/` 只加不改,`UPSTREAM.sha256` 记着复制时每个文件的哈希,由 `tests/test_frontend_build.py` 比对。@@ -426,7 +426,7 @@ vendor 到 `web/vendor/` 的四个包(video.js、swiper、lucide-static、heal| `vitest` | 前端测试运行器。与 Vite 共用同一份配置解析,不必再维护第二套转译 || `happy-dom` | vitest 的 DOM 环境。断言的是真实 DOM 结构,比 jsdom 轻且启动快 || `playwright-core` | `frontend/e2e/` 的浏览器驱动,只驱动本机 Chrome、不下载浏览器。happy-dom 没有布局,横向溢出、等待态卡住这类事实只有真浏览器测得出;不用 `@playwright/test`,用例跑在 `node:test` 上,与 docu.md(`markdown-viewer/markdown-viewer-extension` 的 `test/helpers/browser-render-harness.ts`)同一做法 |-| `oxlint`、`@shadcn/lint` | `npm run lint`:Oxlint 加载 `@shadcn/lint` 的六条规则,只查 `src/react/`、排除 `boardui/`。不用 ESLint,因为 `@typescript-eslint/parser` 的 peer 只到 TypeScript 6.0;`eslint` 作为 `@shadcn/lint` 的 peer 会装进来,不调用 |+| `oxlint`、`@shadcn/lint` | `npm run lint`:Oxlint 原生规则覆盖源码与测试,六条 shadcn 设计规则检查自有 React 源码。使用 TypeScript 与 Oxc 插件;规则集见 `.oxlintrc.json`。`eslint` 作为 `@shadcn/lint` 的 peer 安装,不作为检查入口 || `react`、`react-dom` | 前端唯一的渲染层。BoardUI 源码是 React 组件,交互建在 React Aria 上;不经兼容层运行它(ADR-0031)。`react-dom` 的 `flushSync` 还负责配置页那一帧:壳挂完紧接着就读 DOM || `react-aria-components` | BoardUI 输入框、勾选框、开关、下拉与弹出面板的交互和无障碍语义:标签关联、键盘操作、焦点进出、`aria-invalid` || `react-aria` | 只用 `UNSAFE_PortalProvider`:把 Popover 与下拉列表挂进 `body` 末尾同样带 `.peach-react` 的容器,弹层读到与页面内一致的 token 与 Preflight |diff --git a/docs/REUSE.md b/docs/REUSE.mdindex 6cb554a54..fc9bb6121 100644--- a/docs/REUSE.md+++ b/docs/REUSE.md@@ -286,6 +286,12 @@ JAV 默认封面(官方封面/预览图)与视频默认大小(大图/Python、npm 与 GitHub Actions 的版本由 `.github/dependabot.yml` 每周检查;固定前端文件由`package-lock.json` 和 `scripts/vendor_web_dependencies.mjs` 重建并核对来源、许可证与 SHA-256。+## 前端静态检查++复用现有 Oxlint 1.85.0 的 correctness、`eqeqeq` 与 `oxc/no-accumulating-spread`,不新增依赖。源码和测试共用基础规则;shadcn 设计规则仅作用于自有 React 源码。++评估过 MIT 许可的 [anti-slop](https://github.com/dmmulroy/anti-slop/tree/c44ef22ca116d0ba62a3ff663a0bd13a3f3fa40b)。固定提交的试跑中,8,243 条诊断里 7,274 条要求空行;其禁止 `unknown`、运行时 `typeof` 和模块 mock 的规则不适合本项目的输入校验与测试替身,因此不引入整套插件。类型安全由 TypeScript、基础 lint 与对应行为回归共同检查。+## 已删除旧实现与当前继任者找不到某个旧脚本时先查这张表:它的能力通常已经并进右边的实现,不要照旧名重写一份。diff --git a/frontend/.oxlintrc.json b/frontend/.oxlintrc.jsonindex 380e7db00..7a41e2d91 100644--- a/frontend/.oxlintrc.json+++ b/frontend/.oxlintrc.json@@ -1,8 +1,9 @@{"$schema": "./node_modules/oxlint/configuration_schema.json","categories": {- "correctness": "off"+ "correctness": "error"},+ "plugins": ["typescript", "oxc"],"jsPlugins": ["@shadcn/lint"],"ignorePatterns": ["src/react/boardui/**", "src/react/evilcharts/**"],"settings": {@@ -12,16 +13,23 @@}},"rules": {- "shadcn/no-restyle": ["error", { "allow": ["layout"] }],- "shadcn/no-raw-colors": ["error", {- "allow": ["text-body-*", "text-caption-*", "text-display-*", "text-headline-*", "text-large-title-*",- "text-title-*", "shadow-dropdown"]- }],- "shadcn/no-arbitrary-values": "error",- "shadcn/no-inline-styles": "error",- "shadcn/no-unknown-classes": ["error", { "allow": ["configpage", "configgroup", "swiper", "swiper-wrapper", "swiper-slide", "swiper-zoom-container",- "mono", "javedition", "censored", "chip", "geist-button",- "primary", "popmenu", "geist-input"] }],- "shadcn/require-static-classes": "error"- }+ "eqeqeq": ["error", "always", { "null": "ignore" }],+ "oxc/no-accumulating-spread": "error"+ },+ "overrides": [{+ "files": ["src/react/**/*"],+ "rules": {+ "shadcn/no-restyle": ["error", { "allow": ["layout"] }],+ "shadcn/no-raw-colors": ["error", {+ "allow": ["text-body-*", "text-caption-*", "text-display-*", "text-headline-*", "text-large-title-*",+ "text-title-*", "shadow-dropdown"]+ }],+ "shadcn/no-arbitrary-values": "error",+ "shadcn/no-inline-styles": "error",+ "shadcn/no-unknown-classes": ["error", { "allow": ["configpage", "configgroup", "swiper", "swiper-wrapper", "swiper-slide", "swiper-zoom-container",+ "mono", "javedition", "censored", "chip", "geist-button",+ "primary", "popmenu", "geist-input"] }],+ "shadcn/require-static-classes": "error"+ }+ }]}diff --git a/frontend/e2e/design.test.ts b/frontend/e2e/design.test.tsindex 024757019..a82c7a881 100644--- a/frontend/e2e/design.test.ts+++ b/frontend/e2e/design.test.ts@@ -4350,13 +4350,43 @@ describe('设计决定', () => {}});- it('亮暗卡片、按钮与回执使用克制的接触阴影', { timeout: 60_000 }, async () => {+ it('亮暗按钮保持尺寸与悬停面色,卡片和回执保持接触阴影', { timeout: 60_000 }, async () => {const opened = await visit(browser, '/stats', DESKTOP);try {// 选中的那张页签按基线收掉接触阴影,读旁边没选中的一张。const card = opened.page.locator('#main [class~="shadow-card"]:not([data-selected])').first();await card.waitFor({ timeout: 15_000 });await settle(opened.page);+ const checkSecondaryButton = async () => {+ await opened.page.mouse.move(0, 0);+ const dimensions = await opened.page.evaluate(() => {+ const holder = document.createElement('div');+ holder.style.cssText = 'position:fixed;right:16px;bottom:16px;z-index:10000';+ const button = document.createElement('button');+ button.className = 'geist-button';+ button.dataset.buttonProbe = '';+ button.textContent = '操作';+ holder.append(button);+ document.body.append(holder);+ const style = getComputedStyle(button);+ return [style.boxSizing, style.height, style.paddingTop, style.paddingRight,+ style.borderTopWidth, style.display];+ });+ assert.deepEqual(dimensions, ['border-box', '36px', '8px', '12px', '1px', 'inline-flex']);+ const button = opened.page.locator('[data-button-probe]');+ try {+ const idle = await button.evaluate(element => getComputedStyle(element).backgroundColor);+ assert.equal(idle, await tokenColor(opened.page, 'body', '--color-background-primary-default'));+ const border = await button.evaluate(element => getComputedStyle(element).borderTopColor);+ await button.hover();+ await settle(opened.page);+ const hovered = await button.evaluate(element => getComputedStyle(element).backgroundColor);+ assert.equal(hovered, await tokenColor(opened.page, 'body', '--control-hover'));+ assert.equal(await button.evaluate(element => getComputedStyle(element).borderTopColor), border);+ } finally {+ await button.evaluate(element => element.parentElement!.remove());+ }+ };/* Tailwind 把阴影 token 的字面值抄进工具类,`.dark` 里改 `--shadow-*` 够不着它;旧样式表里写死的浅色阴影同样不跟主题走。读三类来源各一处的计算值。 */const alphas = () => opened.page.evaluate(() => {@@ -4384,12 +4414,14 @@ describe('设计决定', () => {document.documentElement.classList.remove('dark');});const light = await alphas();+ await checkSecondaryButton();// `web/app.js` 的 `applyTheme('dark')` 就是这两句;这里只借它换一次配色。await opened.page.evaluate(() => {document.documentElement.dataset.theme = 'dark';document.documentElement.classList.add('dark');});const dark = await alphas();+ await checkSecondaryButton();for (const key of Object.keys(light) as Array<keyof typeof light>) {assert.ok(light[key] > 0 && light[key] < .2, `浅色下 ${key} 的阴影 ${light[key]} 不在浅色那一档`);assert.ok(dark[key] > light[key] && dark[key] <= .2,diff --git a/frontend/package.json b/frontend/package.jsonindex 49c13277c..2b227d3b0 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -11,7 +11,7 @@"build": "vite build && vite build -c vite.react.config.ts","build:agentation": "vite build -c vite.agentation.config.ts","typecheck": "tsc --noEmit && tsc --noEmit -p src/react",- "lint": "oxlint -c .oxlintrc.json src/react",+ "lint": "oxlint -c .oxlintrc.json src test e2e","test": "vitest run","test:watch": "vitest","e2e": "node --test --test-concurrency=1 --test-reporter=tap \"e2e/**/*.test.ts\""diff --git a/frontend/src/react/entity-page/entity-page.ts b/frontend/src/react/entity-page/entity-page.tsindex 97ca36a18..b95143235 100644--- a/frontend/src/react/entity-page/entity-page.ts+++ b/frontend/src/react/entity-page/entity-page.ts@@ -10,7 +10,7 @@* 骨架与整页一次换掉;页内换筛选时作品区的骨架归正文那一格自己(`useSkeletonReveal`)。 */import { api } from '@peach/legacy/core';-import type { CatalogGridProps, MediaItem, MediaPage } from '../catalog-grid/types';+import type { CatalogGridProps, MediaPage } from '../catalog-grid/types';import type { EntityBodyActions, EntityBodyHelpers, EntityCodeSet, EntityLocalPhoto, PhotoLayout, PhotoSize } from '../entity-body/entity-body';import type { EntityComboItem, EntitySortKey, SegmentOption } from '../entity-filter/entity-filter';import type { EntityHeroData, HeroCostar } from '../entity-hero/entity-hero';diff --git a/frontend/src/react/follow-detail/follow-detail-page.tsx b/frontend/src/react/follow-detail/follow-detail-page.tsxindex bef602ed9..ce7abff2d 100644--- a/frontend/src/react/follow-detail/follow-detail-page.tsx+++ b/frontend/src/react/follow-detail/follow-detail-page.tsx@@ -115,7 +115,7 @@ function Detail({ data, context, mediaIndex, onMedia, mediaView, helpers, action/* ── 媒体区 ── */-function MediaFrame({ item, media, helpers, actions, onMedia, issues }: {+function MediaFrame({ item, media, actions, onMedia, issues }: {item: FollowDetailItem; media: DetailMedia; helpers: FollowFeedHelpers; actions: FollowDetailActions;onMedia(index: number | null): void; issues: MediaIssues;}) {diff --git a/frontend/src/react/follow-feed/follow-feed-page.tsx b/frontend/src/react/follow-feed/follow-feed-page.tsxindex 8d05e9155..0c309359d 100644--- a/frontend/src/react/follow-feed/follow-feed-page.tsx+++ b/frontend/src/react/follow-feed/follow-feed-page.tsx@@ -96,7 +96,7 @@ function useFacets(data: FollowPage | null, view: FollowView, seed: number) {type Facets = ReturnType<typeof useFacets>;export function FollowFeedPage(props: FollowFeedProps) {- const { view, seed, revision, helpers, actions } = props;+ const { view, seed, revision, actions } = props;const query = followFeedQuery(view, revision);const result = useInfiniteQuery(query);const credentialsResult = useQuery({diff --git a/frontend/src/react/index/index-page.tsx b/frontend/src/react/index/index-page.tsxindex 09c51d6bd..28c286a65 100644--- a/frontend/src/react/index/index-page.tsx+++ b/frontend/src/react/index/index-page.tsx@@ -26,7 +26,7 @@ import type { OnlineAuthor, OnlineTag } from '../follow/online-vocab';import {INDEX_TITLES, ONLINE_TAG_CATEGORIES, TAG_CATEGORIES, countText, flatItems, indexQuery, indexRoute, indexSource, isCompany,isPeople, tagGroups, type IndexKind, type IndexPage as Page, type IndexPerson, type IndexProps,- type IndexRoute, type IndexScope, type IndexTag, type PeopleLayout, type TagView,+ type IndexRoute, type IndexScope, type IndexTag, type PeopleLayout,} from './index-data';import { OnlineAuthors, PeopleGrid } from './index-people';import { TagAlphabet, TagCloud, TagDock, TagFilters, type TagEntry } from './index-tags';diff --git a/frontend/src/react/item-detail/item-detail-page.tsx b/frontend/src/react/item-detail/item-detail-page.tsxindex afe87b9b0..e70d62c5d 100644--- a/frontend/src/react/item-detail/item-detail-page.tsx+++ b/frontend/src/react/item-detail/item-detail-page.tsx@@ -9,7 +9,7 @@* 把服务端回的那几个字段换进 `['item', id]`,目录网格缓存里的同一张卡一起换,不重读列表。 */import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type KeyboardEvent, type ReactNode } from 'react';import { useMutation, useQuery } from '@tanstack/react-query';-import { esc, fmtDur, fmtSize, icon, requestErrorMessage } from '@peach/legacy/core';+import { fmtDur, fmtSize, icon, requestErrorMessage } from '@peach/legacy/core';import {coverUrl, entityFaceImg, logoUrl, mixLabel, performerLabel, queueAvatarHtml, queueThumbHtml,} from '@peach/card-art';@@ -30,7 +30,7 @@ import {queueCopy, queueKey, ratingStars, ratingText, realWatched, recentTags, relatedKey, rememberTag, sameOrder,withPartLabel, withTag, withoutTag,type DetailEntityRef, type DetailItem, type DetailQueue, type DetailTag, type ItemDetailActions,- type ItemDetailHelpers, type ItemDetailProps, type MediaGate, type PlaylistPayload, type QueueItem, type TagCount,+ type ItemDetailHelpers, type ItemDetailProps, type MediaGate, type PlaylistPayload, type TagCount,} from './item-detail';/** 字形原样取壳那一份 `icon()`:骨架与遗留详情画的就是它,换成别的字形接管那一拍会跳。 */@@ -455,7 +455,7 @@ function Rating({ item, write }: { item: DetailItem; write: DetailWrite }) {/* 身份按类别分组:标签作为组标题写在上方,同类横向排开。逐行一个名字在共演作品上会把整个侧栏撑满。一个都没有时,「未归属」就是这条作品所属的那一类,和女优、厂牌并列:点进去看得到全部。 */-function Identity({ item, helpers, actions }: { item: DetailItem; helpers: ItemDetailHelpers; actions: ItemDetailActions }) {+function Identity({ item, actions }: { item: DetailItem; helpers: ItemDetailHelpers; actions: ItemDetailActions }) {const groups = useMemo(() => identityGroups(item), [item]);const [castOpen, setCastOpen] = useState(false);const overflow = Math.max(0, groups.cast.length - CAST_SHOWN);diff --git a/frontend/src/react/taste/taste-page.tsx b/frontend/src/react/taste/taste-page.tsxindex 6ed9aa71d..eae2a1826 100644--- a/frontend/src/react/taste/taste-page.tsx+++ b/frontend/src/react/taste/taste-page.tsx@@ -16,8 +16,8 @@ import { useRef, useState } from 'react';import type { ChangeEvent } from 'react';import {RiArrowDownSLine, RiArrowRightSLine, RiCompassLine, RiDatabase2Line, RiDeleteBinLine,- RiEyeLine, RiGlobalLine, RiHistoryLine, RiPriceTag3Line, RiSearchLine, RiThumbDownLine,- RiThumbUpLine, RiUploadLine, RiUserLine,+ RiEyeLine, RiHistoryLine, RiPriceTag3Line, RiSearchLine, RiThumbDownLine,+ RiThumbUpLine, RiUploadLine,} from '@remixicon/react';import { keepPreviousData, useMutation, useQuery } from '@tanstack/react-query';import { Popover, Tab, TabPanel, Tabs } from 'react-aria-components';diff --git a/frontend/test/react/taste.test.tsx b/frontend/test/react/taste.test.tsxindex 2f6f055af..b113a61fa 100644--- a/frontend/test/react/taste.test.tsx+++ b/frontend/test/react/taste.test.tsx@@ -20,7 +20,7 @@ import {import { TasteRadar } from '../../src/react/taste/charts';import { TastePage } from '../../src/react/taste/taste-page';-import { buttonNamed, choose, click, mount, mountRoot, settle } from './render';+import { choose, click, mount, mountRoot, settle } from './render';// 客户端是模块级的单例(所有 React 根共用一个),用例之间不清就互相喂数据。afterEach(() => queryClient.clear());diff --git a/tests/test_complexity_ratchet.py b/tests/test_complexity_ratchet.pyindex cb68d1f9a..8ae3f0e08 100644--- a/tests/test_complexity_ratchet.py+++ b/tests/test_complexity_ratchet.py@@ -24,6 +24,7 @@import astimport pathlibimport unittest+from types import MappingProxyTypeimport peach@@ -134,6 +135,10 @@ def recorded() -> dict[str, int]:class ComplexityRatchetTests(unittest.TestCase):+ @classmethod+ def setUpClass(cls):+ cls.current = MappingProxyType(survey())+def test_the_counter_counts_the_shapes_it_names(self):source = ("def f(items):\n"@@ -150,7 +155,7 @@ class ComplexityRatchetTests(unittest.TestCase):self.assertEqual(complexity(node), 8)def test_no_function_grew_past_its_recorded_count(self):- current, limits = survey(), recorded()+ current, limits = self.current, recorded()grown = sorted(f"{key}: {value}(记录 {limits.get(key, LIMIT - 1)})"for key, value in current.items()@@ -161,7 +166,7 @@ class ComplexityRatchetTests(unittest.TestCase):"都不算拆:\n " + "\n ".join(grown))def test_the_recorded_counts_match_the_code(self):- current = survey()+ current = self.currentstale = sorted(f"{key}: 现在 {current.get(key, '不存在')},记录 {value}"for key, value in recorded().items()diff --git a/tests/test_frontend_build.py b/tests/test_frontend_build.pyindex bc89473cc..67bba6100 100644--- a/tests/test_frontend_build.py+++ b/tests/test_frontend_build.py@@ -454,11 +454,6 @@ class StatsEndpointTests(unittest.TestCase):for helper in ("fmtSize(", "LOC["):self.assertIn(helper, self.source)- def test_the_four_readings_are_the_tabs(self):- """四张读数卡本身就是页签:这一页没有别的主动作,读数就是入口。"""- self.assertIn("react-aria-components", self.source)- self.assertEqual(self.source.count("<MetricTab"), 4)-def test_the_endpoint_is_declared_once(self):"""端点在前端只能有一个声明处,就是这一页的数据模块。"""sources = sorted(path for path in (FRONTEND / "src").rglob("*.ts*"))@@ -759,7 +754,7 @@ class VitestTests(unittest.TestCase):config = (FRONTEND / "vitest.config.ts").read_text(encoding="utf-8")self.assertIn("maxWorkers: 4", config)- def test_the_react_sources_follow_the_design_system_lint(self):+ def test_frontend_sources_and_tests_pass_lint(self):"""`@shadcn/lint` 挡住裸色值、任意值、内联样式和在 BoardUI 组件上改样式(ADR-0031)。"""npm = self._npm("lint", "oxlint")completed = subprocess.run(diff --git a/tests/test_performer_portrait_audit.py b/tests/test_performer_portrait_audit.pyindex 12e7ab70c..ee0687980 100644--- a/tests/test_performer_portrait_audit.py+++ b/tests/test_performer_portrait_audit.py@@ -563,9 +563,9 @@ class PerformerPortraitAuditTests(unittest.TestCase):def test_csv_replace_failure_preserves_the_previous_resume_file(self):previous = "existing resume data\n"self.out.write_text(previous, encoding="utf-8")- # 原子替换本身收进了 peach.review_csv,patch 目标要跟着代码走;这里仍然验的是- # 这个脚本的 write_csv 端到端行为:替换失败时替换前那份续跑文件必须原样保留。- with mock.patch("peach.review_csv.os.replace", side_effect=OSError("locked")):+ # 时钟跨过重试期限;真实写入与失败清理仍由 write_csv 执行。+ with mock.patch("peach.fsutil.os.replace", side_effect=OSError("locked")), \+ mock.patch("peach.fsutil.time.monotonic", side_effect=[0.0, 11.0]):with self.assertRaisesRegex(OSError, "locked"):self.module.write_csv(self.out, [{"section": "missing"}])self.assertEqual(self.out.read_text(encoding="utf-8"), previous)diff --git a/tests/test_source_assertion_ratchet.py b/tests/test_source_assertion_ratchet.pyindex 7284178f2..dbefa54d4 100644--- a/tests/test_source_assertion_ratchet.py+++ b/tests/test_source_assertion_ratchet.py@@ -26,6 +26,7 @@import astimport pathlibimport unittest+from types import MappingProxyTypeTESTS = pathlib.Path(__file__).resolve().parent@@ -40,7 +41,7 @@ BASELINE: dict[str, int] = {"test_fastapi_api.py": 4,"test_follow_assets.py": 1,"test_follow_web.py": 122,- "test_frontend_build.py": 77,+ "test_frontend_build.py": 76,"test_job_status.py": 3,"test_metadata_library.py": 7,"test_repo_hygiene.py": 2,@@ -53,7 +54,7 @@ BASELINE: dict[str, int] = {"test_web_e2e.py": 2,"test_web_js.py": 1,"test_web_settings.py": 5,- "test_web_ui.py": 2103,+ "test_web_ui.py": 2101,"test_windows_update.py": 3,}@@ -228,6 +229,10 @@ def survey() -> dict[str, int]:class SourceAssertionRatchetTests(unittest.TestCase):+ @classmethod+ def setUpClass(cls):+ cls.current = MappingProxyType(survey())+def test_the_counter_tells_repository_text_from_runtime_output(self):source = ("import pathlib, unittest\n"@@ -260,13 +265,13 @@ class SourceAssertionRatchetTests(unittest.TestCase):def test_no_test_file_grew_past_its_baseline(self):grown = sorted(f"{name}: {count}(基线 {BASELINE.get(name, 0)})"- for name, count in survey().items() if count > BASELINE.get(name, 0))+ for name, count in self.current.items() if count > BASELINE.get(name, 0))self.assertEqual(grown, [],"这些测试文件的源码文本断言多了。别改写成别的断言绕过,按本文件开头的""去向换成行为验收:\n " + "\n ".join(grown))def test_the_baseline_only_ratchets_down(self):- current = survey()+ current = self.currentstale = sorted(f"{name}: 现在 {current.get(name, 0)},基线 {value}"for name, value in BASELINE.items() if current.get(name, 0) < value)self.assertEqual(stale, [],diff --git a/tests/test_studio_site_harvest.py b/tests/test_studio_site_harvest.pyindex f577f6c65..5fd621a0b 100644--- a/tests/test_studio_site_harvest.py+++ b/tests/test_studio_site_harvest.py@@ -518,14 +518,6 @@ class ConfirmedSiteTests(unittest.TestCase):verdict, _ = self.module.site_verdict("えむっ娘ラボ", 200, page(title), title, url)self.assertEqual(verdict, "ok")- def test_studios_outside_the_whitelist_are_judged_exactly_as_before(self):- """白名单只影响列出来的那几行。少了这条,「加一行确认」就等于放宽了通用判据。"""- title = "Bazooka Bass Tubes"- verdict, _ = self.module.site_verdict(- "BAZOOKA", 200, page(title, "car audio subwoofers. "), title,- "https://bazooka.com/", derived_hosts=frozenset({"bazooka.com"}))- self.assertEqual(verdict, "weak")-class PlatformEntityTests(unittest.TestCase):"""发行平台不是厂牌,「厂牌官网」这条路对它们本来就不成立。"""diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex 87542cd1a..a49a8dc10 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -549,10 +549,7 @@ class WebUiSourceTests(unittest.TestCase):"""css = stylesheet_source()secondary_hover = "background:color-mix(in srgb,var(--ink) 8%,var(--ground))"- self.assertCode(".geist-button{box-sizing:border-box;height:32px;padding:0 14px;"- "border:0;border-radius:var(--control-radius);"- "background:var(--ground);color:var(--ink);display:inline-flex;")- self.assertPageContains(f".geist-button:hover:not(:disabled){{{secondary_hover}}}")+ # 尺寸、面色与悬停由 design.test.ts 在完整样式表加载后读取计算值。# 强调档那一面只有 `board.css` 一处(`test_the_primary_tier_has_one_face_and_crossfades_into_its_hover`)。# 这一层再写一份的话,它的 `:hover:not(:disabled)` 比 Board 那条静止规则重一个类,# 同一颗按钮的静止和悬停就分别由两处给出。diff --git a/web/dist/peach-react.js b/web/dist/peach-react.jsindex 421e08edc..b2666993b 100644--- a/web/dist/peach-react.js+++ b/web/dist/peach-react.js@@ -34137,42 +34137,42 @@ function cle(e, t, n) {]);}function lle(e) {- let { view: t, seed: n, revision: r, helpers: i, actions: a } = e, o = fO(t, r), s = Ln(o), c = Cn({+ let { view: t, seed: n, revision: r, actions: i } = e, a = fO(t, r), o = Ln(a), s = Cn({queryKey: pO,queryFn: ({ signal: e }) => mO(e)- }), l = (0, V.useMemo)(() => hO(s.data), [s.data]), u = (0, V.useMemo)(() => new Set((c.data?.providers || []).filter((e) => e.present).map((e) => e.provider)), [c.data]), d = (0, V.useMemo)(() => ({- sources: l?.sources || [],- aliases: l?.author_aliases || [],- credentials: u- }), [l, u]), f = cle(l, t, n), p = s.isPending || s.isPlaceholderData, h = !p && !!l, g = (0, V.useMemo)(() => Qce(f.visible.flatMap(_O).map((e) => ({ tags: e.tags || [] }))), [f.visible]);+ }), c = (0, V.useMemo)(() => hO(o.data), [o.data]), l = (0, V.useMemo)(() => new Set((s.data?.providers || []).filter((e) => e.present).map((e) => e.provider)), [s.data]), u = (0, V.useMemo)(() => ({+ sources: c?.sources || [],+ aliases: c?.author_aliases || [],+ credentials: l+ }), [c, l]), d = cle(c, t, n), f = o.isPending || o.isPlaceholderData, p = !f && !!c, h = (0, V.useMemo)(() => Qce(d.visible.flatMap(_O).map((e) => ({ tags: e.tags || [] }))), [d.visible]);(0, V.useEffect)(() => {- h && a.loaded(g);+ p && i.loaded(h);}, [+ p,h,- g,- a+ i]);- let _ = ule(e, !!l);- if (!l) return s.isError ? /* @__PURE__ */ (0, H.jsx)(Vn, {- message: m(s.error),- onRetry: () => void s.refetch()+ let g = ule(e, !!c);+ if (!c) return o.isError ? /* @__PURE__ */ (0, H.jsx)(Vn, {+ message: m(o.error),+ onRetry: () => void o.refetch()}) : null;- let v = (e) => a.route({+ let _ = (e) => i.route({...t,...e- }), y = qce({+ }), v = qce({...t,- author: f.author,- provider: f.provider+ author: d.author,+ provider: d.provider}, {- authors: new Map([...f.authorSources].map(([e, t]) => [e, kO(t, d)])),- providers: f.providers,- works: f.workNames- }), b = t.status ? f.counts[t.status] || 0 : f.allCount, x = f.sources.some((e) => e.can_backfill);+ authors: new Map([...d.authorSources].map(([e, t]) => [e, kO(t, u)])),+ providers: d.providers,+ works: d.workNames+ }), y = t.status ? d.counts[t.status] || 0 : d.allCount, b = d.sources.some((e) => e.can_backfill);return /* @__PURE__ */ (0, H.jsxs)(H.Fragment, { children: [/* @__PURE__ */ (0, H.jsx)("div", {- ref: _.host,+ ref: g.host,"data-follow-progress": ""- }, _.generation), /* @__PURE__ */ (0, H.jsxs)("div", {+ }, g.generation), /* @__PURE__ */ (0, H.jsxs)("div", {"data-follow-feed": "","data-select-mode": e.selectMode ? "" : void 0,children: [@@ -34187,15 +34187,15 @@ function lle(e) {variant: "secondary",leadingIcon: VO,"data-follow-manage": "",- onClick: a.openManage,+ onClick: i.openManage,children: "管理关注"- }), f.sources.length ? /* @__PURE__ */ (0, H.jsx)(J, {+ }), d.sources.length ? /* @__PURE__ */ (0, H.jsx)(J, {variant: "primary","data-follow-recheck": "","aria-label": "检查每个来源的更新",- "aria-busy": _.busy || void 0,- onClick: () => void _.start(!1),- children: _.starting === "check" ? /* @__PURE__ */ (0, H.jsx)("span", {+ "aria-busy": g.busy || void 0,+ onClick: () => void g.start(!1),+ children: g.starting === "check" ? /* @__PURE__ */ (0, H.jsx)("span", {className: "contents",dangerouslySetInnerHTML: { __html: Ne("检查中") }}) : "检查更新"@@ -34203,74 +34203,74 @@ function lle(e) {})]}),/* @__PURE__ */ (0, H.jsx)(dle, {- facets: f,- pressed: f.author,- context: d,+ facets: d,+ pressed: d.author,+ context: u,props: e,- onPick: (e) => v({ author: f.author === e ? "" : e })+ onPick: (e) => _({ author: d.author === e ? "" : e })}),/* @__PURE__ */ (0, H.jsx)(fle, {- rows: f.workRows,+ rows: d.workRows,pressed: t.work,props: e,- onPick: (e) => v({ work: t.work === e ? "" : e })+ onPick: (e) => _({ work: t.work === e ? "" : e })}),/* @__PURE__ */ (0, H.jsx)(ple, {- facets: f,+ facets: d,view: t,- total: b,- busy: p,+ total: y,+ busy: f,props: e,- route: v+ route: _}),/* @__PURE__ */ (0, H.jsx)(mle, {- conditions: y,- onDrop: (e) => a.route(Jce(t, e)),- onClear: () => v({+ conditions: v,+ onDrop: (e) => i.route(Jce(t, e)),+ onClear: () => _({author: "",provider: "",work: "",tags: []})}),- f.broken.length ? /* @__PURE__ */ (0, H.jsx)(hle, {- count: f.broken.length,- onManage: a.openManage+ d.broken.length ? /* @__PURE__ */ (0, H.jsx)(hle, {+ count: d.broken.length,+ onManage: i.openManage}) : null,/* @__PURE__ */ (0, H.jsx)(gle, {- pending: p,- facets: f,- data: l,- context: d,+ pending: f,+ facets: d,+ data: c,+ context: u,props: e- }, o.queryKey.join("\0")),- l.has_more || x ? /* @__PURE__ */ (0, H.jsxs)("div", {+ }, a.queryKey.join("\0")),+ c.has_more || b ? /* @__PURE__ */ (0, H.jsxs)("div", {"data-follow-pagination": "",- children: [l.has_more ? /* @__PURE__ */ (0, H.jsx)("span", {+ children: [c.has_more ? /* @__PURE__ */ (0, H.jsx)("span", {"data-follow-page-action": "",children: /* @__PURE__ */ (0, H.jsxs)(vr, {entity: !0,- enabled: () => !_.busyRef.current,+ enabled: () => !g.busyRef.current,load: async () => {- await s.fetchNextPage({ throwOnError: !0 });+ await o.fetchNextPage({ throwOnError: !0 });},children: [/* @__PURE__ */ (0, H.jsx)(ale, { className: "size-3.5" }), "加载更多"]- }, s.data?.pages.length)- }) : null, x ? /* @__PURE__ */ (0, H.jsxs)("span", {+ }, o.data?.pages.length)+ }) : null, b ? /* @__PURE__ */ (0, H.jsxs)("span", {"data-follow-page-action": "",children: [/* @__PURE__ */ (0, H.jsx)(J, {variant: "secondary",- leadingIcon: _.olderBusy ? void 0 : ole,+ leadingIcon: g.olderBusy ? void 0 : ole,"data-follow-older": "",- "aria-busy": _.busy || void 0,- onClick: () => void _.start(!0),- children: _.olderBusy ? /* @__PURE__ */ (0, H.jsxs)(H.Fragment, { children: [/* @__PURE__ */ (0, H.jsx)("span", {+ "aria-busy": g.busy || void 0,+ onClick: () => void g.start(!0),+ children: g.olderBusy ? /* @__PURE__ */ (0, H.jsxs)(H.Fragment, { children: [/* @__PURE__ */ (0, H.jsx)("span", {className: "contents",dangerouslySetInnerHTML: { __html: Ne("抓取中") }}), /* @__PURE__ */ (0, H.jsx)("span", { children: "抓取中…" })] }) : "抓更早的一页"}), /* @__PURE__ */ (0, H.jsx)("span", {"data-follow-backfill": "",- children: Gce(f.sources)+ children: Gce(d.sources)})]}) : null]}) : null@@ -77447,51 +77447,51 @@ function WGe({ data: e, context: t, mediaIndex: n, onMedia: r, mediaView: i, hel]});}-function GGe({ item: e, media: t, helpers: n, actions: r, onMedia: i, issues: a }) {- let { kind: o, selected: s, src: c, images: u, position: d, carousel: f, frameRatio: p } = t, m = (0, V.useRef)(null), [h, g] = (0, V.useState)(null), _ = zGe(e, t), v = s?.thumb_url || e.thumb_url || "", y = e.playable && o === "video", b = e.playable && o === "image" ? c : e.thumb_url || "", x = e.playable && o === "image" && v && v !== c ? v : "", [S, C] = (0, V.useState)(b), w = (0, V.useRef)({+function GGe({ item: e, media: t, actions: n, onMedia: r, issues: i }) {+ let { kind: a, selected: o, src: s, images: c, position: u, carousel: d, frameRatio: f } = t, p = (0, V.useRef)(null), [m, h] = (0, V.useState)(null), g = zGe(e, t), _ = o?.thumb_url || e.thumb_url || "", v = e.playable && a === "video", y = e.playable && a === "image" ? s : e.thumb_url || "", b = e.playable && a === "image" && _ && _ !== s ? _ : "", [x, S] = (0, V.useState)(y), C = (0, V.useRef)({item: e,- selected: s- }), T = (0, V.useRef)(a.failed);- T.current = a.failed, (0, V.useLayoutEffect)(() => {- let e = m.current;- if (!(!e || !y)) return r.mountPlayer(e, w.current.item, w.current.selected, { onError: () => T.current() });- }, [r, y]), (0, V.useLayoutEffect)(() => {- let e = m.current, t = e?.querySelector("[data-follow-detail-poster]"), n = e?.querySelector("[data-follow-image-step]");+ selected: o+ }), w = (0, V.useRef)(i.failed);+ w.current = i.failed, (0, V.useLayoutEffect)(() => {+ let e = p.current;+ if (!(!e || !v)) return n.mountPlayer(e, C.current.item, C.current.selected, { onError: () => w.current() });+ }, [n, v]), (0, V.useLayoutEffect)(() => {+ let e = p.current, t = e?.querySelector("[data-follow-detail-poster]"), n = e?.querySelector("[data-follow-image-step]");if (!e || !t || !n) return;let r = () => {if (!t.naturalWidth || !t.naturalHeight) return;let r = e.getBoundingClientRect(), i = Math.min(r.width, r.height * (t.naturalWidth / t.naturalHeight)), a = Math.max(0, (r.width - i) / 2), o = matchMedia("(max-width:640px)").matches ? 10 : 16;- g(Math.round(a >= n.offsetWidth + o * 2 ? (a - n.offsetWidth) / 2 : o));+ h(Math.round(a >= n.offsetWidth + o * 2 ? (a - n.offsetWidth) / 2 : o));}, i = new ResizeObserver(r);return i.observe(e), t.addEventListener("load", r), () => {i.disconnect(), t.removeEventListener("load", r);};- }, [S]);- let E = (e) => i(u[(d + e + u.length) % u.length].index);+ }, [x]);+ let T = (e) => r(c[(u + e + c.length) % c.length].index);return /* @__PURE__ */ (0, H.jsxs)("div", {- ref: m,+ ref: p,"data-stage-media": "",- "data-follow-detail-media": o || "none",- "data-framed": p ? "" : void 0,+ "data-follow-detail-media": a || "none",+ "data-framed": f ? "" : void 0,style: {- "--follow-frame-ratio": p ? p.toFixed(4) : void 0,- "--follow-image-arrow-inset": h === null ? void 0 : `${h}px`+ "--follow-frame-ratio": f ? f.toFixed(4) : void 0,+ "--follow-image-arrow-inset": m === null ? void 0 : `${m}px`},children: [- /* @__PURE__ */ (0, H.jsx)(B7, { onClose: r.close }),- y ? null : b ? /* @__PURE__ */ (0, H.jsx)("img", {+ /* @__PURE__ */ (0, H.jsx)(B7, { onClose: n.close }),+ v ? null : y ? /* @__PURE__ */ (0, H.jsx)("img", {"data-follow-detail-poster": "",- "data-zoomable": _.length ? "" : void 0,- src: S,+ "data-zoomable": g.length ? "" : void 0,+ src: x,alt: e.title,referrerPolicy: "no-referrer",- onClick: _.length ? () => void XT(Math.max(0, d), _) : void 0,+ onClick: g.length ? () => void XT(Math.max(0, u), g) : void 0,onError: () => {- if (x && S !== x) {- C(x), a.thumbFallback();+ if (b && x !== b) {+ S(b), i.thumbFallback();return;}- a.failed();+ i.failed();}}) : /* @__PURE__ */ (0, H.jsxs)("div", {"data-follow-detail-placeholder": "",@@ -77500,14 +77500,14 @@ function GGe({ item: e, media: t, helpers: n, actions: r, onMedia: i, issues: adangerouslySetInnerHTML: { __html: OO(e.resource_provider || e.provider) }}), /* @__PURE__ */ (0, H.jsx)("span", { children: "没有可用预览" })]}),- f ? /* @__PURE__ */ (0, H.jsxs)(H.Fragment, { children: [+ d ? /* @__PURE__ */ (0, H.jsxs)(H.Fragment, { children: [/* @__PURE__ */ (0, H.jsx)("button", {type: "button","data-follow-image-step": "-1","data-follow-image-arrow": "prev","aria-label": "上一张图片",title: "上一张",- onClick: () => E(-1),+ onClick: () => T(-1),dangerouslySetInnerHTML: { __html: l("chevron-left") }}),/* @__PURE__ */ (0, H.jsx)("button", {@@ -77516,20 +77516,20 @@ function GGe({ item: e, media: t, helpers: n, actions: r, onMedia: i, issues: a"data-follow-image-arrow": "next","aria-label": "下一张图片",title: "下一张",- onClick: () => E(1),+ onClick: () => T(1),dangerouslySetInnerHTML: { __html: l("chevron-right") }}),/* @__PURE__ */ (0, H.jsx)("div", {"data-follow-image-dots": "",role: "group",- "aria-label": `${u.length} 张图片`,- children: u.map((e, t) => /* @__PURE__ */ (0, H.jsx)("button", {+ "aria-label": `${c.length} 张图片`,+ children: c.map((e, t) => /* @__PURE__ */ (0, H.jsx)("button", {type: "button","data-follow-image-item": e.index,- "aria-current": t === d ? "true" : "false",- "aria-label": `第 ${t + 1} 张,共 ${u.length} 张`,+ "aria-current": t === u ? "true" : "false",+ "aria-label": `第 ${t + 1} 张,共 ${c.length} 张`,title: `第 ${t + 1} 张`,- onClick: () => i(e.index)+ onClick: () => r(e.index)}, e.index))})] }) : null@@ -78750,53 +78750,53 @@ function dKe({ item: e, write: t }) {})]});}-function fKe({ item: e, helpers: t, actions: n }) {- let r = (0, V.useMemo)(() => Afe(e), [e]), [i, a] = (0, V.useState)(!1), o = Math.max(0, r.cast.length - 8), s = (e, t, r) => {- let a = e === "performer" && r >= 8 && !i, o = e === "performer" ? /* @__PURE__ */ (0, H.jsxs)(H.Fragment, { children: [/* @__PURE__ */ (0, H.jsx)("span", { children: t.name.slice(0, 1) }), /* @__PURE__ */ (0, H.jsx)(q7, { html: N({- id: t.id,- hasImage: t.has_image,- version: t.image_version,- focus: t.avatar_focus- }) })] }) : e === "studio" ? /* @__PURE__ */ (0, H.jsxs)(H.Fragment, { children: [/* @__PURE__ */ (0, H.jsx)("span", { children: t.name.slice(0, 2) }), t.has_logo ? /* @__PURE__ */ (0, H.jsx)("img", {- src: ee(t.name, "icon", t.logo_version),+function fKe({ item: e, actions: t }) {+ let n = (0, V.useMemo)(() => Afe(e), [e]), [r, i] = (0, V.useState)(!1), a = Math.max(0, n.cast.length - 8), o = (e, n, i) => {+ let a = e === "performer" && i >= 8 && !r, o = e === "performer" ? /* @__PURE__ */ (0, H.jsxs)(H.Fragment, { children: [/* @__PURE__ */ (0, H.jsx)("span", { children: n.name.slice(0, 1) }), /* @__PURE__ */ (0, H.jsx)(q7, { html: N({+ id: n.id,+ hasImage: n.has_image,+ version: n.image_version,+ focus: n.avatar_focus+ }) })] }) : e === "studio" ? /* @__PURE__ */ (0, H.jsxs)(H.Fragment, { children: [/* @__PURE__ */ (0, H.jsx)("span", { children: n.name.slice(0, 2) }), n.has_logo ? /* @__PURE__ */ (0, H.jsx)("img", {+ src: ee(n.name, "icon", n.logo_version),alt: "",loading: "lazy","data-drop": "self"- }) : null] }) : /* @__PURE__ */ (0, H.jsx)("span", { children: t.name.slice(0, 1) }), s = /* @__PURE__ */ (0, H.jsxs)(H.Fragment, { children: [/* @__PURE__ */ (0, H.jsx)("span", {+ }) : null] }) : /* @__PURE__ */ (0, H.jsx)("span", { children: n.name.slice(0, 1) }), s = /* @__PURE__ */ (0, H.jsxs)(H.Fragment, { children: [/* @__PURE__ */ (0, H.jsx)("span", {"data-id-face": "",children: o}), /* @__PURE__ */ (0, H.jsx)("span", {"data-id-name": "",- children: t.name- })] }), c = e === "performer" && r >= 8 ? { "data-castoverflow": "" } : {};- return t.id ? /* @__PURE__ */ (0, H.jsx)("button", {+ children: n.name+ })] }), c = e === "performer" && i >= 8 ? { "data-castoverflow": "" } : {};+ return n.id ? /* @__PURE__ */ (0, H.jsx)("button", {type: "button","data-id-cell": e,"data-entity-kind": e,- "data-entity-name": t.name,- title: t.name,+ "data-entity-name": n.name,+ title: n.name,hidden: a,...c,- onClick: () => n.openEntity(e, t.name),+ onClick: () => t.openEntity(e, n.name),children: s- }, `${e}:${t.name}`) : /* @__PURE__ */ (0, H.jsx)("span", {+ }, `${e}:${n.name}`) : /* @__PURE__ */ (0, H.jsx)("span", {"data-id-cell": e,- title: t.name,+ title: n.name,hidden: a,...c,children: s- }, `${e}:${t.name}`);- }, c = (e, t, n, r = null) => n.length ? /* @__PURE__ */ (0, H.jsxs)("section", {+ }, `${e}:${n.name}`);+ }, s = (e, t, n, r = null) => n.length ? /* @__PURE__ */ (0, H.jsxs)("section", {"data-id-group": t,children: [/* @__PURE__ */ (0, H.jsx)("h5", {"data-id-label": "",children: e}), /* @__PURE__ */ (0, H.jsxs)("div", {"data-id-row": "",- children: [n.map((e, n) => s(t, e, n)), r]+ children: [n.map((e, n) => o(t, e, n)), r]})]- }, `${t}:${e}`) : null, l = [- r.unowned ? /* @__PURE__ */ (0, H.jsxs)("section", {+ }, `${t}:${e}`) : null, c = [+ n.unowned ? /* @__PURE__ */ (0, H.jsxs)("section", {"data-id-group": "unowned",children: [/* @__PURE__ */ (0, H.jsx)("h5", {"data-id-label": "",@@ -78808,7 +78808,7 @@ function fKe({ item: e, helpers: t, actions: n }) {"data-id-cell": "unowned","data-open-unowned": "",title: "打开未归属:馆藏里没有署名人的作品",- onClick: n.openUnowned,+ onClick: t.openUnowned,children: [/* @__PURE__ */ (0, H.jsx)("span", {"data-id-face": "",children: /* @__PURE__ */ (0, H.jsx)(K7, { name: "user-round" })@@ -78818,42 +78818,42 @@ function fKe({ item: e, helpers: t, actions: n }) {})]})})]- }, "unowned") : c(te(e), "performer", r.cast, o && !i ? /* @__PURE__ */ (0, H.jsxs)("button", {+ }, "unowned") : s(te(e), "performer", n.cast, a && !r ? /* @__PURE__ */ (0, H.jsxs)("button", {type: "button",id: "castMore","data-cast-more": "",- onClick: () => a(!0),+ onClick: () => i(!0),children: ["还有 ",- o,+ a," 位"]}) : null),- c("厂牌", "studio", r.studios),- c("片商", "studio", r.makers)+ s("厂牌", "studio", n.studios),+ s("片商", "studio", n.makers)].filter(Boolean);return /* @__PURE__ */ (0, H.jsxs)("div", {"data-item-identity": "",children: [- l.length ? /* @__PURE__ */ (0, H.jsx)("div", {+ c.length ? /* @__PURE__ */ (0, H.jsx)("div", {"data-identity-primary": "",- children: l+ children: c}) : null,- c("创作者", "creator", r.creators),- r.series.length ? /* @__PURE__ */ (0, H.jsxs)("section", {+ s("创作者", "creator", n.creators),+ n.series.length ? /* @__PURE__ */ (0, H.jsxs)("section", {"data-id-group": "series",children: [/* @__PURE__ */ (0, H.jsx)("h5", {"data-id-label": "",children: "系列"}), /* @__PURE__ */ (0, H.jsx)("div", {"data-series-rows": "",- children: r.series.map((e) => e.id ? /* @__PURE__ */ (0, H.jsxs)("button", {+ children: n.series.map((e) => e.id ? /* @__PURE__ */ (0, H.jsxs)("button", {type: "button","data-series-link": "","data-entity-kind": "series","data-entity-name": e.name,title: e.name,- onClick: () => n.openEntity("series", e.name),+ onClick: () => t.openEntity("series", e.name),children: [/* @__PURE__ */ (0, H.jsx)(K7, { name: "tags" }), /* @__PURE__ */ (0, H.jsx)("span", { children: e.name })]}, e.name) : /* @__PURE__ */ (0, H.jsxs)("span", {"data-series-link": "",