Peach: Local-first video metadata scraper and media manager.
fix(web): 播放列表里换条后关掉回到列表页
longmeidao58cb3f8426bb
diff --git a/frontend/e2e/item-detail.test.ts b/frontend/e2e/item-detail.test.tsindex bf539ee95..b5886c380 100644--- a/frontend/e2e/item-detail.test.ts+++ b/frontend/e2e/item-detail.test.ts@@ -1,4 +1,5 @@-/* 作品详情岛(`item-detail`)在真浏览器里的行为:从目录卡进出、深链、舞台在媒体框里挂 Video.js、+/* 作品详情岛(`item-detail`)在真浏览器里的行为:从目录卡进出、深链、+ * 播放列表换条后关掉回列表页、舞台在媒体框里挂 Video.js、* 脱盘说明、共演收起、标题折叠、评分与标签的撤销、反馈键态、四种队列、播放列表排序与移出、保存 Mix、接着看、* 实体页入口与手机布局。*@@ -71,6 +72,58 @@ describe('作品详情岛', () => {}});+ it('播放列表里换条再关掉回到列表页并重读;后退回到其中一条再关掉也一样', { timeout: 90_000 }, async () => {+ const opened = await openItemPage(browser, '/', DESKTOP, { ready: `#grid [data-media-card][data-id="${ITEM.plain}"]` });+ try {+ const page = opened.page;+ let listed = 0;+ // 桩里的列表行没有续播位置,卡片不给打开键;这里补上停在第一条。+ await page.route((url) => url.pathname === '/api/playlists', (route) => {+ listed += 1;+ return route.fulfill({ json: { items: [{+ id: PLAYLIST.id, name: PLAYLIST.name, item_count: PLAYLIST.items.length,+ current_asset_id: PLAYLIST.items[0], preview_asset_id: PLAYLIST.items[0],+ }] } });+ });+ await page.goto(new URL('/playlists', page.url()).toString(), { waitUntil: 'load' });+ const card = page.locator(`[data-playlist-card="${PLAYLIST.id}"]`);+ const step = async (id: number) => {+ await page.locator(`#stage [data-queue-item="${id}"]`).click();+ await pathIs(page, `/playlists/${PLAYLIST.id}/${id}`);+ await page.locator(`#stage [data-queue-item="${id}"][aria-current="true"]`).waitFor();+ };+ const enter = async () => {+ await card.locator('[data-mix-open]').click();+ await pathIs(page, `/playlists/${PLAYLIST.id}/${PLAYLIST.items[0]}`);+ await page.locator(DETAIL_READY).waitFor();+ await step(PLAYLIST.items[1]!);+ await step(PLAYLIST.items[2]!);+ };+ const closeToList = async () => {+ const before = listed;+ await page.locator('#closeStage').click();+ await pathIs(page, '/playlists');+ await page.locator('#stage[open]').waitFor({ state: 'detached', timeout: 10_000 }).catch(() => {});+ await card.waitFor();+ assert.equal(await page.locator('#stage[open]').count(), 0);+ for (const deadline = Date.now() + 10_000; listed <= before && Date.now() < deadline;) await page.waitForTimeout(50);+ assert.ok(listed > before, '关掉之后列表页没有重读');+ };+ await card.waitFor({ timeout: 15_000 });+ await enter();+ await closeToList();+ await enter();+ await page.goBack();+ await pathIs(page, `/playlists/${PLAYLIST.id}/${PLAYLIST.items[1]}`);+ await page.locator(`#stage [data-queue-item="${PLAYLIST.items[1]}"][aria-current="true"]`).waitFor();+ await page.locator(DETAIL_READY).waitFor();+ await closeToList();+ assert.deepEqual(withoutPlayer(opened.problems), []);+ } finally {+ await opened.close();+ }+ });+it('舞台在媒体框里挂上 Video.js,氛围光画布与统计角标跟它进同一块媒体区', { timeout: 60_000 }, async () => {const opened = await openItemPage(browser, `/item/${ITEM.plain}`, DESKTOP);try {diff --git a/web/app.js b/web/app.jsindex 79a8c0a68..079bf0905 100644--- a/web/app.js+++ b/web/app.js@@ -3546,9 +3546,9 @@ const QUEUE_ROUTES={mix:'/mix',parts:'/parts',editions:'/editions',playlist:'/plfunction openQueue(kind,key,itemId,push,anchor=null){key=+key;const same=activeQueue?.kind===kind&&(kind==='playlist'?activeQueue.playlistId:activeQueue.seedId)===key;- if(push&&(kind==='playlist'||!same))detailReturnPath=location.pathname+location.search;- /* 队列地址取完数才推(`present`),背景按此刻记;同队列换条在详情地址上,沿用上一条的背景,- 播放列表也一样,不跟 `detailReturnPath` 走。 */+ /* 同一个队列里换条,来处保持打开队列那一刻的那一页:播放列表关掉回列表页并重读。 */+ if(push&&!same)detailReturnPath=location.pathname+location.search;+ /* 队列地址取完数才推(`present`),背景按此刻记;同队列换条在详情地址上,沿用上一条的背景。 */if(push)holdOverlayBackground();const queue=kind==='playlist'?{kind,playlistId:key,fresh:true}:{kind,seedId:key,fresh:!same};return openItem(itemId==null?null:+itemId,false,queue,anchor,push);