Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 补齐目录页的原地换态动效

longmeidao765c763f5dae
diff --git a/docs/reference-snapshots/transitions-dev-measured.md b/docs/reference-snapshots/transitions-dev-measured.md
index 32ac47686..bef16848e 100644
--- a/docs/reference-snapshots/transitions-dev-measured.md
+++ b/docs/reference-snapshots/transitions-dev-measured.md
@@ -17,15 +17,16 @@
## 逐条对照
时长与缓动一律并进 Peach 已有的动效 token:`--board-motion`(.3s cubic-bezier(.4,0,.2,1))、
-`--spring-press`(208ms 采样弹簧,峰值 1.088)、本次新增的 `--motion-swap`(.25s)、
-`--motion-reveal`(.4s)、`--motion-stagger`(70ms),全部由 `board.css` 那一条
+`--spring-press`(208ms 采样弹簧,峰值 1.088)、`--motion-swap`(.25s)、
+`--motion-count`(.25s cubic-bezier(.34,1.45,.64,1))、`--motion-reveal`(.4s)、
+`--motion-stagger`(70ms),全部由 `board.css` 那一条
`prefers-reduced-motion` 规则统一归零。
| 配方 | slug | 上游取值 | Peach 落成值 | 落点 |
| --- | --- | --- | --- | --- |
| 字形换字形 | `icon-swap` | 250ms;`ease-in-out`;blur 2px;scale .25 | `--motion-swap`(.25s cubic-bezier(.4,0,.2,1));blur 2px;scale .25 | `.iconswap`;`iconSwapHtml`/`setIconSwap` |
| 一行字换一行字 | `text-states` | 150ms;`ease-in-out`;blur 2px;位移 4px | `--motion-swap`;blur 2px;位移 4px | `.textswap`;`swapText` |
-| 读数按位跳出 | `number-pop-in` | 500ms;`cubic-bezier(0.34,1.45,0.64,1)`;blur 2px;位移 8px;按位延迟 70ms | `--motion-swap` + 同一条超调缓动;blur 2px;位移 8px;`--motion-stagger` 70ms | `.digits`;`popCount` |
+| 读数按位跳出 | `number-pop-in` | 500ms;`cubic-bezier(0.34,1.45,0.64,1)`;blur 2px;位移 8px;按位延迟 70ms | `--motion-count`(.25s + 同一条超调缓动);blur 2px;位移 8px;`--motion-stagger` 70ms | `.digits`;`popCount` |
| 占位换真内容 | `skeleton-loader` | 400ms;`ease-in-out`;blur 2px | `--motion-reveal`(.4s cubic-bezier(.4,0,.2,1));blur 2px | `.skelreveal`/`.skelfade`;`revealSkeleton` |
| 开关双弹 | `toggle-double-bounce` | 350ms;`cubic-bezier(0.34,1.35,0.64,1)`;行程 14.66px;超出端点 1px | `--spring-press`(208ms,峰值 1.088,行程 18px,超出约 1.6px) | `.ptoggle::after`/`::before` |
| 成功打勾 | `success-check` | 四段各 500ms;rotate 80deg;blur 10px;上荡 40px;`stroke-dasharray` 20;画笔延迟 80ms | `--board-motion` 走转正与清晰、`--spring-press` 走上荡 14px;rotate 80deg;blur 10px;`stroke-dasharray` 24;画笔延迟 `--motion-stagger` | `.checkdraw`;toast 图标 |
@@ -48,15 +49,17 @@
- 取证方式同上,另加一条:`https://transitions.dev/transitions/<slug>` 会 301 到同一
地址带斜杠的那一份,配方的 CSS 与 React 两份全文都在那一页的 HTML 里,不在 JS 包里。
-- 这一批新增一档 token `--motion-pop`(.4s cubic-bezier(.34,1.36,.64,1)),和原有五档
+- 这一批新增一档 token `--motion-pop`(.4s cubic-bezier(.34,1.36,.64,1)),和当时已有五档
住在 `board.css` 同一个 `:root`、由同一条 `prefers-reduced-motion` 规则归零。
它单独成档是因为缓动:`animation` 里只能有一条缓动函数,token 已经带着一条,
再写第二条整条声明就无效,动画会被整个丢掉。
+- 2026-09-19 在线复核 `input-clear-with-dissolve`:出场仍为 400ms、向下位移 12px、blur 2px,
+ 缓动仍为 `cubic-bezier(.22,1,.36,1)`;Peach 保留向上溶解且不做逐词扫光的既有差异。
| 配方 | slug | 上游取值 | Peach 落成值 | 落点 |
| --- | --- | --- | --- | --- |
-| 一排头像里抬起一枚 | `avatar-group-hover` | 320ms;进 `cubic-bezier(0.22,1,0.36,1)`、出 `cubic-bezier(0.34,3.85,0.64,1)`;抬 -4px;放大 1.05;衰减 .45 | `--board-motion`(.3s)走抬起、`--spring-press`(208ms 采样弹簧)走落回;抬 -4px;放大 1.05;衰减 .45,横向推开 7px/10px 为 Peach 自拟 | `.tier`/`.followauthors`/`.followworks` 的 `.av`、`.brandpill`;卡片上的 `.mavstack .mav` |
-| 清空时内容溶解 | `input-clear-with-dissolve` | 出场 400ms;`cubic-bezier(0.22,1,0.36,1)`;位移 12px;blur 2px;另有逐词 radial-gradient 扫光 | `--motion-reveal`(.4s);位移 12px;blur 2px;不做扫光 | `.cleardissolve`;`dissolveValue`;`#q` 的六个清空入口 |
+| 一排头像里抬起一枚 | `avatar-group-hover` | 320ms;进 `cubic-bezier(0.22,1,0.36,1)`、出 `cubic-bezier(0.34,3.85,0.64,1)`;抬 -4px;放大 1.05;衰减 .45 | `--board-motion`(.3s)走抬起、`--spring-press`(208ms 采样弹簧)走落回;抬 -4px;放大 1.05;共演头像最多五枚,常态相邻压 22px,悬停或焦点时后续四枚向右 10/20/30/40px,左缘保留放大与 2px 环空间,均为 Peach 自拟 | `.tier`/`.followauthors`/`.followworks` 的 `.av`、`.brandpill`;卡片上的 `.mavstack .mav` |
+| 清空时内容溶解 | `input-clear-with-dissolve` | 出场 400ms;`cubic-bezier(0.22,1,0.36,1)`;位移 12px;blur 2px;另有逐词 radial-gradient 扫光 | `--motion-reveal`(.4s);位移 12px;blur 2px;不做扫光;复制输入框 padding、字体与横滚位置 | `.cleardissolve`;`dissolveValue`;`#q` 的程序清空、原生清空键、整段删除与第二次 Escape |
| 计数徽标弹出 | `notification-badge` | 弹入 500ms `cubic-bezier(0.34,1.36,0.64,1)`、淡入 400ms;blur 2px;scale 0→1;另有 260ms 的 (-8.2px, 12.4px) 滑入 | `--motion-pop`(.4s + 同一条超调缓动);blur 2px;scale 0→1;不做滑入 | `.countbadge`;`popBadges`;筛选条与抽屉的 `.n`、垃圾文件分类计数 |
| 标题逐行揭示 | `texts-reveal` | 500ms;`cubic-bezier(0.22,1,0.36,1)`;位移 12px;blur 3px;行距 40ms | `--motion-reveal`(.4s);位移 12px;blur 3px;行距 `--motion-stagger` 70ms | `.revealline`;`revealTexts`;详情浮窗标题、管理区页面标题、设置面板页签标题 |
@@ -67,13 +70,16 @@
三档就衰减到 .36px(看不出来),选择器直接写到两位即可,省掉一整套监听与重新绑定。
落回那条不用上游的 `cubic-bezier(0.34,3.85,0.64,1)`,改用站内已有的 `--spring-press`,
理由与第一批开关双弹同一条:已经有采样自真实弹簧的那一档,不再另起一条近似。
-- 横向推开是 Peach 自己加的,上游没有这一项。它只对叠放那一组(`.mavstack`,相邻两枚
- 压着 14px)成立:只抬不推的话,被抬起的那一枚仍有半张脸压在邻座下面。横滚的那两排
- 本来就有 14px 间距,不推。
+- 横向推开是 Peach 自己加的,上游没有这一项。它只对最多五枚的叠放组成立:常态相邻两枚
+ 压着 22px,指到或聚焦一枚时只把它右边的头像按 10px 阶梯向标题方向展开,左边的头像和
+ 整组左缘不动。首枚的真实内缩同时容纳 1.05 倍放大和 2px 环,窄卡只显示前两枚;横滚的
+ 头像排本来就有间距,不横向推开。悬停与键盘焦点所在头像都升到最高层。
- 清空不做逐词扫光。上游自己在注释里写明那道光的起落曲线无法用静态关键帧表达、必须逐帧写
`background`;换来的是一道在深浅两个主题下都几乎看不出来的光,搜索框每清一次跑一段
逐帧 JS 不值当。溶解层是照着输入框当下的位置和字体摆的一份复制品,输入框的 value 在
- 动画开始前就已经清空,光标与输入法不等这 400ms。
+ 动画开始前就已经清空,光标与输入法不等这 400ms。原生搜索清空键、非空到空的整段删除
+ 与菜单已经关闭后的 Escape 都走同一入口;继续输入会取消残影,输入法开始组字时也先取消,
+ 不让旧字盖住候选字。
- 徽标不做滑入。上游那枚锚在铃铛图标的右上角,滑入是从图标中心飞到角上;Peach 这几枚
是行内跟在标签后面的计数,没有「从哪飞来」的起点,硬加一段位移只会让整行字跟着晃。
- 徽标只在值真的变了时弹,判据存在模块级的一张表里,不看节点是不是新建的:这几排每换
diff --git a/frontend/e2e/design.test.ts b/frontend/e2e/design.test.ts
index 49781d87b..a7f65c55d 100644
--- a/frontend/e2e/design.test.ts
+++ b/frontend/e2e/design.test.ts
@@ -128,6 +128,46 @@ async function openProcessing(
return opened;
}
+/** 打开目录并等到读数与卡片一起替下首屏骨架。 */
+async function openCatalog(browser: Browser): Promise<Visit> {
+ const opened = await visit(browser, '/', DESKTOP);
+ await opened.page.locator('#count [data-count-readout]').waitFor({ timeout: 15_000 });
+ await settle(opened.page);
+ return opened;
+}
+
+interface CatalogFixture {
+ total: number;
+ items: Array<Record<string, unknown>>;
+ [key: string]: unknown;
+}
+
+/** 从演示库取一份能完整渲染的真实目录响应,只替换当前判据需要的字段。 */
+async function openCatalogFixture(
+ browser: Browser,
+ change: (payload: CatalogFixture, url: URL) => void,
+): Promise<Visit> {
+ const opened = await visit(browser, '/', DESKTOP);
+ let baseline: CatalogFixture | undefined;
+ await opened.page.route(/\/api\/items\?/, async (route) => {
+ if (!baseline) {
+ const response = await route.fetch();
+ baseline = await response.json() as CatalogFixture;
+ }
+ const payload = structuredClone(baseline);
+ change(payload, new URL(route.request().url()));
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify(payload),
+ });
+ });
+ await opened.page.reload({ waitUntil: 'load' });
+ await opened.page.locator('#count [data-count-readout]').waitFor({ timeout: 15_000 });
+ await settle(opened.page);
+ return opened;
+}
+
/** 一趟跑到一半的扫描与采集。 */
const RUNNING_JOB = { status: 'running', stage: '采集缺失资料', checked: 38, total: 100 };
@@ -343,4 +383,211 @@ describe('设计决定', () => {
await opened.close();
}
});
+
+ it('顶栏版式键保留两枚字形并原地换态', { timeout: 60_000 }, async () => {
+ const opened = await openCatalog(browser);
+ try {
+ await opened.page.emulateMedia({ reducedMotion: 'no-preference' });
+ const button = opened.page.locator('#density');
+ const swap = button.locator('[data-icon-swap]');
+ await swap.waitFor({ timeout: 5_000 });
+ assert.equal(await swap.locator('[data-icon]').count(), 2);
+ const before = await swap.getAttribute('data-icon-state');
+ await swap.evaluate((element) => { element.setAttribute('data-test-identity', 'density-swap'); });
+ await button.click();
+ assert.notEqual(await swap.getAttribute('data-icon-state'), before,
+ '按下后仍停在同一枚字形');
+ assert.equal(await swap.locator('[data-icon]').count(), 2,
+ '换态不应销毁其中一枚字形');
+ await button.click();
+ assert.equal(await swap.getAttribute('data-icon-state'), before, '第二次按下没有回到原字形');
+ assert.equal(await button.locator('[data-icon-swap][data-test-identity="density-swap"]').count(), 1,
+ '两次换态之间重建了字形容器');
+ } finally {
+ await opened.close();
+ }
+ });
+
+ it('读数首次静态落笔,变值时每一位都有有效动画', { timeout: 60_000 }, async () => {
+ const opened = await openCatalogFixture(browser, (payload, url) => {
+ payload.total = url.searchParams.has('q') ? 34 : 12;
+ });
+ try {
+ await opened.page.emulateMedia({ reducedMotion: 'no-preference' });
+ const result = await opened.page.evaluate(async () => {
+ const { popCount } = await import('/js/ui-components.js');
+ const host = document.createElement('span');
+ document.body.append(host);
+ popCount(host, '12');
+ const firstWasStatic = !host.firstElementChild?.classList.contains('popping');
+ popCount(host, '34');
+ const digit = host.querySelector<HTMLElement>('.digits.popping > span');
+ const style = digit && getComputedStyle(digit);
+ const answer = {
+ firstWasStatic,
+ animationName: style?.animationName || '',
+ duration: style?.animationDuration || '',
+ };
+ host.remove();
+ return answer;
+ });
+ assert.equal(result.firstWasStatic, true, '首次写入不应弹动');
+ assert.equal(result.animationName, 'digit-pop-in');
+ assert.equal(result.duration, '0.25s');
+
+ const input = opened.page.locator('#q');
+ await input.fill('读数变值');
+ await input.press('Enter');
+ await opened.page.waitForFunction(() =>
+ document.querySelector('#count [data-count-readout]')?.textContent?.includes('34 个符合'));
+ const liveDigit = opened.page.locator('#count [data-count-readout] .digits.popping > span').first();
+ await liveDigit.waitFor({ timeout: 5_000 });
+ assert.equal(await liveDigit.evaluate((element) => getComputedStyle(element).animationName),
+ 'digit-pop-in', '真实读数节点变值后没有播放动画');
+ } finally {
+ await opened.close();
+ }
+ });
+
+ it('五枚叠放头像只朝标题方向展开,左缘和窄卡边界不动', { timeout: 60_000 }, async () => {
+ const names = Array.from({ length: 7 }, (_, index) => `演示演员 ${index + 1}`);
+ const opened = await openCatalogFixture(browser, (payload) => {
+ const item = payload.items[0];
+ if (!item) throw new Error('演示目录没有可替换的卡片');
+ item.creator = '';
+ item.performers = names;
+ item.performer_total = names.length;
+ item.performer_entities = names.map((name, index) => ({ id: 90_000 + index, name, has_image: false }));
+ });
+ try {
+ await opened.page.emulateMedia({ reducedMotion: 'no-preference' });
+ const stack = opened.page.locator('.card[data-id] .mavstack').first();
+ await stack.waitFor({ timeout: 5_000 });
+ const avatars = stack.locator('.mav');
+ assert.equal(await avatars.count(), 5, 'API 给七位表演者时卡片没有收在五枚以内');
+ const before = await avatars.evaluateAll((items) => items.map((item) => item.getBoundingClientRect().x));
+ const left = (await stack.boundingBox())!.x;
+
+ await avatars.first().hover();
+ await opened.page.waitForTimeout(320);
+ const firstSpread = await avatars.evaluateAll((items) => items.map((item) => item.getBoundingClientRect().x));
+ for (let index = 1; index < firstSpread.length; index += 1) {
+ assert.ok(firstSpread[index] > before[index], `首枚悬停时第 ${index + 1} 枚没有向标题方向展开`);
+ }
+
+ await avatars.nth(2).hover();
+ await opened.page.waitForTimeout(320);
+ const after = await avatars.evaluateAll((items) => items.map((item) => item.getBoundingClientRect().x));
+ const card = stack.locator('xpath=ancestor::*[contains(concat(" ", normalize-space(@class), " "), " card ")]').first();
+ const bounds = await card.evaluate((cardElement) => {
+ const stackRect = cardElement.querySelector('.mavstack')!.getBoundingClientRect();
+ const lastRect = cardElement.querySelector('.mav:last-child')!.getBoundingClientRect();
+ const firstRect = cardElement.querySelector('.mav')!.getBoundingClientRect();
+ const cardRect = cardElement.getBoundingClientRect();
+ return {
+ stackLeft: stackRect.left,
+ firstRingLeft: firstRect.left - 2,
+ lastRingRight: lastRect.right + 2,
+ cardLeft: cardRect.left,
+ cardRight: cardRect.right,
+ };
+ });
+ assert.equal(bounds.stackLeft, left, '展开时左缘发生位移');
+ assert.equal(after[0], before[0], '指向第三枚时第一枚被往左推');
+ assert.equal(after[1], before[1], '指向第三枚时第二枚被往左推');
+ assert.ok(after[3] > before[3] && after[4] > before[4], '右侧邻座没有朝标题方向让开');
+ assert.ok(bounds.firstRingLeft >= bounds.cardLeft - .5, '首枚放大加描边后被卡片左缘裁切');
+ assert.ok(bounds.lastRingRight <= bounds.cardRight + .5, '头像展开越出卡片右缘');
+
+ await opened.page.mouse.move(0, 0);
+ await avatars.nth(2).focus();
+ await opened.page.waitForTimeout(320);
+ const layers = await avatars.evaluateAll((items) => items.map((item) => Number(getComputedStyle(item).zIndex)));
+ assert.equal(layers[2], Math.max(...layers), '键盘焦点所在头像没有升到最高层');
+
+ await opened.page.setViewportSize({ width: 390, height: 844 });
+ const drawer = opened.page.locator('#drawer');
+ if (await drawer.evaluate((element) => element.classList.contains('open'))) {
+ await opened.page.locator('#scrim').evaluate((element) => (element as HTMLElement).click());
+ await opened.page.waitForFunction(() => !document.querySelector('#drawer')?.classList.contains('open'));
+ }
+ await avatars.first().hover();
+ await opened.page.waitForTimeout(320);
+ const narrow = await card.evaluate((cardElement) => {
+ const cardRect = cardElement.getBoundingClientRect();
+ const firstRect = cardElement.querySelector('.mav')!.getBoundingClientRect();
+ const lastRect = cardElement.querySelector('.mav:last-child')!.getBoundingClientRect();
+ let clip: Element | null = cardElement.parentElement;
+ while (clip && clip !== document.documentElement) {
+ const style = getComputedStyle(clip);
+ if (style.overflowX !== 'visible' || style.overflowY !== 'visible') break;
+ clip = clip.parentElement;
+ }
+ const clipRect = (clip || document.documentElement).getBoundingClientRect();
+ return {
+ firstRingLeft: firstRect.left - 2,
+ lastRingRight: lastRect.right + 2,
+ cardLeft: cardRect.left,
+ cardRight: cardRect.right,
+ clipLeft: clipRect.left,
+ clipRight: clipRect.right,
+ viewport: document.documentElement.clientWidth,
+ };
+ });
+ assert.ok(narrow.firstRingLeft >= Math.max(narrow.cardLeft, narrow.clipLeft) - .5,
+ '390px 视口下首枚头像或描边被最近的裁切祖先截掉');
+ assert.ok(narrow.lastRingRight <= Math.min(narrow.cardRight, narrow.clipRight, narrow.viewport) + .5,
+ '390px 视口下展开头像越出卡片、裁切祖先或视口');
+ } finally {
+ await opened.close();
+ }
+ });
+
+ it('搜索框从非空变空时立即清值并溶解原内容', { timeout: 60_000 }, async () => {
+ const opened = await openCatalog(browser);
+ try {
+ await opened.page.emulateMedia({ reducedMotion: 'no-preference' });
+ const input = opened.page.locator('#q');
+ const text = '一段长到会在搜索框里横向滚动的内容 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ '.repeat(4).trim();
+ await input.fill(text);
+ await input.evaluate((element) => {
+ const field = element as HTMLInputElement;
+ field.setSelectionRange(field.value.length, field.value.length);
+ field.scrollLeft = field.scrollWidth;
+ field.dispatchEvent(new InputEvent('input', { bubbles: true, inputType: 'insertText' }));
+ });
+ assert.ok(await input.evaluate((element) => (element as HTMLInputElement).scrollLeft) > 0,
+ '测试内容没有真正让搜索框横向滚动');
+ await input.fill('');
+ const ghost = opened.page.locator('.search > .cleardissolve');
+ await ghost.waitFor({ timeout: 1_000 });
+ assert.equal(await input.inputValue(), '', '动画阻塞了真实输入框清空');
+ assert.equal(await ghost.locator('[data-dissolve-value]').textContent(), text);
+ assert.equal(await input.evaluate((element) => getComputedStyle(element, '::placeholder').opacity), '0');
+ assert.match(await ghost.locator('[data-dissolve-value]').getAttribute('style') || '', /translateX\(-\d+px\)/);
+ await ghost.waitFor({ state: 'detached', timeout: 2_000 });
+ assert.equal(await input.evaluate((element) => element.classList.contains('dissolving')), false,
+ '动画结束后仍压着输入框的溶解状态');
+
+ await input.fill(text);
+ await input.fill('');
+ await opened.page.locator('.search > .cleardissolve').waitFor({ timeout: 1_000 });
+ await input.type('新输入');
+ assert.equal(await opened.page.locator('.search > .cleardissolve').count(), 0,
+ '清空后继续输入仍被旧残影覆盖');
+ assert.equal(await input.inputValue(), '新输入');
+
+ await input.fill('输入法候选');
+ await input.fill('');
+ await opened.page.locator('.search > .cleardissolve').waitFor({ timeout: 1_000 });
+ await input.evaluate((element) => element.dispatchEvent(new CompositionEvent('compositionstart', {
+ bubbles: true,
+ data: '候',
+ })));
+ assert.equal(await opened.page.locator('.search > .cleardissolve').count(), 0,
+ '输入法开始组字后旧残影仍覆盖候选字');
+ } finally {
+ await opened.close();
+ }
+ });
});
diff --git a/tests/test_web_e2e.py b/tests/test_web_e2e.py
index 53c69a477..187f0d890 100644
--- a/tests/test_web_e2e.py
+++ b/tests/test_web_e2e.py
@@ -32,7 +32,7 @@ from contextlib import closing
from pathlib import Path
from unittest import mock
-from peach import settings_file
+from peach import link_marks, scraping_access, settings_file
from peach.config import FFMPEG_DIR
from peach.ffmpeg import FFmpegResolver
from peach.library_processing import process_library
@@ -85,6 +85,16 @@ def refuse_network(*args, **kwargs):
raise AssertionError("演示库的 process 不应向任何外部来源发请求")
+def e2e_command(npm: str, node: str, concurrency: str = "") -> list[str]:
+ """资源受限运行可串行两个 Node 测试文件;日常与 CI 仍走 package script。"""
+ if not concurrency:
+ return [npm, "--prefix", str(FRONTEND), "run", "e2e", "--silent"]
+ if not concurrency.isdecimal() or int(concurrency) < 1:
+ raise AssertionError("PEACH_E2E_CONCURRENCY 必须是正整数")
+ return [node, "--test", f"--test-concurrency={int(concurrency)}",
+ "--test-reporter=tap", "e2e/**/*.test.ts"]
+
+
@windows_ledger_roots
class WebE2ESmokeTests(unittest.TestCase):
@classmethod
@@ -92,6 +102,9 @@ class WebE2ESmokeTests(unittest.TestCase):
npm = shutil.which("npm")
if npm is None:
missing_prerequisite("跳过 e2e:本机没有 npm。装 Node 24+ 后 `-Scope web` 会带上它")
+ node = shutil.which("node")
+ if node is None:
+ missing_prerequisite("跳过 e2e:本机没有 Node。装 Node 24+ 后 `-Scope web` 会带上它")
if not (FRONTEND / "node_modules" / "playwright-core").is_dir():
missing_prerequisite("跳过 e2e:frontend/node_modules 还没装,先 `npm --prefix frontend ci`")
ffmpeg = FFmpegResolver(FFMPEG_DIR).ffmpeg()
@@ -100,7 +113,7 @@ class WebE2ESmokeTests(unittest.TestCase):
chrome = chrome_executable()
if chrome is None:
missing_prerequisite("跳过 e2e:没找到 Chrome;装 Google Chrome 或用 PEACH_E2E_CHROME 指定")
- cls.npm, cls.ffmpeg, cls.chrome = npm, str(ffmpeg.path), chrome
+ cls.npm, cls.node, cls.ffmpeg, cls.chrome = npm, node, str(ffmpeg.path), chrome
cls.root = Path(tempfile.mkdtemp(prefix="peach-e2e-")).resolve()
cls.server = None
try:
@@ -140,6 +153,15 @@ class WebE2ESmokeTests(unittest.TestCase):
)
settings_file.write(config)
generated = config.directory("generated")
+ # 路由冒烟只验页面与站标端点的衔接;取图算法另有 mock 契约,不让这轮布局测试依赖外网。
+ mark_root = generated / "site-marks"
+ mark_root.mkdir(parents=True)
+ mark = (ROOT / "resources" / "peach-logo.png").read_bytes()
+ for spec in scraping_access.SOURCES.values():
+ cached = link_marks.cached_path(mark_root, spec["login"])
+ if cached is None:
+ raise AssertionError(f"采集来源没有可缓存的主机:{spec['login']}")
+ cached.write_bytes(mark)
result = process_library(config, cls.db, generated, generated / "covers",
provider_factory=refuse_network)
if result["status"] != "complete":
@@ -184,7 +206,8 @@ class WebE2ESmokeTests(unittest.TestCase):
PEACH_E2E_CHROME=self.chrome)
try:
completed = subprocess.run(
- [self.npm, "--prefix", str(FRONTEND), "run", "e2e", "--silent"],
+ e2e_command(self.npm, self.node,
+ os.environ.get("PEACH_E2E_CONCURRENCY", "").strip()),
capture_output=True, text=True, encoding="utf-8", errors="replace",
cwd=str(FRONTEND), env=env, timeout=E2E_SECONDS, check=False)
except subprocess.TimeoutExpired as expired:
@@ -211,6 +234,17 @@ class MissingPrerequisiteTests(unittest.TestCase):
with self.assertRaises(unittest.SkipTest):
missing_prerequisite("没有 npm")
+ def test_resource_limited_e2e_places_concurrency_before_the_test_glob(self):
+ self.assertEqual(e2e_command("npm", "node", "1"), [
+ "node", "--test", "--test-concurrency=1", "--test-reporter=tap",
+ "e2e/**/*.test.ts",
+ ])
+ self.assertEqual(e2e_command("npm", "node"), [
+ "npm", "--prefix", str(FRONTEND), "run", "e2e", "--silent",
+ ])
+ with self.assertRaisesRegex(AssertionError, "必须是正整数"):
+ e2e_command("npm", "node", "0")
+
if __name__ == "__main__":
unittest.main()
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 98e19ce49..594039519 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -1802,8 +1802,9 @@ class WebUiSourceTests(unittest.TestCase):
"""
self.assertPageContains("iq.oninput=e=>{if(e.isComposing)return;refineIndex()};")
self.assertPageContains("iq.oncompositionend=refineIndex;")
- self.assertPageContains("$('#q').oninput=e=>{if(e.isComposing)return;refreshSearchMenu()};")
- self.assertPageContains("$('#q').oncompositionend=refreshSearchMenu;")
+ self.assertPageContains("const handleSearchInput=e=>{\n if(e.isComposing)return;")
+ self.assertPageContains("$('#q').oninput=handleSearchInput;")
+ self.assertPageContains("$('#q').addEventListener('compositionend',handleSearchInput);")
self.assertPageContains("search.oninput=e=>{if(e.isComposing)return;renderPicker()};")
self.assertPageContains("search.oncompositionend=renderPicker;")
# 顶部搜索和标签选择器的键盘处理在最前面让位给输入法。
@@ -1870,11 +1871,12 @@ class WebUiSourceTests(unittest.TestCase):
# 多人合集保留头像提示,但文字只写第一位和总人数,避免名称折成多行。
self.assertPageContains("const coStarred=performers.length>1&&!primaryCreator")
self.assertPageContains('<div class="mavstack">')
- self.assertPageContains("performers.slice(0,3)")
+ self.assertPageContains("performers.slice(0,5)")
self.assertPageContains("data-entity-kind=\"performer\" data-entity-name=\"${esc(nm)}\"")
self.assertPageContains("data-entity-name=\"${esc(performer)}\"")
self.assertPageContains("等 ${performerTotal} 人")
- self.assertPageContains(".mavstack .mav+.mav{margin-left:-14px}")
+ self.assertPageContains(".mavstack .mav+.mav{margin-left:-22px}")
+ self.assertPageContains(".mavstack .mav:nth-child(n+6){display:none}")
def test_card_tags_drop_whole_names_instead_of_ellipsizing_them(self):
"""卡片上宁可少放几个标签,也要把名字写全。
@@ -2612,7 +2614,8 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("document.addEventListener('pointerdown',event=>{\n"
" if(!event.target.closest('.search'))"
"hideSearchMenu();\n},true);")
- self.assertPageContains("if(e.key==='Escape'&&!$('#searchMenu').hidden){")
+ self.assertPageContains("const hadValue=!!$('#q').value,hadMenu=!$('#searchMenu').hidden;")
+ self.assertPageContains("if(hadMenu){hideSearchMenu();searchActive=-1;e.preventDefault();return}")
self.assertPageLacks("]).then(renderSearchMenu)});")
def test_card_aspect_ratio_actually_reaches_the_element(self):
@@ -3160,7 +3163,8 @@ class WebUiSourceTests(unittest.TestCase):
self.assertIn('class="danger" data-cleanup-empty hidden', self.app_js)
self.assertIn("body .splitbutton.primary{border:0;box-shadow:none}", board)
# 顶栏密度键跟筛选框的版式开关取同一份字形映射。
- self.assertPageContains("const glyph=PHOTO_SIZES.find(([key])=>key===size)?.[2];if(!glyph)return;")
+ self.assertPageContains("button.innerHTML=iconSwapHtml(big[2],small[2],")
+ self.assertPageContains("}else setIconSwap(button,size===small[0]?'b':'a');")
self.assertPageContains("syncDensityIcon(density==='big'?'big':'small')}")
self.assertPageContains(" }else applyDensity();")
@@ -9726,7 +9730,7 @@ class WebUiSourceTests(unittest.TestCase):
self.assertIn(":active::-webkit-slider-thumb{scale:1.18;transition:scale .06s ease-out}", board)
# 关掉动效时两档弹簧一起归零,剩下的是瞬时到位;原地换态那三档也在同一条里。
self.assertIn("--board-motion:0s;--board-dialog-motion:0s;--spring-pane-ms:0;"
- "--spring-press-ms:0;--motion-swap:0s;--motion-reveal:0s;"
+ "--spring-press-ms:0;--motion-swap:0s;--motion-count:0s;--motion-reveal:0s;"
"--motion-stagger:0ms;--motion-pop:0s}", board)
def test_the_theme_sweep_masks_with_a_gradient_instead_of_a_filtered_svg(self):
@@ -11066,8 +11070,8 @@ class WebUiSourceTests(unittest.TestCase):
去裁——行高凑不出整行,第三行会露半截字,用户看到的就是被切掉的「399 MB」。
"""
self.assertCode(
- ".ncard .mavstack .mav:nth-child(3),\n"
- ".sgrid.mixgrid>.mixqueue .mavstack .mav:nth-child(3){display:none}")
+ ".ncard .mavstack .mav:nth-child(n+3),\n"
+ ".sgrid.mixgrid>.mixqueue .mavstack .mav:nth-child(n+3){display:none}")
self.assertPageContains(
".ncard .meta .s{flex-wrap:nowrap;overflow:hidden}")
self.assertPageContains(
@@ -12274,6 +12278,7 @@ class MotionRecipeTests(unittest.TestCase):
self.assertPageContains("if(previous===undefined||previous===next){write();return}")
# 整行重画时读数那一格跟着重建,靠上一次的值判断自己是刚出现还是换了数。
self.assertPageContains("if(lastCountReadout)readout.dataset.popCount=lastCountReadout;")
+ self.assertPageContains(".digits.popping>span{animation:digit-pop-in var(--motion-count) both;")
self.assertPageContains("animation-delay:calc(var(--motion-stagger) * var(--digit-at,0))")
def test_skeleton_hands_over_to_content_with_a_cross_fade(self):
@@ -12335,8 +12340,11 @@ class MotionRecipeTests(unittest.TestCase):
self.assertPageContains(
"transform:translate(var(--lift-x,0),var(--lift-y,0)) scale(var(--lift-scale,1))")
self.assertPageContains(
- ":is(#tiers .tier,.followauthors,.followworks,.mavstack):has(:hover)"
+ ":is(#tiers .tier,.followauthors,.followworks,.mavstack):has(:is(:hover,:focus-visible))"
"{--lift-motion:var(--board-motion)}")
+ self.assertPageContains(
+ ".mavstack .mav:is(:hover,:focus-visible)+.mav+.mav+.mav+.mav{--lift-x:40px}")
+ self.assertNotIn("--lift-x:-", motion, "叠放头像不得向卡片左缘移动")
# 落回走按压弹簧:站内已经有采样自真实弹簧的那一档,不另起一条近似。
self.assertPageContains("--lift-motion:calc(var(--spring-press-ms) * 1ms) var(--spring-press)")
# 那条 transition 住在 board.css:它的 shorthand 已经排着 scale 与配色,
@@ -12351,8 +12359,12 @@ class MotionRecipeTests(unittest.TestCase):
复制品先摆好、value 当场清空,光标与输入法一刻也不等这段动画;六个清空入口
共用同一个函数,漏掉一个就是那条路径上硬切。
"""
- self.assertPageContains("export function dissolveValue(input,host=input&&input.parentElement)")
- self.assertPageContains("const clearSearchField=()=>dissolveValue($('#q'));")
+ self.assertPageContains("export function dissolveValue(input,host=input&&input.parentElement,")
+ self.assertPageContains("if(!next&&searchValueSnapshot.text)clearSearchField(searchValueSnapshot);")
+ self.assertPageContains("$('#q').addEventListener('compositionstart',()=>{cancelSearchDissolve();")
+ self.assertPageContains("$('#q').addEventListener('beforeinput'")
+ self.assertPageContains(".search input.dissolving::placeholder{opacity:0}")
+ self.assertPageContains("if(!host.querySelector(':scope > .cleardissolve'))input.classList.remove('dissolving')")
self.assertPageContains("animation:clear-dissolve var(--motion-reveal) forwards")
app = (Path(__file__).resolve().parents[1]
/ "web/app.js").read_text(encoding="utf-8")
@@ -12397,8 +12409,10 @@ class MotionRecipeTests(unittest.TestCase):
board = (Path(__file__).resolve().parents[1]
/ "web/board.css").read_text(encoding="utf-8")
self.assertIn("--motion-pop:.4s cubic-bezier(.34,1.36,.64,1)", board)
+ self.assertIn("--motion-count:.25s cubic-bezier(.34,1.45,.64,1)", board)
start = board.index("--board-motion:0s")
self.assertIn("--motion-pop:0", board[start:board.index("}", start)])
+ self.assertIn("--motion-count:0", board[start:board.index("}", start)])
if __name__ == "__main__":
diff --git a/web/app.js b/web/app.js
index 9844f2437..5b9c147a4 100644
--- a/web/app.js
+++ b/web/app.js
@@ -1207,7 +1207,19 @@ function resetHomeState(){
/* 离开搜索结果时把搜索框一起清掉。框里的字不是瞬间没的:`dissolveValue` 先照着它此刻
的位置摆一份同样的字飘上去糊掉,输入框当场就空了,回来的人看见的是一个空框加一段
刚散掉的残影,而不是「刚才那句话去哪了」。 */
-const clearSearchField=()=>dissolveValue($('#q'));
+let searchValueSnapshot={text:'',scrollLeft:0};
+let cancelSearchDissolve=()=>{};
+const rememberSearchValue=(input=$('#q'))=>{
+ searchValueSnapshot={text:input?.value||'',scrollLeft:input?.scrollLeft||0};
+};
+const clearSearchField=(snapshot=null)=>{
+ const input=$('#q');if(!input)return;
+ const liveSnapshot={text:input.value,scrollLeft:input.scrollLeft||0};
+ const previous=snapshot||(liveSnapshot.text?liveSnapshot:searchValueSnapshot);
+ cancelSearchDissolve();
+ cancelSearchDissolve=dissolveValue(input,input.parentElement,previous);
+ searchValueSnapshot={text:'',scrollLeft:0};
+};
/* 「未归属」是全库那一类,不是当前这一页里的子筛选:在某位女优的资料页上再筛「没有
署名人」永远是空的。所以它和打开资料页一样离开当前语境,回目录只留这一条筛选,
顶栏芯片指的就是同一份列表。 */
@@ -1242,7 +1254,7 @@ const entityFilterSearch=filters=>{const params=new URLSearchParams();
const cloneBarsContext=context=>context&&context.type==='entity'
? {...context,filters:{...context.filters}}:context;
const activeFilterState=()=>barsContext.type==='home'?state:barsContext.filters;
-$('#q').value=state.q;
+$('#q').value=state.q;rememberSearchValue();
const REP={}; // 创作者/厂牌 → 代表作 id,用来做圆头像(裁接触印相中心格,不另造图)
let offset=0,total=0,facets=null,current=null,detailReturnPath='/',activeQueue=null;
let detailOriginAnchor=null,detailOriginAbove=false,detailReturnNeedsRestore=false;
@@ -2694,8 +2706,10 @@ let density=localStorage.getItem('density')||'big';
映射(PHOTO_SIZES 的第三位),按下去跟着换成当前状态的图标。 */
function syncDensityIcon(size){
const button=$('#density');if(!button)return;
- const glyph=PHOTO_SIZES.find(([key])=>key===size)?.[2];if(!glyph)return;
- button.querySelector('use')?.setAttribute('href',`#i-${glyph}`);
+ const [big,small]=PHOTO_SIZES;
+ if(!button.querySelector('[data-icon-swap]')){
+ button.innerHTML=iconSwapHtml(big[2],small[2],size===small[0]?'b':'a');
+ }else setIconSwap(button,size===small[0]?'b':'a');
button.setAttribute('aria-label',size==='big'?'切换为小图':'切换为大图')}
function applyDensity(){document.documentElement.style.setProperty('--tile',TILES[density]);
document.body.dataset.density=density;
@@ -3097,7 +3111,7 @@ function cardIdentity(it,linked=true){
// 会在普通卡片里折成三行;「第一位 + 等 N 人」仍能说明身份与规模。
const coStarred=performers.length>1&&!primaryCreator;
const avatar=coStarred
- ? `<div class="mavstack">${performers.slice(0,3)
+ ? `<div class="mavstack">${performers.slice(0,5)
.map((nm,i)=>link('mav',`data-entity-kind="performer" data-entity-name="${esc(nm)}" title="打开${esc(performerLabel(it))}页:${esc(nm)}"`,avatarInner(nm,performerRefs[i],REP[nm])))
.join('')}</div>`
: (()=>{
@@ -4734,7 +4748,7 @@ async function openPlaylists(push=true){
?`<img class="poster" src="/poster?id=${list.preview_asset_id}&c=4" alt="" loading="lazy" data-drop="self">`
:'<span class="nopic">无预览</span>';
const faces=(list.faces||[]).length
- ? `<div class="mavstack">${list.faces.map(face=>`<button class="mav entitylink"
+ ? `<div class="mavstack">${list.faces.slice(0,5).map(face=>`<button class="mav entitylink"
data-entity-kind="${esc(face.kind)}" data-entity-name="${esc(face.name)}"
title="打开资料页:${esc(face.name)}">${avatarInner(face.name,face,REP[face.name],face.kind)}</button>`).join('')}</div>`
: `<span class="mav"><span class="ini">${esc(list.name.slice(0,1))}</span></span>`;
@@ -8380,6 +8394,7 @@ function renderSearchMenu(){const menu=$('#searchMenu'),query=$('#q').value.trim
})}
function runSearch(useSuggestion=false,committed=false){let query=$('#q').value.trim();
if(useSuggestion&&!query){query=$('#q').dataset.suggestion||'';$('#q').value=query}
+ rememberSearchValue();
if(committed)rememberSearch(query);
disposeStage(false);
state.q=query;route(state.q?'/?q='+encodeURIComponent(state.q):'/',true);load(true)}
@@ -8404,13 +8419,30 @@ const refreshSearchMenu=()=>{searchActive=-1;
/* 回调回来时焦点可能已经不在输入框上:失焦那条 140ms 的兜底先把下拉栏收了,
晚到的 then 再把它掀开,而这一刻没有焦点,也就再不会有第二次失焦来收场。 */
if(document.activeElement===$('#q'))renderSearchMenu()}),SUGGEST_DEBOUNCE)};
-$('#q').oninput=e=>{if(e.isComposing)return;refreshSearchMenu()};
-$('#q').oncompositionend=refreshSearchMenu;
+const handleSearchInput=e=>{
+ if(e.isComposing)return;
+ const input=$('#q'),next=input.value;
+ if(!next&&searchValueSnapshot.text)clearSearchField(searchValueSnapshot);
+ else{
+ if(next){cancelSearchDissolve();cancelSearchDissolve=()=>{}}
+ rememberSearchValue(input);
+ }
+ refreshSearchMenu();
+};
+$('#q').oninput=handleSearchInput;
+$('#q').addEventListener('compositionend',handleSearchInput);
+$('#q').addEventListener('compositionstart',()=>{cancelSearchDissolve();cancelSearchDissolve=()=>{}});
+$('#q').addEventListener('beforeinput',e=>{if(!e.isComposing)rememberSearchValue(e.currentTarget)});
+$('#q').addEventListener('scroll',e=>{if(e.currentTarget.value)rememberSearchValue(e.currentTarget)});
+$('#q').addEventListener('pointerdown',e=>{if(e.currentTarget.value)rememberSearchValue(e.currentTarget)});
$('#q').onkeydown=e=>{
/* 组字过程中的方向键在挑候选字、回车在定字,都不是给这个菜单的。 */
if(e.isComposing)return;
- if(e.key==='Escape'&&!$('#searchMenu').hidden){
- hideSearchMenu();searchActive=-1;e.preventDefault();return;
+ if(e.key==='Escape'){
+ const hadValue=!!$('#q').value,hadMenu=!$('#searchMenu').hidden;
+ if(hadMenu){hideSearchMenu();searchActive=-1;e.preventDefault();return}
+ if(hadValue){clearSearchField({text:$('#q').value,scrollLeft:$('#q').scrollLeft||searchValueSnapshot.scrollLeft});
+ searchActive=-1;e.preventDefault();refreshSearchMenu();return}
}
if(e.key==='ArrowDown'||e.key==='ArrowUp'){
if(moveSearchActive(e.key==='ArrowDown'?1:-1))e.preventDefault();
@@ -8423,7 +8455,7 @@ $('#q').onkeydown=e=>{
hideSearchMenu();
// 选中的是一部作品时回车就开它,和点它一样,不绕一趟搜索。
if(picked&&picked.dataset.openItem){$('#q').blur();openItem(+picked.dataset.openItem);return}
- if(picked)$('#q').value=picked.dataset.searchValue;
+ if(picked){$('#q').value=picked.dataset.searchValue;rememberSearchValue()}
// 选中某一项时用它原样搜索;没选中才回退到「空输入按 Enter 用推荐词」。
runSearch(!picked,true);
$('#q').blur();
@@ -9654,7 +9686,7 @@ function openCatalog(path){
dur_min:params.get('dur_min')||'',dur_max:params.get('dur_max')||'',orient:params.get('orient')||'',
state:ROUTE_STATES[path]||params.get('state')||'',...resolveSort(params.get('sort'),params.get('dir')),
seed:params.get('seed')||(enteringHome?rollSeed():state.seed||rollSeed()),q:params.get('q')||'',jav:params.get('jav')||''};
- $('#q').value=state.q;buildEdge();buildBars();load(true);
+ $('#q').value=state.q;rememberSearchValue();buildEdge();buildBars();load(true);
}
/* 回收站。它和目录页共用同一张网格,只是筛选被钉死成 `trash`。 */
function openTrash(push){
diff --git a/web/board.css b/web/board.css
index 446c08296..1f5d9ef60 100644
--- a/web/board.css
+++ b/web/board.css
@@ -827,7 +827,7 @@ body>.board-filter-frame{margin-inline:16px}
带超调——徽标从零长到原大小,匀速收尾读成「被撑开的」,过一点再收住才读成「弹出来的」。
缓动不同就不能借 `--motion-reveal`:那两档的缓动写在 token 里,动画里再写第二条
缓动是无效声明,整条 `animation` 会被丢掉。 */
-:root{--motion-swap:.25s cubic-bezier(.4,0,.2,1);--motion-reveal:.4s cubic-bezier(.4,0,.2,1);--motion-stagger:70ms;--motion-pop:.4s cubic-bezier(.34,1.36,.64,1)}
+:root{--motion-swap:.25s cubic-bezier(.4,0,.2,1);--motion-count:.25s cubic-bezier(.34,1.45,.64,1);--motion-reveal:.4s cubic-bezier(.4,0,.2,1);--motion-stagger:70ms;--motion-pop:.4s cubic-bezier(.34,1.36,.64,1)}
body{font-size:14px;line-height:20px}
button,input,select,textarea{font-family:inherit}
.index .ihead{padding:4px;gap:12px;min-width:0;flex-wrap:wrap}
@@ -908,7 +908,7 @@ html.board-high-contrast .settingscard.settingscard>.board-local-nav{background:
.settingscard .settingsscroll .gselect,.settingscard .settingsscroll .gselectfield{height:40px;font-size:14px}
.settingscard .settingsscroll .board-number-control>span{font-size:14px}
}
-@media(prefers-reduced-motion:reduce){:root{--board-motion:0s;--board-dialog-motion:0s;--spring-pane-ms:0;--spring-press-ms:0;--motion-swap:0s;--motion-reveal:0s;--motion-stagger:0ms;--motion-pop:0s}.settingscard .settingshead::after{transition:none}}
+@media(prefers-reduced-motion:reduce){:root{--board-motion:0s;--board-dialog-motion:0s;--spring-pane-ms:0;--spring-press-ms:0;--motion-swap:0s;--motion-count:0s;--motion-reveal:0s;--motion-stagger:0ms;--motion-pop:0s}.settingscard .settingshead::after{transition:none}}
/* Stat Cards 的内层读数与底栏;统计卡仍是可键盘切换的视图入口。 */
/* 侧栏分组使用标题行与带计数的叶项。 */
.drawer.drawer{display:flex;flex-direction:column;overflow:hidden}
diff --git a/web/css/12-cards.css b/web/css/12-cards.css
index 2291ca85e..14d36197e 100644
--- a/web/css/12-cards.css
+++ b/web/css/12-cards.css
@@ -364,14 +364,18 @@ body[data-density="dense"] .junkcard .junkactions button span{display:none}
.mav img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block}
.mav .ini{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
font-size:var(--fs-sm);color:var(--muted);font-family:Bahnschrift,"Microsoft YaHei UI","Microsoft YaHei","PingFang SC",sans-serif}
-/* 共演头像叠放:靠左的在上层,hover 时抬到最前,保证每一位都点得到。 */
-.mavstack{display:flex;flex:none;margin-top:2px}
+/* 共演头像最多五枚,常态紧叠;上、左、下三边给放大与焦点环留出空间,头像本身仍与单人
+ 头像站在同一条左对齐线上。 */
+.mavstack{display:flex;flex:none;max-width:calc(100% - 48px);margin:-4px -2px -2px;padding:6px 2px 2px 5px}
.mavstack .mav{margin-top:0;box-shadow:0 0 0 2px var(--ground)}
-.mavstack .mav+.mav{margin-left:-14px}
-.mavstack .mav:nth-child(1){z-index:3}
-.mavstack .mav:nth-child(2){z-index:2}
-.mavstack .mav:nth-child(3){z-index:1}
-.mavstack .mav:hover{z-index:4;box-shadow:0 0 0 2px var(--ink-2)}
+.mavstack .mav+.mav{margin-left:-22px}
+.mavstack .mav:nth-child(1){z-index:5}
+.mavstack .mav:nth-child(2){z-index:4}
+.mavstack .mav:nth-child(3){z-index:3}
+.mavstack .mav:nth-child(4){z-index:2}
+.mavstack .mav:nth-child(5){z-index:1}
+.mavstack .mav:nth-child(n+6){display:none}
+.mavstack .mav:is(:hover,:focus-visible){z-index:6;box-shadow:0 0 0 2px var(--ink-2)}
.meta .whomore{color:var(--muted)}
.mtext{display:flex;flex-direction:column;gap:3px;min-width:0;flex:1}
/* 高度另用 max-height 封在两行:标题里的番号块是 inline-flex,WebKit 的 line-clamp 遇到非行内的
diff --git a/web/css/15-detail.css b/web/css/15-detail.css
index 2c2b6bcf4..c6be05daf 100644
--- a/web/css/15-detail.css
+++ b/web/css/15-detail.css
@@ -153,11 +153,10 @@
整条横向带被最高的一张顶起来、矮的下面全是空。窄卡只放两个头像,元数据钉成一行不换行:
大小和观看次数干脆不放,推荐理由留着截尾——那才是这条带存在的理由。
不能用固定高度加 overflow 去裁:`.s` 的行高和 gap 凑不出整行,第三行会露半截字。 */
-.ncard .mavstack .mav:nth-child(3),
-.sgrid.mixgrid>.mixqueue .mavstack .mav:nth-child(3){display:none}
+.ncard .mavstack .mav:nth-child(n+3),
+.sgrid.mixgrid>.mixqueue .mavstack .mav:nth-child(n+3){display:none}
.ncard .meta .s{flex-wrap:nowrap;overflow:hidden}
.ncard .meta .who{flex:0 1 auto;max-width:55%}
.ncard .meta .whomore{flex:none;white-space:nowrap}
.ncard .meta .why{flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ncard .meta .size,.ncard .meta .watchcount{display:none}
-
diff --git a/web/css/25-motion.css b/web/css/25-motion.css
index 32eeae6dc..2efb437aa 100644
--- a/web/css/25-motion.css
+++ b/web/css/25-motion.css
@@ -41,7 +41,7 @@
to{opacity:1;filter:blur(0);transform:none}}
.digits{display:inline-flex;align-items:baseline}
.digits>span{display:inline-block;white-space:pre}
-.digits.popping>span{animation:digit-pop-in var(--motion-swap) cubic-bezier(.34,1.45,.64,1) both;
+.digits.popping>span{animation:digit-pop-in var(--motion-count) both;
animation-delay:calc(var(--motion-stagger) * var(--digit-at,0))}
/* ── 占位换成真内容 ──
@@ -102,20 +102,23 @@
只能并进同一条列表。 */
:is(#tiers .tier,.followauthors,.followworks,.mavstack){
--lift-motion:calc(var(--spring-press-ms) * 1ms) var(--spring-press)}
-:is(#tiers .tier,.followauthors,.followworks,.mavstack):has(:hover){--lift-motion:var(--board-motion)}
+:is(#tiers .tier,.followauthors,.followworks,.mavstack):has(:is(:hover,:focus-visible)){--lift-motion:var(--board-motion)}
:is(#tiers,.followauthors,.followworks) :is(.av,.brandpill),.mavstack .mav{
transform:translate(var(--lift-x,0),var(--lift-y,0)) scale(var(--lift-scale,1))}
.mavstack .mav{transition:transform var(--lift-motion,var(--board-motion))}
-:is(#tiers .tier,.followauthors,.followworks) :is(.av,.brandpill):hover,
-.mavstack .mav:hover{--lift-y:-4px;--lift-scale:1.05}
-:is(#tiers .tier,.followauthors,.followworks) :is(.av,.brandpill):hover+:is(.av,.brandpill),
-:is(#tiers .tier,.followauthors,.followworks) :is(.av,.brandpill):has(+:is(.av,.brandpill):hover){--lift-y:-1.8px}
-:is(#tiers .tier,.followauthors,.followworks) :is(.av,.brandpill):hover+:is(.av,.brandpill)+:is(.av,.brandpill),
-:is(#tiers .tier,.followauthors,.followworks) :is(.av,.brandpill):has(+:is(.av,.brandpill)+:is(.av,.brandpill):hover){--lift-y:-.81px}
-.mavstack .mav:hover+.mav{--lift-y:-1.8px;--lift-x:7px}
-.mavstack .mav:hover+.mav+.mav{--lift-y:-.81px;--lift-x:10px}
-.mavstack .mav:has(+.mav:hover){--lift-y:-1.8px;--lift-x:-7px}
-.mavstack .mav:has(+.mav+.mav:hover){--lift-y:-.81px;--lift-x:-10px}
+:is(#tiers .tier,.followauthors,.followworks) :is(.av,.brandpill):is(:hover,:focus-visible),
+.mavstack .mav:is(:hover,:focus-visible){--lift-y:-4px;--lift-scale:1.05}
+:is(#tiers .tier,.followauthors,.followworks) :is(.av,.brandpill):is(:hover,:focus-visible)+:is(.av,.brandpill),
+:is(#tiers .tier,.followauthors,.followworks) :is(.av,.brandpill):has(+:is(.av,.brandpill):is(:hover,:focus-visible)){--lift-y:-1.8px}
+:is(#tiers .tier,.followauthors,.followworks) :is(.av,.brandpill):is(:hover,:focus-visible)+:is(.av,.brandpill)+:is(.av,.brandpill),
+:is(#tiers .tier,.followauthors,.followworks) :is(.av,.brandpill):has(+:is(.av,.brandpill)+:is(.av,.brandpill):is(:hover,:focus-visible)){--lift-y:-.81px}
+/* 叠放头像的左缘不动,只让右侧邻座朝标题方向逐枚让开;折叠时每枚前进 16px,展开后
+ 恢复成 26px 的可辨步长,五枚连同左侧安全距仍收在 168px 密集卡内。键盘焦点与指针
+ 使用同一套几何。 */
+.mavstack .mav:is(:hover,:focus-visible)+.mav{--lift-y:-1.8px;--lift-x:10px}
+.mavstack .mav:is(:hover,:focus-visible)+.mav+.mav{--lift-y:-.81px;--lift-x:20px}
+.mavstack .mav:is(:hover,:focus-visible)+.mav+.mav+.mav{--lift-x:30px}
+.mavstack .mav:is(:hover,:focus-visible)+.mav+.mav+.mav+.mav{--lift-x:40px}
/* ── 清空时输入的内容溶解掉 ──
输入框自己的 value 是一瞬间没的,没有动画可挂。所以清空前先照着输入框的位置和字体
@@ -125,9 +128,11 @@
上游还在同一条配方里给每个词铺一层 radial-gradient 做扫光,那部分要逐帧写背景才
画得出来,这里不做:搜索框每清一次就跑一段逐帧 JS,换来的是一道一眼看不出来的光。 */
@keyframes clear-dissolve{to{opacity:0;filter:blur(2px);transform:translateY(-12px)}}
-.cleardissolve{position:absolute;z-index:1;display:flex;align-items:center;overflow:hidden;
+.cleardissolve{position:absolute;z-index:2;display:flex;align-items:center;overflow:hidden;
white-space:nowrap;pointer-events:none;color:inherit;
animation:clear-dissolve var(--motion-reveal) forwards}
+.cleardissolve>[data-dissolve-value]{display:block;min-width:max-content;will-change:transform}
+.search input.dissolving::placeholder{opacity:0}
/* ── 计数徽标弹出来 ──
从零长到原大小,同时从模糊里清晰起来。整枚一起弹,不按位拆:这一枚说的是「这里有
diff --git a/web/js/ui-components.js b/web/js/ui-components.js
index 89b71c695..a617d1b5a 100644
--- a/web/js/ui-components.js
+++ b/web/js/ui-components.js
@@ -128,26 +128,44 @@ export function revealSkeleton(container,write){
* 的字,让那一份去飘,真正的输入框当场就空了,光标和输入法一刻也不等。`host` 缺省取
* 输入框的父元素,它必须是定位祖先,否则这一层会飘到页面左上角去。
*/
-export function dissolveValue(input,host=input&&input.parentElement){
- if(!input||!host)return;
- const text=input.value;
+export function dissolveValue(input,host=input&&input.parentElement,
+ {text=input&&input.value,scrollLeft=input&&input.scrollLeft||0}={}){
+ if(!input||!host)return ()=>{};
+ host.querySelectorAll(':scope > .cleardissolve').forEach(node=>node.remove());
+ input.classList.remove('dissolving');
input.value='';
- if(!text||!input.isConnected)return;
+ if(!text||!input.isConnected)return ()=>{};
const box=input.getBoundingClientRect(),frame=host.getBoundingClientRect();
- if(!box.width)return;
+ if(!box.width)return ()=>{};
const ghost=document.createElement('span');
ghost.className='cleardissolve';
ghost.setAttribute('aria-hidden','true');
- ghost.textContent=text;
+ const value=document.createElement('span');
+ value.dataset.dissolveValue='';
+ value.textContent=text;
+ value.style.transform=`translateX(-${Math.max(0,scrollLeft)}px)`;
+ ghost.append(value);
const style=getComputedStyle(input);
- Object.assign(ghost.style,{left:`${box.left-frame.left}px`,top:`${box.top-frame.top}px`,
- width:`${box.width}px`,height:`${box.height}px`,font:style.font,letterSpacing:style.letterSpacing});
+ Object.assign(ghost.style,{left:`${box.left-frame.left-host.clientLeft}px`,
+ top:`${box.top-frame.top-host.clientTop}px`,width:`${box.width}px`,height:`${box.height}px`,
+ boxSizing:'border-box',padding:style.padding,font:style.font,lineHeight:style.lineHeight,
+ letterSpacing:style.letterSpacing,textAlign:style.textAlign,direction:style.direction});
+ input.classList.add('dissolving');
host.append(ghost);
- const drop=()=>ghost.remove();
- ghost.addEventListener('animationend',drop,{once:true});
+ let active=true,timer=null;
+ const drop=()=>{
+ if(!active)return;
+ active=false;
+ if(timer!==null)clearTimeout(timer);
+ ghost.removeEventListener('animationend',drop);
+ ghost.remove();
+ if(!host.querySelector(':scope > .cleardissolve'))input.classList.remove('dissolving');
+ };
+ ghost.addEventListener('animationend',drop);
/* 兜底:`--motion-reveal` 归零或这一刻元素不可见时 `animationend` 不会来,
不兜的话这份复制品就永远盖在输入框上。 */
- setTimeout(drop,1000);
+ timer=setTimeout(drop,1000);
+ return drop;
}
/* 计数徽标上一次是多少。徽标所在的那一排每次筛选都整块重画,节点本身留不住上一个值,