Peach: Local-first video metadata scraper and media manager.
feat(web): 女优页照片档把样张平铺成一面墙
longmeidao7b7663e2940a
diff --git a/docs/BOARD_UI.md b/docs/BOARD_UI.mdindex 51b9e42a5..c1182a0e3 100644--- a/docs/BOARD_UI.md+++ b/docs/BOARD_UI.md@@ -324,7 +324,7 @@ Radio card 沿用 2026-09-08 取得的 `r/checkbox-card.json`(`checkbox-card.t| 资料卡 | 未取得(card/profile-card 404);卡形沿用 `.fsec`:secondary 底、18px 圆角、不描边、卡脚 `--board-card-foot` | `<section class="entityhero">`:`.entityprofile` 里 120px 头像加身份三行:名字 Title 3(24/32、500)、别名·视频数·事务所、外链排成 36px/10px 圆角的 secondary Button;同台艺人收进卡脚 `.entityfoot` 那条带,它是这个人的附注,不是正文;事务所的名册是正文,走 Tabs 里那一档。窄屏卡不变,只有卡里正文那一格改成单列居中、头像 96px || 视频/照片/艺人切换 | `tabs.tsx` 是页面级导航的形;这一组留在筛选浮层上,不取 Tabs | 浮层最左端的一组媒体圆键(`mediaViewButtonsHtml`,`aria-pressed`),选中那枚由圆玻璃 `viewglide-round` 滑过去标出,跟四枚观看状态各一块玻璃;隔一道竖杠再是观看状态、再一道才是标签。`boardTabsHtml()` 的下划线 Tabs 只给索引页切地址用 || 资料页筛选条 | 无对应 | 媒体圆键、四枚观看状态、标签三段由粗到细,`aria-label`「媒体与标签」;照片、名册视图下标签收起、竖杠隐去,圆键留着 |-| 资料页照片档 | 无对应;交互参考 beeg `?media=photos` 的图片集视图(集封面加张数,点开翻页),其余细节未取得 | 有本地图片或有番号样张就出照片键,键上数的是两者之和。墙上先是一排番号集卡 `.photosets`:复用播放列表卡(`.playlistcard` 的叠层纸边、右下角 `mixbadge`「N 张」、下面番号加标题与「DMM / FANZA 样张 · 发行日」两行),封面走视频卡的 `coverImage`;再是本地图片墙。点卡进样张墙,读数「番号 标题 · N 张」,左端「全部照片」返回,没有换一批与源文件工具;地址 `?media=photos&set=code:<番号>`。样张格取不到时只摘 `<img>`,格子留 `--sunk` 空底,瀑布流里按 3:2 撑住;灯箱详情写「来源 · 第 n / N 张 · 尺寸」(ADR-0068) |+| 资料页照片档 | 无对应;平铺是用户对照三种预览选定的(ADR-0068 修订) | 有本地图片或有番号样张就出照片键,键上数的是两者之和。样张不分组,按发行日从新到旧平铺在墙的最前面,每部第一张左上角一枚 `mixbadge` 写番号(挪到左上,让开右下的图内水印),后面接本地图片;读数「照片 · N 张 · 样张 M 张 · K 部作品」,只有样张时省掉第一段,也不出换一批。翻页只数本地图片。样张格取不到时只摘 `<img>`,格子留 `--sunk` 空底,瀑布流里按 3:2 撑住;灯箱详情写「来源 · 第 n / N 张 · 尺寸」(ADR-0068) || 关注页 | 无对应(上游没有更新流页) | 对齐首页,不另起一套;头像排、题材圆标取景、筛选浮层与排序见下方「关注页」小节 || 两页骨架 | Skeleton 只是占位形状 | 都把 `.board-filter-frame` 外框和上下两排的 `data-filter-row` 写全,否则等的那几秒钟是两块各带圆角的浮层;资料页骨架用 `.entityprofile`/`.entityidentity` 的真实类名,筛选条那排用 `data-skeleton-tier="pill"` 铺药丸 || 外链图标 | `avatar.tsx` 只有圆形;站标那一档无对应 | 资料卡外链按钮里的 favicon 与社媒标记 `.entitylinkicon` 收成 `--badge-radius` 的圆角方框,跟 20px 的图标位同形;外链一律 `target="_blank" rel="noreferrer"` |diff --git a/docs/PRODUCT_BACKLOG.md b/docs/PRODUCT_BACKLOG.mdindex fb4934bc1..a1209b15e 100644--- a/docs/PRODUCT_BACKLOG.md+++ b/docs/PRODUCT_BACKLOG.md@@ -13,7 +13,6 @@- Remix Icon 候选在预览页 `/icon-review.html` 审查,用户筛选完之前保留现有已选图标。- 安装后教程:右下角那张卡和清单渲染仍在 `web/app.js`,状态层(三个本地键、签名、请求代际)已在 `web/js/ui-components.js`。迁移时整块接管渲染,删掉遗留那一段。- 厂牌资料页视频视图卡片多时(如 Prestige,339 张卡),侧栏展开那一帧最长约 37ms。屏外卡已跳过封面与元信息区的渲染,剩下的开销在卡片盒本身的排版;作品区已在 `catalog-grid` island 里,要上虚拟列表就在岛里做。-- 资料页照片集卡(`.photosets`)仍借 `.playlistcard` 的遗留卡面,迁移时换掉,再删 `12-cards.css` 里那几条。## 已有骨架、尚未完成(7 项)diff --git a/docs/adr/0068-code-sample-images-group-the-photo-tab.md b/docs/adr/0068-code-sample-images-group-the-photo-tab.mdindex b116ab70d..09077c55f 100644--- a/docs/adr/0068-code-sample-images-group-the-photo-tab.md+++ b/docs/adr/0068-code-sample-images-group-the-photo-tab.md@@ -46,8 +46,12 @@ DMM 图片主机在部分国内出口不可达,所以页面从不直连上游**五、界面。** `/api/photos` 的 `sets` 前面是番号集(`kind: code`,id 是 `code:<番号>`,封面就是作品封面,张数是样张数,标题是番号加标题),后面是目录图集(`kind: dir`);`sample_total` 数样张,`total` 只数本地图片。-照片档在「有本地图片或有番号样张」时出现。墙上先是一排番号集卡,再是本地图片墙;点卡进这部作品的样张墙,-再点进现有 Swiper 灯箱。地址沿用 `?media=photos&set=<id>`。+照片档在「有本地图片或有番号样张」时出现。样张不分组:各部作品的样张按发行日从新到旧平铺在同一面墙的最前面,+每部第一张左上角标番号,后面接本地图片;整面墙共用一个 Swiper 灯箱,翻页只数本地图片。`?media=photos&set=<id>`+只认目录图集的整数 id,带番号集 id 的地址落在整面墙上。++**修订(2026-09-27)。** 用户对照三种预览后选定平铺:番号集卡要多点一层才看到图,平铺后打开照片档就是剧照。+`sets` 里的番号集仍按作品给出,前端据此排序、标番号和算读数。## 写真大图来源的核实结果diff --git a/frontend/e2e/code-samples.test.ts b/frontend/e2e/code-samples.test.tsindex 3986c8a5f..6ee122dca 100644--- a/frontend/e2e/code-samples.test.ts+++ b/frontend/e2e/code-samples.test.ts@@ -1,4 +1,4 @@-/* 女优资料页照片档的番号样张集(ADR-0068)。+/* 女优资料页照片档的番号样张(ADR-0068)。** 演示库没有人物实体,也没有样张:资料、照片清单、封面和样张图都由这里按接口的形状给,* 页面自己的路由、渲染、深链与灯箱照常跑。第 2 张样张故意回 404,验「取不到的那格留着占位、@@ -12,41 +12,57 @@ import { launch, settle, visit, VIEWPORTS, type Visit } from './harness.ts';const DESKTOP = VIEWPORTS.find((viewport) => !viewport.mobile)!;const NAME = '七沢みあ';-const SET_ID = 'code:SSIS-057';-// 1×1 的 PNG,封面与样张都用它:这里验的是结构与交互,不是图。+// 1×1 的 PNG,样张与本地图都用它:这里验的是结构与交互,不是图。const PIXEL = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==','base64');const MISSING = /\/sample-(?:thumb|image)\?code=SSIS-057&n=2$/;+const SETS = [+ { id: 'code:SSIS-057', kind: 'code', code: 'SSIS-057', name: '雨の日', title: 'SSIS-057 雨の日', n: 3,+ release_date: '2021-05-18', site: 'dmm', site_label: 'DMM', has_cover: true },+ { id: 'code:SSIS-001', kind: 'code', code: 'SSIS-001', name: '初夏', title: 'SSIS-001 初夏', n: 2,+ release_date: '2021-02-19', site: 'dmm', site_label: 'DMM', has_cover: true },+];-async function serveProfile(page: Page): Promise<void> {+type Local = { first: number; more: number };++/** `local` 给了就同时有本地图片:第一页 `first` 张、`has_more` 为真,翻页请求把 offset 记下来。 */+async function serveProfile(page: Page, local?: Local): Promise<number[]> {+ const offsets: number[] = [];+ const photo = (id: number) => ({ id, name: `${id}.jpg`, size: 1, location: 'media' });await page.route(/\/api\/entity\?/, (route) => route.fulfill({ json: {id: 90_001, kind: 'performer', canonical_name: NAME, aliases: [], display_aliases: [],user_aliases: [], asset_count: 0, tags: [], related_performers: [], links: [],metadata: {}, has_image: false, has_avatar: false, avatar_focus: null,representative_asset_id: null, entry_links: [], feed: { following: false },} }));- await page.route(/\/api\/photos\?/, (route) => route.fulfill({ json: {- kind: 'performer', name: NAME, entity_id: 90_001, total: 0, items: [], seed: '', has_more: false,- sample_total: 3,- sets: [{ id: SET_ID, kind: 'code', code: 'SSIS-057', name: '雨の日', title: 'SSIS-057 雨の日', n: 3,- release_date: '2021-05-18', site: 'dmm', site_label: 'DMM', has_cover: true }],- } }));- await page.route(/\/cover\?code=SSIS-057/, (route) =>+ await page.route(/\/api\/photos\?/, (route) => {+ const offset = Number(new URL(route.request().url()).searchParams.get('offset') || 0);+ if (offset) offsets.push(offset);+ const items = !local ? [] : offset+ ? Array.from({ length: local.more }, (_, i) => photo(100 + offset + i))+ : Array.from({ length: local.first }, (_, i) => photo(100 + i));+ return route.fulfill({ json: {+ kind: 'performer', name: NAME, entity_id: 90_001, total: local ? local.first + local.more : 0, items,+ seed: '', has_more: Boolean(local) && !offset, sample_total: 5, sets: SETS,+ } });+ });+ await page.route(/\/photo-thumb\?/, (route) =>route.fulfill({ status: 200, contentType: 'image/png', body: PIXEL }));await page.route(/\/sample-(?:thumb|image)\?/, (route) => MISSING.test(route.request().url())? route.fulfill({ status: 404, json: { error: 'unavailable' } }): route.fulfill({ status: 200, contentType: 'image/png', body: PIXEL }));+ return offsets;}-async function openPhotos(browser: Browser, search: string): Promise<Visit> {+async function openPhotos(browser: Browser, search: string, local?: Local): Promise<Visit & { offsets: number[] }> {const opened = await visit(browser, '/', DESKTOP);- await serveProfile(opened.page);+ const offsets = await serveProfile(opened.page, local);await opened.page.goto(new URL(`/performers/${encodeURIComponent(NAME)}?${search}`, opened.page.url()).href,{ waitUntil: 'load' });await opened.page.locator('#index .photohead').waitFor({ state: 'visible', timeout: 15_000 });await settle(opened.page);- return opened;+ return { ...opened, offsets };}/** 故意回 404 的那一张不算运行期问题,浏览器为它各记一条的控制台 404 也按条数扣掉;@@ -61,60 +77,69 @@ function unexpected(problems: string[]): string[] {});}-describe('番号样张集', () => {+const cellBadges = (page: Page) => page.locator('.photowall .photocell').evaluateAll((cells) =>+ cells.map((cell) => cell.querySelector('.mixbadge')?.textContent?.trim() || ''));++describe('番号样张', () => {let browser: Browser;before(async () => { browser = await launch(); });after(async () => { await browser?.close(); });- it('只有样张时照片档照样出现,墙上是一排番号集卡', async () => {+ it('只有样张时照片档照样出现,各部样张按发行日铺在一面墙上,每部第一张标番号', async () => {const opened = await openPhotos(browser, 'media=photos');const { page } = opened;try {assert.equal(await page.locator('.entitymediaview [data-media-view="photos"]').getAttribute('aria-pressed'),'true');- const card = page.locator('.photosets .codeset');- assert.equal(await card.count(), 1);- assert.match(await card.innerText(), /SSIS-057 雨の日/);- assert.match(await card.innerText(), /3 张/);- assert.match(await page.locator('.photohead h3').innerText(), /1 部作品样张/);+ assert.deepEqual(await cellBadges(page), ['SSIS-057', '', '', 'SSIS-001', '']);+ assert.match(await page.locator('.photohead h3').innerText(), /样张 5 张 · 2 部作品/);assert.equal(await page.locator('.photohead .entitybatch').count(), 0, '没有本地图可换一批');+ assert.equal(await page.locator('.photoback').count(), 0, '样张不另开一层');assert.deepEqual(unexpected(opened.problems), [], JSON.stringify(opened.problems));} finally {await opened.close();}});- it('点开一组进样张墙,地址带番号集 id,取不到的那格留着占位', async () => {+ it('取不到的那格留着占位和番号位置,灯箱按整面墙连续翻', async () => {const opened = await openPhotos(browser, 'media=photos');const { page } = opened;try {- await page.locator('[data-code-set]').click();- await page.waitForFunction(() => document.querySelectorAll('.photowall .photocell').length === 3);- assert.equal(new URL(page.url()).searchParams.get('set'), SET_ID);- assert.match(await page.locator('.photohead h3').innerText(), /SSIS-057 雨の日 · 3 张/);await page.waitForFunction(() => !document.querySelector('.photowall .photocell:nth-child(2) img'));const hole = await page.locator('.photowall .photocell').nth(1).boundingBox();assert.ok(hole && hole.height > 0, '占位格不塌');- await page.locator('.photowall .photocell').first().click();+ await page.locator('.photowall .photocell').nth(3).click();const count = page.locator('dialog.photolight .photocount');await count.waitFor({ state: 'visible' });- assert.equal((await count.innerText()).trim(), '1 / 3');+ assert.equal((await count.innerText()).trim(), '4 / 5');await page.locator('dialog.photolight .photoclose').click();- await page.locator('.photoback').click();- await page.locator('.photosets .codeset').waitFor({ state: 'visible' });- assert.equal(new URL(page.url()).searchParams.get('set'), null);assert.deepEqual(unexpected(opened.problems), [], JSON.stringify(opened.problems));} finally {await opened.close();}});- it('深链直接进样张墙', async () => {- const opened = await openPhotos(browser, `media=photos&set=${encodeURIComponent(SET_ID)}`);+ it('样张排在本地图片前面,翻页只数本地图片', async () => {+ const opened = await openPhotos(browser, 'media=photos', { first: 2, more: 1 });+ const { page } = opened;+ try {+ // 墙矮,「载入更多」一进视口就自己翻下一页:等两页都落定再读。+ await page.waitForFunction(() => document.querySelectorAll('.photowall .photocell').length === 8);+ assert.deepEqual(await cellBadges(page), ['SSIS-057', '', '', 'SSIS-001', '', '', '', '']);+ assert.equal(await page.locator('.photowall .photocell img[src^="/photo-thumb"]').count(), 3);+ assert.deepEqual(opened.offsets, [2]);+ assert.deepEqual(unexpected(opened.problems), [], JSON.stringify(opened.problems));+ } finally {+ await opened.close();+ }+ });++ it('带番号集 id 的旧地址退回整面照片墙', async () => {+ const opened = await openPhotos(browser, `media=photos&set=${encodeURIComponent('code:SSIS-057')}`);const { page } = opened;try {- assert.equal(await page.locator('.photowall .photocell').count(), 3);- assert.equal(await page.locator('.photoback').count(), 1);+ assert.equal(await page.locator('.photowall .photocell').count(), 5);+ assert.equal(await page.locator('.photoback').count(), 0);assert.deepEqual(unexpected(opened.problems), [], JSON.stringify(opened.problems));} finally {await opened.close();diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex ab1fc6846..9b4b87421 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -11014,7 +11014,7 @@ class WebUiSourceTests(unittest.TestCase):def test_photo_tab_opens_the_flat_wall_without_album_cover_cards(self):self.assertPageContains("if(media==='photos'){renderPhotoWall(kind,name,filters,entityPhotos);return}")self.assertPageContains("readout:back?`${esc(data.title)} · ${(data.total||0).toLocaleString()} 张`:photoReadout(data,codeSets)")- self.assertPageContains("/api/photos?kind=${encodeURIComponent(kind)}&name=${encodeURIComponent(name)}&limit=120&offset=${photoWallItems.length}")+ self.assertPageContains("/api/photos?kind=${encodeURIComponent(kind)}&name=${encodeURIComponent(name)}&limit=120&offset=${localPhotoCount()}")self.assertPageLacks("renderPhotoSets")self.assertPageLacks(".photosetcover{display:block;aspect-ratio:3/4")@@ -11024,14 +11024,14 @@ class WebUiSourceTests(unittest.TestCase):账本里图片只有文件名、体积和来源,视频那排排序键在这里没有对应的数。换一批跟视频那一排同一枚键、同一个位置;大小是列数,一次请求都不发。那排标签数的是视频,照片视图下收起来。等着的那一下骨架也带着下半,浮层不会缺一截。"""- self.assertPageContains("const photoHeadHtml=(data,{back=false,codeSets=[],sample=false}={})=>collectionHeaderHtml({className:'photohead'")+ self.assertPageContains("const photoHeadHtml=(data,{back=false,codeSets=[]}={})=>collectionHeaderHtml({className:'photohead'")self.assertPageContains("controls:sortControlsHtml({extra:photoControlsHtml()")self.assertPageLacks("photorefresh")self.assertPageContains("shufflePhotos(kind,name,filters,entityWide?0:data.id,event.currentTarget)")# 换过一批,后面几页沿用同一粒种子。self.assertPageContains("seed=data.seed?`&seed=${encodeURIComponent(data.seed)}`:'';")- self.assertPageContains("offset=${photoWallItems.length}${seed}`")+ self.assertPageContains("offset=${localPhotoCount()}${seed}`")# 大小:存进设置,改的只是那面墙上的一个属性。self.assertPageContains("photoSize:'small',")self.assertPageContains("wall.dataset.size=photoSize();wall.dataset.layout=wall.closest('.skeletonpanel')?'fixed':photoLayout()")diff --git a/web/app.js b/web/app.jsindex 497c43d60..ae188c48a 100644--- a/web/app.js+++ b/web/app.js@@ -6600,12 +6600,11 @@ async function updateEntityCollection(kind,name,filters,push=true){`web/css/08-photos.css` 里那条规则上面。缩略图一律走 `/photo-thumb`(服务端缓存),只有灯箱里的大图读 `/photo` 原图——PikPak 是计费来源,一屏直接铺原图等于付几十兆流量。- 番号样张是另一种分组:一部作品一组,集封面就是这部片的封面,点开是它的官方样张- (ADR-0068)。它的 set id 是 `code:<番号>`,和目录图集的整数 id 同走一个 `set=` 参数。 ── */+ 番号样张不分组:名下每部作品的官方样张按发行日从新到旧直接铺在墙的最前面,每部第一张+ 角上标番号(ADR-0068)。`set=` 参数只认目录图集的整数 id。 ── */function emptyMediaView(){return {media:'videos',set:0}}const parseMediaView=search=>{const params=new URLSearchParams(search),set=params.get('set')||'';- return {media:params.get('media')==='photos'?'photos':'videos',- set:/^\d+$/.test(set)?Number(set):/^code:[\w.-]+$/.test(set)?set:0}};+ return {media:params.get('media')==='photos'?'photos':'videos',set:/^\d+$/.test(set)?Number(set):0}};const entityViewSearch=(filters,view)=>{const params=new URLSearchParams(entityFilterSearch(filters));if(view&&view.media==='photos'){params.set('media','photos');if(view.set)params.set('set',String(view.set))}return params.toString()};@@ -6615,7 +6614,7 @@ const routeEntityView=(kind,name,view)=>{route(entityPath(kind,name)+(search?'?'+search:''))};const photoTotalOf=()=>entityPhotos&&!entityPhotos.error?(entityPhotos.total||0):0;const codeSetsOf=(data=entityPhotos)=>data&&!data.error?(data.sets||[]).filter(set=>set.kind==='code'):[];-// 照片档出不出看两样:本地有图,或者名下作品有官方样张。只有样张时整面墙就是那一排番号集。+// 照片档出不出看两样:本地有图,或者名下作品有官方样张。只有样张时整面墙就是样张。const photosAvailable=()=>photoTotalOf()>0||codeSetsOf().length>0;/* 这一页当前是哪个视图。名册和媒体不共用 `entityMediaView`:地址栏只认 `media`,@@ -6683,19 +6682,10 @@ function showAllPhotos(kind,name,filters,push=true){renderPhotoWall(kind,name,filters,entityPhotos);}-/* 番号集不再请求一次:张数、站名和标题已经随 `/api/photos` 下来,样张地址留在服务端,- 墙和灯箱只递番号与序号。地址栏里的番号不在这一页名下时退回整面照片墙。 */+/* 样张不再请求一次:张数、站名和标题已经随 `/api/photos` 下来,样张地址留在服务端,+ 墙和灯箱只递番号与序号。 */const codeSetItems=set=>Array.from({length:set.n},(_,i)=>({sample:true,code:set.code,position:i+1,total:set.n,name:`${set.code} 样张 ${i+1}`,source:set.site_label||'官方样张'}));-function openCodeSet(kind,name,filters,setId,push=true){- const set=codeSetsOf().find(item=>item.id===setId);- if(!set){showAllPhotos(kind,name,filters,push);return}- ++entityRequestSeq;- entityMediaView={media:'photos',set:setId};- if(push)routeEntityView(kind,name,entityMediaView);- renderEntityMediaToggle(kind,name,filters);- renderSampleWall(kind,name,filters,set);-}/* 换一批:换一粒种子把这一屏重排一遍,整组照片或单个图集都是。翻页沿用回话里带回的那一粒。等的这一下键上转圈,跟首页那枚一样;新的一面墙回来时整排连它一起重画。 */@@ -6753,25 +6743,18 @@ const photoCell=(item,index)=>`<button class="photocell" data-photo-index="${inddecoding="async" fetchpriority="low"data-drop="closest:.photocell"></button>`;/* 样张格取不到图时留在墙上,只摘掉 <img>:本地图片取不到说明文件没了,整格该走;样张- 取不到多半是来源这会儿不通,格子留着 `--sunk` 空底,序号不断,灯箱里照样翻得到。 */+ 取不到多半是来源这会儿不通,格子留着 `--sunk` 空底,序号不断,灯箱里照样翻得到。+ 每部作品的第一张角上标番号,用卡片上那枚角标:墙上各部挨着铺,这是分得清哪几张是+ 同一部的唯一记号;图没取到时番号照样留在空格上。 */const sampleQuery=item=>`code=${encodeURIComponent(item.code)}&n=${item.position}`;const sampleCell=(item,index)=>`<button class="photocell" data-photo-index="${index}" title="${esc(item.name)}"><img src="/sample-thumb?${sampleQuery(item)}" alt="${esc(item.name)}" loading="lazy"- decoding="async" fetchpriority="low" data-drop="self"></button>`;-/* 番号集一张卡:借播放列表卡的叠层纸边、右下角张数和下面两行字,它们回答的是同一件事- ——「这一张代表一组,里面有几个」。封面走视频卡同一份 `coverImage`,取景一致。 */-const codeSetCard=set=>{- const poster=set.has_cover?coverImage({code:set.code},'small',false):'<span class="nopic">无封面</span>';- const note=[set.site_label?`${set.site_label} 样张`:'官方样张',set.release_date].filter(Boolean).join(' · ');- return `<article class="card playlistcard codeset">- <div class="mixstack"><div class="pic" style="--card-ratio:${16/9}">${poster}- <button class="cardopenhit" data-code-set="${esc(set.id)}" aria-label="打开样张 ${esc(set.title)}"></button>- <span class="mixbadge">${icon('pics')}${set.n} 张</span></div></div>- <div class="mixmeta"><div class="mixcopy"><b>${esc(set.title)}</b><span>${esc(note)}</span></div></div></article>`;-};+ decoding="async" fetchpriority="low" data-drop="self">${item.position===1+ ?`<span class="mixbadge mono">${esc(item.code)}</span>`:''}</button>`;const photoReadout=(data,codeSets)=>'照片 · '+[data.total||!codeSets.length?`${(data.total||0).toLocaleString()} 张`:'',- codeSets.length?`${codeSets.length} 部作品样张`:''].filter(Boolean).join(' · ');+ codeSets.length?`样张 ${(data.sample_total||0).toLocaleString()} 张 · ${codeSets.length} 部作品`:'']+ .filter(Boolean).join(' · ');/* 照片这一栏跟视频那一栏是同一块浮层的下半,所以用同一个壳。换成别的容器的话,切一下媒体类型,浮层的下半就整块消失——上半的下沿留着两个直角,底下接着页面底色。@@ -6779,22 +6762,23 @@ const photoReadout=(data,codeSets)=>'照片 · '+[壳一样,里面装的不一样:这一排不给排序键。排序读的是每条记录上的值,而账本里图片只有文件名、体积和来源三样,视频那八个键有七个在这里没有对应的数。这一排只放三样:张数、换一批、大小。换一批跟首页和视频那一排是同一枚键、同一个位置、同一个意思。- 不点它时按文件名排:`001.jpg` 这类编号本来就是一套图的顺序。- 番号集那一面没有换一批也没有源文件工具:样张的顺序就是官方给的顺序,文件也不在本机。 */-const photoHeadHtml=(data,{back=false,codeSets=[],sample=false}={})=>collectionHeaderHtml({className:'photohead',+ 不点它时按文件名排:`001.jpg` 这类编号本来就是一套图的顺序。换一批只打散本地图片,+ 样张的顺序就是官方给的顺序,文件也不在本机。 */+const photoHeadHtml=(data,{back=false,codeSets=[]}={})=>collectionHeaderHtml({className:'photohead',before:back?`<button class="photoback" type="button">${icon('chevron-left')}<span>全部照片</span></button>`:'',readout:back?`${esc(data.title)} · ${(data.total||0).toLocaleString()} 张`:photoReadout(data,codeSets),- controls:sortControlsHtml({extra:photoControlsHtml()+(back&&!sample?sourceTools(data.id):'')})});+ controls:sortControlsHtml({extra:photoControlsHtml()+(back?sourceTools(data.id):'')})});+/* 墙上样张在前、本地图片在后,翻页只数本地图片:样张一次铺完,不走分页。 */+const localPhotoCount=()=>photoWallItems.filter(item=>!item.sample).length;function renderPhotoWall(kind,name,filters,data,append=false){const section=$('#index').querySelector('.entitysection');if(!section)return;if(!append)releaseEntityGrid();const entityWide=!data.id;if(!append){- photoWallItems=[];const codeSets=entityWide?codeSetsOf(data):[];+ photoWallItems=codeSets.flatMap(codeSetItems);section.innerHTML=photoHeadHtml(data,{back:!entityWide,codeSets})- +(codeSets.length?`<div class="grid photosets">${codeSets.map(codeSetCard).join('')}</div>`:'')- +`<div class="photowall" data-size="${photoSize()}"></div>+ +`<div class="photowall" data-size="${photoSize()}">${photoWallItems.map(sampleCell).join('')}</div><button class="entitymore" type="button">载入更多</button>`;const head=section.querySelector('.photohead');wirePhotoControls(head);syncPhotoWalls();@@ -6802,8 +6786,6 @@ function renderPhotoWall(kind,name,filters,data,append=false){if(data.total)head.querySelector('.entitybatch').onclick=event=>shufflePhotos(kind,name,filters,entityWide?0:data.id,event.currentTarget);else head.querySelector('.entitybatch').remove();- section.querySelectorAll('[data-code-set]').forEach(button=>- button.onclick=()=>openCodeSet(kind,name,filters,button.dataset.codeSet));if(!entityWide){head.querySelector('.photoback').onclick=()=>showAllPhotos(kind,name,filters);// 对账后整组数量都变了,重开这一组比逐格摘除简单也更不容易错。@@ -6824,26 +6806,11 @@ function renderPhotoWall(kind,name,filters,data,append=false){wireLoadMore(more,{isCurrent:()=>seq===entityRequestSeq&&$('#index').dataset.entityKind===kind&&$('#index').dataset.entityName===name,read:signal=>api(entityWide- ? `/api/photos?kind=${encodeURIComponent(kind)}&name=${encodeURIComponent(name)}&limit=120&offset=${photoWallItems.length}${seed}`- : `/api/photo-set?id=${data.id}&limit=120&offset=${photoWallItems.length}${seed}`,{signal}),+ ? `/api/photos?kind=${encodeURIComponent(kind)}&name=${encodeURIComponent(name)}&limit=120&offset=${localPhotoCount()}${seed}`+ : `/api/photo-set?id=${data.id}&limit=120&offset=${localPhotoCount()}${seed}`,{signal}),apply:next=>{if(next.error)throw new Error(next.error);renderPhotoWall(kind,name,filters,next,true)},});}-/* 一部作品的样张一次铺完:官方样张一部最多几十张,用不着分页。 */-function renderSampleWall(kind,name,filters,set){- const section=$('#index').querySelector('.entitysection');if(!section)return;- releaseEntityGrid();- photoWallItems=codeSetItems(set);- section.innerHTML=photoHeadHtml({title:set.title,total:set.n},{back:true,sample:true})- +`<div class="photowall" data-size="${photoSize()}">${photoWallItems.map(sampleCell).join('')}</div>`;- const head=section.querySelector('.photohead');- wirePhotoControls(head);syncPhotoWalls();- head.querySelector('.entitybatch').remove();- head.querySelector('.photoback').onclick=()=>showAllPhotos(kind,name,filters);- section.querySelectorAll('.photocell').forEach(cell=>- cell.onclick=()=>openPhotoLightbox(Number(cell.dataset.photoIndex)));- syncEntityFilterFrame();-}/* ── 源文件管理 ───────────────────────────────────────────────────────────────标题旁两个按钮,服务的是「跳过去自己整理网盘目录」这条来回:定位打开源文件所在@@ -7489,7 +7456,6 @@ async function openEntity(kind,name,push=true){renderEntityMediaToggle(kind,name,filters);if(entityViewNow(kind)==='people')renderEntityRoster(roster);else if(entityMediaView.media!=='photos')renderEntityCollection(kind,name,items,filters);- else if(typeof entityMediaView.set==='string')openCodeSet(kind,name,filters,entityMediaView.set,false);else if(entityMediaView.set)await openPhotoSet(kind,name,filters,entityMediaView.set,false);else renderPhotoWall(kind,name,filters,entityPhotos);buildBars();diff --git a/web/css/08-photos.css b/web/css/08-photos.cssindex 78c14746f..84950ad22 100644--- a/web/css/08-photos.css+++ b/web/css/08-photos.css@@ -11,7 +11,7 @@@media (max-width:1000px){.photowall{grid-template-columns:repeat(3,minmax(0,1fr))}.photowall[data-size="big"]{grid-template-columns:repeat(1,minmax(0,1fr))}}.photocell{display:block;width:100%;aspect-ratio:1;border:0;padding:0;margin:0;background:var(--sunk);- border-radius:var(--surface-radius);overflow:hidden;cursor:zoom-in;line-height:0}+ border-radius:var(--surface-radius);overflow:hidden;cursor:zoom-in;line-height:0;position:relative}/* 图还没到的格子是一块空底,不是一行文件名。`alt` 留着给读屏,但格子既然已经按比例占好了位置,浏览器就有地方把它画出来——一屏几十格全在等图时,看到的是满屏`118abp00325pl.jpg`。这块 `--sunk` 底本身就是这里的骨架。 */@@ -20,8 +20,10 @@/* 样张取不到时摘掉的只是 <img>,格子留着。瀑布流里格高来自图,空格会塌成 0,所以按官方样张最常见的横幅比例撑住那块 `--sunk` 底。 */[data-layout="masonry"]>.photocell:not(:has(img)){aspect-ratio:3/2}-/* 番号集那排卡片在本地图片墙上方,间距与卡片网格的行距相同。 */-.photosets{margin-bottom:24px}+/* 每部作品第一张样张的番号:卡片那枚角标挪到左上,让开右下角留给图本身的水印。+ 格子是 `line-height:0` 的替换元素容器,角标自己把行高要回来。 */+.photocell>.mixbadge{left:8px;top:8px;right:auto;bottom:auto;min-height:24px;padding:2px 8px;+ line-height:20px;pointer-events:none}/* 媒体圆钮只共享 48/24 的几何与图标居中;表面色由使用场景决定。 */.media-circle{box-sizing:border-box;width:48px;height:48px;padding:0;border:0;border-radius:50%;background:rgba(255,255,255,.1);color:#f1f1f1;display:grid;place-items:center;cursor:pointer}