Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 保持大图库键盘导航与等待态布局

longmeidao5c5c966b6284
diff --git a/README.en.md b/README.en.md
index ddc2cae66..9c2bc36a5 100644
--- a/README.en.md
+++ b/README.en.md
@@ -70,6 +70,7 @@ Want to look around before installing? The [live demo](https://demo.peach.video)
- **Filling in details**: by video code, Peach fills in titles, performers, studios and high-resolution covers from studio sites, DMM, JavBus, JavDB and others. It only fills empty fields and never overwrites your edits.
- **Playback**: play in the browser and pick up where you left off. Like, rate, save for later, add to a playlist, or "log a climax".
- **New releases**: subscribe on a performer page or by name in follow management, including performers not yet in your library. Peach checks for new titles regularly. Follow creators across sites such as FANBOX, Patreon and Kemono; the same work on different sites appears as one card.
+- **Online creators**: creator pages show local works and online updates separately, with video and image views and filters. Choose and crop an avatar from social profiles, online covers or post images, or use a local image or image URL.
- **JAV intake**: mark a new-release card or followed post as wanted, or enter a video code. Work cards find and deduplicate links from JavDB's resource list and comments, showing attributes, size and date. Add magnets directly to 115 or PikPak, or copy other links. Files scanned into your library are marked as acquired; titles set aside can be searched again.
- **Cloud download**: open Cloud download from JAV intake or a quality goal, paste a magnet link and hand it to 115 or PikPak for offline download; the finished file joins your library on its own. Progress shows up in Activity.
- **Find a release**: add your own Prowlarr or Jackett indexer under Downloads in local configuration, then search by release code in the Cloud download dialog. Filter by size and prioritize resolution, Chinese subtitles, or uncensored editions; select a candidate and confirm submission.
diff --git a/frontend/e2e/follow-detail.test.ts b/frontend/e2e/follow-detail.test.ts
index 1ae25e86b..21a297822 100644
--- a/frontend/e2e/follow-detail.test.ts
+++ b/frontend/e2e/follow-detail.test.ts
@@ -125,7 +125,23 @@ describe('关注详情岛', () => {
for (const one of document.querySelectorAll('[data-skeleton="detail"]')) if (!one.closest('#stage')) seen.outside = true;
}).observe(document, { childList: true, subtree: true });
});
- await page.reload({ waitUntil: 'load' });
+ let releaseItem = () => {};
+ const itemWait = new Promise<void>((resolve) => { releaseItem = resolve; });
+ await page.route((url) => url.pathname === '/api/follow' && url.searchParams.has('item'), async (route) => {
+ await itemWait;
+ await route.fallback();
+ });
+ try {
+ await page.reload({ waitUntil: 'load' });
+ const media = page.locator('#stage [data-skeleton="detail"] [data-stage-media]');
+ await media.waitFor();
+ const box = await media.boundingBox();
+ assert.ok(box && box.height > 120, `详情等待画面高度不足:${JSON.stringify(box)}`);
+ assert.equal(await page.locator('#stage [data-skeleton="detail"] [data-stage-side-content]')
+ .evaluate((node) => getComputedStyle(node).rowGap), '12px');
+ } finally {
+ releaseItem();
+ }
await page.locator(DETAIL_READY).waitFor({ timeout: 15_000 });
assert.equal(await page.evaluate(() => (window as unknown as { detailSkeletonSeen: { outside: boolean } })
.detailSkeletonSeen.outside), false, '刷新时浮窗外先画了一份详情骨架');
@@ -274,6 +290,26 @@ describe('关注详情岛', () => {
}
});
+ it('二十一张图使用计数条时,键盘左右仍切图并循环,地址保持当前帖子', { timeout: 60_000 }, async () => {
+ const opened = await openDetail(browser, DETAIL.largeGallery);
+ try {
+ const page = opened.page;
+ const poster = page.locator('#stage [data-follow-detail-poster]');
+ assert.equal(await page.locator('#stage [data-follow-image-dots]').count(), 0);
+ for (const [key, index] of [['ArrowRight', 1], ['ArrowLeft', 0], ['ArrowLeft', 20]] as const) {
+ await page.keyboard.press(key);
+ await page.waitForFunction((wanted) => document.querySelector('#stage [data-follow-detail-poster]')
+ ?.getAttribute('src') === wanted, `/follow-stream?id=5002&media=${index}`);
+ assert.equal(await poster.getAttribute('src'), `/follow-stream?id=5002&media=${index}`);
+ assert.equal((await page.locator('#stage [data-follow-image-count]').innerText()).trim(), `${index + 1} / 21`);
+ }
+ assert.equal(new URL(page.url()).pathname, '/follow/item/5002');
+ assert.deepEqual(opened.problems, []);
+ } finally {
+ await opened.close();
+ }
+ });
+
it('隐藏这张图退到恢复带,从恢复带点回来又回到轮播', { timeout: 60_000 }, async () => {
const opened = await openDetail(browser, DETAIL.hidden);
try {
diff --git a/frontend/e2e/follow-fixture.ts b/frontend/e2e/follow-fixture.ts
index 166d0f3fa..4444f0236 100644
--- a/frontend/e2e/follow-fixture.ts
+++ b/frontend/e2e/follow-fixture.ts
@@ -72,11 +72,12 @@ const gallery = (id: number, count: number, title: string) => item(id, 1, {
});
/** 多图轮播、视频合集(另一版加另一站的同一条)、一帖多媒体、带两张已隐藏图的帖子、一条
* 没有任何预览、标签六种类型各一枚的帖子,以及摘要、标题与媒体报错都是不换行长串的帖子。 */
-export const DETAIL = { gallery: 5001, collection: 5101, media: 5201, hidden: 5301, bare: 5401, long: 5501 } as const;
+export const DETAIL = { gallery: 5001, largeGallery: 5002, collection: 5101, media: 5201, hidden: 5301, bare: 5401, long: 5501 } as const;
const UNBROKEN = 'abcdef0123456789'.repeat(12);
const TYPED_TAGS = { ow: 'copyright', tracer: 'character', kou: 'artist', solo: 'general', animated: 'metadata', odd: 'unknown' };
const DETAIL_GROUPS = [
group(gallery(5001, 3, '三张图的帖子 5001')),
+ group(gallery(5002, 21, '二十一张图的帖子 5002')),
{
...group(item(5101, 0, { title: '合集主条目 5101' })), providers: ['kemono', 'rule34xxx'],
variants: [item(5102, 0, { title: '合集另一版 5102', variant_kind: 'alt', variant_label: '4K',
diff --git a/frontend/src/board-skeleton.ts b/frontend/src/board-skeleton.ts
index 2090cddf6..487e354db 100644
--- a/frontend/src/board-skeleton.ts
+++ b/frontend/src/board-skeleton.ts
@@ -82,7 +82,7 @@ const followList = (options: FollowSkeletonOptions) => {
/** 详情骨架外层 `[data-skeleton="detail"]` 里面那一格:舞台岛自己画外层,里面照这一份写。格子与详情栏
* 的几何是舞台的(`react/stage/stage.css`),骨架的底色与行距是壳的 `skeleton` 一族。 */
export function detailSkeletonBody(): string {
- return `<div data-stage-grid="" aria-hidden="true"><div data-stage-media="" class="skeleton-detail-media skeleton"></div><aside data-stage-side=""><div data-stage-side-content="" class="skeleton-lines">${line('85%')}${line('65%')}${repeat(lines(), 4)}</div></aside></div>`;
+ return `<div data-stage-grid="" aria-hidden="true"><div data-stage-media="" class="ui-skeleton-detail-media skeleton"></div><aside data-stage-side=""><div data-stage-side-content="" class="ui-skeleton-lines">${line('85%')}${line('65%')}${repeat(lines(), 4)}</div></aside></div>`;
}
export function boardPageSkeleton(
@@ -98,13 +98,13 @@ export function boardPageSkeleton(
} else if (path === '/configuration') {
body = configurationSkeleton();
} else if (path === '/activity') {
- body = `<div class="activitypage">${['正在进行', '被挡下的', '最近完成'].map(title => `<section class="activitysection"><h3 class="geist-fieldset-title">${title}</h3><div class="activity-runs"><article class="cleanupfieldset activity-run"><div class="geist-fieldset-content skeleton-lines">${line('35%')}${lines()}</div></article></div></section>`).join('')}</div>`;
+ body = `<div class="ui-activitypage">${['正在进行', '被挡下的', '最近完成'].map(title => `<section class="activitysection"><h3 class="geist-fieldset-title">${title}</h3><div class="ui-activity-runs"><article class="cleanupfieldset activity-run"><div class="geist-fieldset-content ui-skeleton-lines">${line('35%')}${lines()}</div></article></div></section>`).join('')}</div>`;
} else if (path === '/duplicates') {
body = duplicatesSkeleton();
} else if (path === '/quality-goals') {
body = qualityGoalsSkeleton();
} else if (path === '/playlists') {
- body = `<section class="playlistpage"><header><div><h2>播放列表</h2><p>保存 Mix,按自己的顺序继续播放。</p></div><div class="playlistcreate skeleton-lines"><span>新播放列表</span>${line('200px')}</div></header><div class="playlistcards">${repeat(`<article class="card playlistcard"><div class="mixstack"><div class="pic skeleton"></div></div><div class="mixmeta"><span class="mav skeleton"></span><div class="mixcopy skeleton-lines">${lines()}</div></div></article>`, 6)}</div></section>`;
+ body = `<section class="ui-playlistpage"><header><div><h2>播放列表</h2><p>保存 Mix,按自己的顺序继续播放。</p></div><div class="playlistcreate ui-skeleton-lines"><span>新播放列表</span>${line('200px')}</div></header><div class="ui-playlistcards">${repeat(`<article class="card playlistcard"><div class="mixstack"><div class="pic skeleton"></div></div><div class="mixmeta"><span class="mav skeleton"></span><div class="mixcopy ui-skeleton-lines">${lines()}</div></div></article>`, 6)}</div></section>`;
} else return '';
return `<div class="board-page-skeleton" data-skeleton="board${path}" role="status" aria-label="正在读取页面"><div aria-hidden="true" inert>${body}</div></div>`;
}
diff --git a/frontend/test/board-skeleton.test.ts b/frontend/test/board-skeleton.test.ts
index 36ff65565..2bd0a83a4 100644
--- a/frontend/test/board-skeleton.test.ts
+++ b/frontend/test/board-skeleton.test.ts
@@ -31,7 +31,7 @@ describe('Board 页面骨架', () => {
['/quality-goals', '.peach-react .card-grid-cover > li', 6],
['/follow-manage', '.peach-react .ui-follow-skeleton-surface .follow-skeleton-author', 3],
['/configuration', '.peach-react .configpage section', 2],
- ['/playlists', '.playlistcards > .playlistcard', 6],
+ ['/playlists', '.ui-playlistcards > .playlistcard', 6],
] as const)('%s 复用最终内容容器', (path, selector, count) => {
const root = document.createElement('div');
root.innerHTML = boardPageSkeleton(path);
diff --git a/web/app.js b/web/app.js
index cb052d243..d0b8f4c49 100644
--- a/web/app.js
+++ b/web/app.js
@@ -3498,12 +3498,9 @@ document.addEventListener('keydown',e=>{
}
// 输入态不抢键:搜索框、标签弹窗和任何可编辑区域里的按键归它们自己处理。
if(isTypingTarget(e.target)||e.ctrlKey||e.metaKey||e.altKey)return;
- const imageDots=[...document.querySelectorAll('#stage[open] [data-follow-image-dots] [data-follow-image-item]')];
- if(imageDots.length&&(e.key==='ArrowLeft'||e.key==='ArrowRight')){
- e.preventDefault();
- const current=Math.max(0,imageDots.findIndex(dot=>dot.getAttribute('aria-current')==='true'));
- imageDots[(current+(e.key==='ArrowRight'?1:-1)+imageDots.length)%imageDots.length].click();
- return;
+ if(e.key==='ArrowLeft'||e.key==='ArrowRight'){
+ const imageStep=document.querySelector(`#stage[open] [data-follow-image-step="${e.key==='ArrowRight'?1:-1}"]`);
+ if(imageStep){e.preventDefault();imageStep.click();return}
}
const video=activeVideo();
if(video){