Peach: Local-first video metadata scraper and media manager.
fix(web): 分卷与版本叠层卡不再翻同一张图,纸边圆角随封面,关注卡条数只报一次
longmeidao690c0634106e
diff --git a/frontend/e2e/design.test.ts b/frontend/e2e/design.test.tsindex 964da9da5..ea1ffc2e6 100644--- a/frontend/e2e/design.test.ts+++ b/frontend/e2e/design.test.ts@@ -870,6 +870,40 @@ describe('设计决定', () => {}});+ it('分卷卡不翻卡、悬停走分段预览,叠层纸边和封面同一档圆角', { timeout: 60_000 }, async () => {+ /* 各卷共用同一个番号的封套,翻过去还是那张图。演示库没有分卷,给首张卡挂一个。 */+ const opened = await openCatalogFixture(browser, (payload) => {+ const [first, second] = payload.items;+ payload.items[0] = { ...first, part_group: {+ key: 'DEMO-PART', title: 'DEMO-PART', count: 2, seed_id: first.id,+ item_ids: [first.id, second.id], total_duration: 120, total_size: 1 } };+ });+ try {+ const shapeOf = (selector: string) => opened.page.locator(selector).first().evaluate((element) => {+ const stack = element.querySelector('.partstack,.mixstack')!;+ return {+ cover: getComputedStyle(element.querySelector('.pic')!).borderTopLeftRadius,+ layers: ['::before', '::after'].map((pseudo) => getComputedStyle(stack, pseudo).borderTopLeftRadius),+ faces: element.querySelectorAll('[data-mix-faces]').length,+ preview: Boolean(element.querySelector('.previewcounter')),+ };+ });+ await opened.page.locator('article.card.partcard').first().waitFor({ timeout: 10_000 });+ const part = await shapeOf('article.card.partcard');+ assert.notEqual(part.cover, '0px', '封面没有圆角,比对失去意义');+ assert.deepEqual(part.layers, [part.cover, part.cover], '分卷卡的叠层纸边和封面不是同一档圆角');+ assert.equal(part.faces, 0, '分卷卡仍挂着翻卡面板');+ assert.ok(part.preview, '分卷卡悬停没有分段预览入口');+ if (await opened.page.locator('article.mixcard').count()) {+ const mix = await shapeOf('article.mixcard');+ assert.deepEqual(mix.layers, [mix.cover, mix.cover], 'Mix 卡的叠层纸边和封面不是同一档圆角');+ }+ assert.deepEqual(opened.problems, []);+ } finally {+ await opened.close();+ }+ });+it('抬起与推开只属于作品卡的共演头像', { timeout: 60_000 }, async () => {const opened = await openCatalog(browser);try {diff --git a/tests/test_follow_web.py b/tests/test_follow_web.pyindex 0d86b702d..fe6a7a526 100644--- a/tests/test_follow_web.py+++ b/tests/test_follow_web.py@@ -208,6 +208,21 @@ class FollowContractTests(unittest.TestCase):self.assertEqual([row['k'] for row in online['follow_tags']], follow['tags'])self.assertEqual(self._get('/api/facets', loc='local')['follow_tags'], [])+ def test_every_card_member_says_whether_it_is_a_version_or_a_piece(self):+ """卡片据 `variant_kind` 决定叠层翻不翻:alt 与 WIP 是同一段的另一版,翻过去+ 还是那张图;main 是独立的一段。同站版本和跨站成员都得带上这个字段。"""+ self._seed()+ self._seed(provider="pawchive", ref="lazy", candidates=(FollowCandidate(+ provider="pawchive", external_id="p1", title="Fiona - Paizuri",+ url="https://pawchive.test/p1", published_at="2026-08-19T00:00:00Z"),))+ groups = [group for group in self._get()["groups"]+ if group["primary"]["title"].startswith("Fiona")]+ self.assertEqual(len(groups), 1)+ group = groups[0]+ members = [group["primary"], *group["variants"], *group["duplicates"]]+ self.assertEqual(sorted((item["provider"], item["variant_kind"]) for item in members),+ [("pawchive", "main"), ("rule34video", "alt"), ("rule34video", "main")])+def test_unsaved_follow_tags_do_not_enter_catalog_facets(self):self._seed(candidates=(FollowCandidate(provider='rule34video', external_id='unsaved', title='Demo video',@@ -3221,8 +3236,6 @@ class FollowWebSourceTests(unittest.TestCase):self.assertPageLacks("`${group.variants.length} 个版本`","版本数必须含主条目,否则两个视频显示成 1 个版本")- # 计数来源换成了「点开真能看到的那一组」,量词的分工不变。- self.assertPageContains("const count=(openable||followOpenableItems(group)).length;")def test_cross_site_duplicates_are_shown_as_another_source(self):self.assertPageContains("另见 ")@@ -3469,11 +3482,12 @@ class FollowWebSourceTests(unittest.TestCase):实测两处对不上:paheal 一组 9 条里有 1 张图,卡上写「9 个版本」、播放角标写「8 个视频」;`2B Camp [4K]` 卡上写「2 个版本」,同组另一条不是可播视频,- `collection` 因此为 null,点开只有 1 条。+ `collection` 因此为 null,点开只有 1 条。两个数一致之后,封面角标已经报过的+ 那一组,正文就不再报第二遍(`web/js/stack-cards.js`,行为验收在 `test_web_js.py`)。"""self.assertPageContains("function followOpenableItems(group)")self.assertPageContains("if(followMediaView==='videos')return followVideoItems(group);")- self.assertPageContains("const count=(openable||followOpenableItems(group)).length;")+ self.assertPageContains("const count=showCount?(openable||followOpenableItems(group)).length:0;")self.assertPageContains("if(count>1)badges.push(")self.assertPageLacks("${group.variants.length+1} ${group.is_release?'条动态':'个版本'}")diff --git a/tests/test_source_assertion_ratchet.py b/tests/test_source_assertion_ratchet.pyindex 5980bb4a1..0cd95b6cc 100644--- a/tests/test_source_assertion_ratchet.py+++ b/tests/test_source_assertion_ratchet.py@@ -39,7 +39,7 @@ BASELINE: dict[str, int] = {"test_face_detect.py": 3,"test_fastapi_api.py": 4,"test_follow_assets.py": 2,- "test_follow_web.py": 354,+ "test_follow_web.py": 353,"test_frontend_build.py": 81,"test_job_status.py": 3,"test_metadata_library.py": 7,@@ -53,7 +53,7 @@ BASELINE: dict[str, int] = {"test_web_e2e.py": 2,"test_web_js.py": 1,"test_web_settings.py": 8,- "test_web_ui.py": 4572,+ "test_web_ui.py": 4557,"test_windows_update.py": 3,}diff --git a/tests/test_web_js.py b/tests/test_web_js.pyindex 2c7fb5c24..5a747b6ea 100644--- a/tests/test_web_js.py+++ b/tests/test_web_js.py@@ -619,6 +619,60 @@ class WebJsBehaviourTests(unittest.TestCase):("face-frame.js", "faceZoom", [self.SMALL_FACE, {"w": 0, "h": 0}, 2], 1),])+ # 关注卡的成员取 `/api/follow` 下发的形状:条目有 `variant_kind`,帖子里的媒体没有。+ @staticmethod+ def follow_member(ident, kind="main", media_kind="video"):+ return {"id": ident, "variant_kind": kind, "media_kind": media_kind,+ "thumb_url": f"/follow-cover?id={ident}"}++ def test_a_follow_stack_flips_only_between_distinct_pieces(self):+ # 2026-09-24 生产样本:paheal 一组 9 帖(1 图 8 视频),时长各不相同,是同一段+ # 动画拆出的几条。每张图都不一样,照翻。+ burst = [self.follow_member(ident) for ident in range(16385, 16393)]+ # 主条目加几份 alt(`[4K]`、`(No Text)`)是同一段的另一版,翻过去还是那张图。+ versions = [self.follow_member(1), self.follow_member(2, "alt"),+ self.follow_member(3, "alt"), self.follow_member(4, "wip")]+ # 封面落在 alt 上、组里只有一条 main:仍然只有一段画面。+ one_piece = [self.follow_member(2, "alt"), self.follow_member(1)]+ results = self.run_js([+ ["stack-cards.js", "followStack",+ [{"cover": "/follow-cover?id=16385", "videos": burst, "openable": 8}]],+ ["stack-cards.js", "followStack",+ [{"cover": "/follow-cover?id=1", "videos": versions, "openable": 4}]],+ ["stack-cards.js", "followStack",+ [{"cover": "/follow-cover?id=2", "videos": one_piece, "openable": 2}]],+ ["stack-cards.js", "followStack",+ [{"cover": "/follow-cover?id=16385", "videos": burst, "openable": 8, "limit": 3}]],+ ])+ self.assertEqual([r["faces"] for r in results[:3]],+ [[f"/follow-cover?id={ident}" for ident in range(16385, 16393)], [], []])+ # 不翻的那几种照样是一叠:纸边和「N 个视频」都还在。+ self.assertEqual([(r["isMix"], r["mixCount"], r["mixKind"]) for r in results[:3]],+ [(True, 8, "视频"), (True, 4, "视频"), (True, 2, "视频")])+ self.assertEqual(len(results[3]["faces"]), 3)++ def test_a_follow_card_states_its_count_once(self):+ # 封面角标数的是组里的视频成员时,正文的「N 个版本」数的是同一组,不再说第二遍。+ burst = [self.follow_member(ident) for ident in range(16385, 16393)]+ # 一条帖子自带 11 张图、组里另有一条帖子:角标数的是这一帖的图,组里几条帖子是+ # 另一件事,正文照说;翻的是这一帖自己的图。+ post = [{"index": i, "media_kind": "image", "thumb_url": f"/img/{i}"} for i in range(11)]+ results = self.run_js([+ ["stack-cards.js", "followStack",+ [{"cover": "/follow-cover?id=16385", "videos": burst, "openable": 8}]],+ ["stack-cards.js", "followStack",+ [{"cover": "/img/0", "embedded": post, "videos": burst[:2], "openable": 2,+ "imageView": True}]],+ # 图片视图里几条单图帖子:封面没有角标,条数只能由正文说。+ ["stack-cards.js", "followStack",+ [{"cover": "/img/0", "embedded": post[:1], "imageView": True, "openable": 3}]],+ ["stack-cards.js", "followStack", [{"cover": "/img/0", "openable": 1}]],+ ])+ self.assertEqual([r["showCount"] for r in results], [False, True, True, False])+ self.assertEqual((results[1]["mixCount"], results[1]["mixKind"], len(results[1]["faces"])),+ (11, "图片", 9))+ self.assertFalse(results[2]["isMix"])+if __name__ == "__main__":unittest.main()diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex ef5636d63..12dbbf75b 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -7828,30 +7828,6 @@ class WebUiSourceTests(unittest.TestCase):# 队列长度不能被悬浮预取剪短:两边用同一个 limit。self.assertPageContains("api('/api/related?id='+seedId+'&limit=28')")- def test_multipart_cards_flip_through_their_parts_on_hover(self):- """分卷卡悬浮翻各卷画面,版次卡继续走分段视频预览。-- 有码、中字、无码是同一段画面的几个来源,翻过去前后两张几乎一样,看着像图- 卡住了;各卷是不同画面,翻动才说明这张卡代表不止一条。分卷卡因此也不带- 倒计时环和快退/快进那三颗——它们要操作的 `video.hv` 在这种卡上不存在。- 各卷只取一次,悬浮预取后点开分卷队列不再发第二个请求。- """- self.assertPageContains(- """${parts?'<div class="mixfaces" data-mix-faces hidden></div>':''}""")- self.assertPageContains("function wirePartFlip(el,it){")- self.assertPageContains("if(it?.part_group)wirePartFlip(el,it);")- self.assertPageContains(- "else if(it&&(!it.medium||it.medium==='video'))wireHover(el,it);")- # 和 Mix 共用同一套时序、门槛和面渲染,不另写一份动效。- self.assertPageContains("wireStackFlip(el,async()=>{")- self.assertPageContains(".filter(x=>mixHasPicture(x,layout)).slice(0,MIX_FLIP_FACES)")- # 第一张是卡片自己的静止封面,翻进来的才不会跳取景。- self.assertPageContains("return [it,...items.filter(x=>x.id!==it.id)]")- self.assertPageContains("const tools=parts?laterTool:")- self.assertPageContains("const partGroupCache=new Map();")- self.assertPageContains("try{group=await partGroup(seedId)}catch(_e)")- self.assertPageLacks("const group=await api('/api/parts?id='+seedId);")-def test_stacked_cards_pile_upward_and_keep_the_row_bottom_aligned(self):"""Mix、分卷、版次和关注合集的叠层往上溢出,卡片本体不为它留白。@@ -7880,13 +7856,7 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains("wireStackFlip(card,async()=>urls.map(url=>")self.assertPageContains("if(!card.dataset.flipWired){card.dataset.flipWired='1';wireFollowStackFlip(card)}")- # 翻的必须是角标数的那一组,否则卡上写「9 个视频」翻的却是别处的图。- self.assertPageContains(- "const faceSource=embedded.length>1?embedded:"- "(groupedVideos.length>1?groupedVideos:videos);")- self.assertPageContains("const faceUrls=isMix?[...new Set([thumbUrl,...faceSource")- self.assertPageContains(".filter(entry=>!imageView||entry.media_kind==='image')")- self.assertPageContains(".map(entry=>entry.thumb_url)].filter(Boolean))].slice(0,MIX_FLIP_FACES):[];")+ # 翻哪几张由 `web/js/stack-cards.js` 判定,行为验收在 `test_web_js.py`。self.assertPageContains('${faceUrls.length>1?`<div class="mixfaces" ''data-mix-faces="${esc(JSON.stringify(faceUrls))}" hidden></div>`:\'\'}')diff --git a/web/app.js b/web/app.jsindex db68f25e3..36f2d7d69 100644--- a/web/app.js+++ b/web/app.js@@ -11,6 +11,7 @@ import { javDisplayName, javTitleHtml } from './js/jav-title.js';import { matchRoute, routeLabel } from './js/routes.js';import { initMiddleTruncate } from './js/middle-truncate.js';import { tagLabel } from './js/tags.js';+import { followStack } from './js/stack-cards.js';import { playUiSound, setUiSoundsEnabled, wireUiSounds } from './js/ui-sounds.js';import { ACCENTS, DEFAULT_ACCENT, DEFAULT_HOME_GLOW, GLASS_NATIVE_PRESET, GLOW_SPOT_LABELS, GLOW_SWATCHES, GLOW_SWATCH_FAMILIES, HOME_GLOW_CHOICES, HOME_GLOW_PRESETS, HOME_GLOW_SPOTS, glowAccent, glowChipFill, glowColor, glowPalette, glowPresetName, isNativeGlass, normalizeAccent, normalizeHomeGlow, paintGlassFaces, paintHomeGlow } from './js/home-glow.js';import { mountIsland, unmountIsland, islandMounted, paginationHtml, pageCount, clampPage, preferredDirection } from './dist/peach-ui.js';@@ -3543,9 +3544,7 @@ function cardHtml(it,cls){const tgs=(it.follow_tags||it.tags||[]).slice(0,3).map(x=>`<button type="button" class="tg general"${it.follow_item_id?' disabled':` data-tag="${esc(x)}"`}>${esc(tagLabel(x))}</button>`).join('');const laterTool=`<div class="hovertools later-tools"><button class="laterbtn" data-later aria-pressed="${!!it.watch_later}" title="稍后看" aria-label="稍后看">${it.watch_later?icon('check'):icon('bookmark-plus')}</button></div>`;- /* 分卷卡悬浮翻的是各卷首帧,没有可控的视频:倒计时环和快退/快进那三颗留着的话,- 按下去找不到 `video.hv`,等于三颗空按钮压在正在翻的画面上。 */- const tools=parts?laterTool:`<button class="previewcounter" data-open title="打开预览" aria-label="打开预览">+ const tools=`<button class="previewcounter" data-open title="打开预览" aria-label="打开预览"><svg viewBox="-18 -18 36 36"><circle r="17"></circle><circle r="17"></circle></svg>${icon('play','ringplay')}</button>${laterTool}<div class="hovertools seektools">@@ -3554,11 +3553,13 @@ function cardHtml(it,cls){<button data-open title="打开详情" aria-label="打开详情">${icon('expand')}</button></div>`;/* 小图与预览图都是 16:9 横图,只更换图片来源;元数据 DOM 和高度必须完全相同。 *//* 叠层纸边是「这张卡代表不止一条」的视觉说法,分卷和版次都成立。只给分卷的话,- 同样被折叠过的版次卡长得和普通卡一模一样,只有角标能看出来。 */+ 同样被折叠过的版次卡长得和普通卡一模一样,只有角标能看出来。+ 两种都不翻卡:各卷与各版次共用同一个番号的封套,翻过去还是那张图,看着像卡住了。+ 悬停照普通卡走分段视频预览。 */const stacked=parts||editions;return `<article class="card ${stacked?'partcard ':''}${cls||''} ${it.disposal==='trash'?'pending-delete':''}" data-id="${it.id}"${parts?` data-part-seed="${parts.seed_id}"`:''}><button type="button" class="cardopenhit" data-open aria-label="打开 ${esc(shownName)}${parts?'分卷':editions?'版本':'详情'}"></button>- ${stacked?'<div class="partstack">':''}<div class="pic" style="--card-ratio:${ar}">${thumb}${parts?'<div class="mixfaces" data-mix-faces hidden></div>':''}+ ${stacked?'<div class="partstack">':''}<div class="pic" style="--card-ratio:${ar}">${thumb}<div class="badge mono">${srcBadge(it.location,it.cost)}</div><span class="selectionMark">${icon('check')}</span><span class="deleteMark">${icon('trash')}<b>回收站</b></span>${parts?`<span class="partbadge">${parts.count} 卷</span>`:''}${editions?`<span class="partbadge editionbadge" title="${esc(editions.editions.join(' · '))}">${editions.count} 个版本</span>`:''}<span class="dur mono">${fmtDur(shownDuration)}</span>${tr}${tools}</div>${stacked?'</div>':''}@@ -3893,7 +3894,7 @@ function wireMixFlip(el,seedId){.map(x=>mixFacePoster(x,layout,true));});}-/* 分卷组每个 seed 只取一次:悬浮翻动和点开后的分卷队列用的是同一份。 */+/* 分卷组每个 seed 只取一次:同一组的分卷队列反复打开不再发第二个请求。 */const partGroupCache=new Map();function partGroup(seedId){if(!partGroupCache.has(seedId))@@ -3902,17 +3903,6 @@ function partGroup(seedId){.catch(error=>{partGroupCache.delete(seedId);throw error}));return partGroupCache.get(seedId);}-/* 分卷卡悬浮翻的是同一部片各卷的画面,和 Mix 用同一套时序与门槛。版次组不翻:- 有码、中字、无码是同一段画面的几个来源,翻过去前后两张几乎一样,看着像图卡住了,- 那种卡继续用分段视频预览。第一张是卡片自己的静止封面,翻进来的才不会跳取景。 */-function wirePartFlip(el,it){- wireStackFlip(el,async()=>{- const items=await partGroup(it.part_group.seed_id).then(group=>group.items),layout=javLayout();- return [it,...items.filter(x=>x.id!==it.id)]- .filter(x=>mixHasPicture(x,layout)).slice(0,MIX_FLIP_FACES)- .map(x=>mixFacePoster(x,layout,true));- });-}/* 关注页的合集翻的是卡片渲染时就写进 DOM 的那几张缩略图:同一组媒体已经在手上,悬浮不该再为动画发一次请求。第一张必须是静止封面本身,否则一翻就露出取景差别。 */@@ -3986,8 +3976,7 @@ function wireCards(root,onClick){opener.dataset.openWired='1';opener.onclick=e=>{e.stopPropagation();if(selectMode||e.shiftKey||e.ctrlKey||e.metaKey){e.preventDefault();toggleSelection(it.id,e.shiftKey);return}openCard(+el.dataset.id,el)};});- if(it?.part_group)wirePartFlip(el,it);- else if(it&&(!it.medium||it.medium==='video'))wireHover(el,it);+ if(it&&(!it.medium||it.medium==='video'))wireHover(el,it);});}@@ -5994,9 +5983,10 @@ function followOpenableItems(group){return followCollectionItems(group).filter(item=>followItemMediaKinds(item).has('image'));}-function followBadges(group,openable=null){+/* `count:false`:封面角标已经报过这一组的条数(`followStack` 判定),正文不再说第二遍。 */+function followBadges(group,openable=null,{count:showCount=true}={}){const badges=[];- const count=(openable||followOpenableItems(group)).length;+ const count=showCount?(openable||followOpenableItems(group)).length:0;/* WIP 说的是这一条,不是这一组。`2B Camp [4K]` 判的是 alt,只因为同组还有一条`[WIP]` 就在它头上挂 WIP,读起来就成了「这一条是半成品」。同组有 WIP 仍然要说,但要说成「含」。 */@@ -6419,18 +6409,11 @@ function followCard(group,authorSources=[]){const videos=followMediaView==='videos'?followVideoItems(group):[],embedded=item.media_items||[];const groupedOwner=followMediaView==='videos'?followGroupedMediaOwner(group):null;const groupedVideos=(groupedOwner?.media_items||[]).filter(media=>media.media_kind==='video');- const isMix=embedded.length>1||groupedVideos.length>1||videos.length>1;- const mixCount=embedded.length>1?embedded.length:(groupedVideos.length||videos.length);- const mixKind=embedded.length&&embedded.every(media=>media.media_kind==='image')?'图片'- :embedded.length&&embedded.some(media=>media.media_kind==='image')?'媒体':'视频';const mixTarget=embedded.length>1?item.id:(videos[0]?.id||item.id);- /* 翻动用的几张必须来自角标数的那一组,否则卡上写「9 个视频」翻的却是别处的图。- 图片视图里只翻图片:这一叠说的就是这几张图。 */- const faceSource=embedded.length>1?embedded:(groupedVideos.length>1?groupedVideos:videos);- const faceUrls=isMix?[...new Set([thumbUrl,...faceSource- .filter(entry=>!imageView||entry.media_kind==='image')- .map(entry=>entry.thumb_url)].filter(Boolean))].slice(0,MIX_FLIP_FACES):[];- const badges=followBadges(group);+ /* 翻动用的几张来自角标数的那一组,否则卡上写「9 个视频」翻的却是别处的图。 */+ const {isMix,mixCount,mixKind,faces:faceUrls,showCount}=followStack({cover:thumbUrl,embedded,+ groupedVideos,videos,imageView,openable:followOpenableItems(group).length,limit:MIX_FLIP_FACES});+ const badges=followBadges(group,null,{count:showCount});const author=followAuthorName(authorSources)||item.author||item.source_label||'创作者未取得';const when=followWhen(item),compactWhen=/^\d{4}-/.test(when)?(when.startsWith(String(new Date().getFullYear()))?when.slice(5,10):when.slice(0,10)):when;diff --git a/web/board.css b/web/board.cssindex e33df55de..cdbb9c531 100644--- a/web/board.css+++ b/web/board.css@@ -786,7 +786,7 @@ body>.board-filter-frame{margin-inline:16px}.iconswitch label{border-radius:8px}.iconswitch label:has(input:checked){background:var(--ground);box-shadow:0 1px 3px light-dark(#0002,#0009)}.card{overflow:visible;border-radius:var(--surface-radius)}-.card .pic{border-radius:var(--surface-radius)}+.card :is(.pic,.mixstack,.partstack){border-radius:var(--surface-radius)}.card .info{background:transparent}@media(max-width:760px){.sidecontent{padding:16px}.stage{border-radius:12px}.stage .side{border-left:0;border-top:1px solid var(--line-soft)}}/* 单列时媒体、详情栏和队列上下排成一列,总高超过浮窗,滚的是里面那一格内容:`<dialog>`diff --git a/web/css/12-cards.css b/web/css/12-cards.cssindex 1196dbc4b..c4b79b11f 100644--- a/web/css/12-cards.css+++ b/web/css/12-cards.css@@ -156,9 +156,10 @@ body.refreshing #batchAction svg,content-visibility:auto;contain-intrinsic-size:auto 320px;overflow-clip-margin:8px}/* 叠层往上溢出到行间距里,卡片本体不为它留白。留白的写法(padding-top:7px)会把整张卡压低 7px 并加高 7px,同一行里 Mix、分卷、版次卡的封面和下面的文字就比- 邻居矮一截;往上堆之后卡片盒和普通卡完全同高,下沿自然平齐。 */-.mixstack,.partstack{position:relative;isolation:isolate}-.mixstack::before,.mixstack::after,.partstack::before,.partstack::after{content:"";position:absolute;border-radius:var(--badge-radius);+ 邻居矮一截;往上堆之后卡片盒和普通卡完全同高,下沿自然平齐。+ 纸边与封面是同一种表面,圆角同一档:容器取封面那一档,纸边继承容器。 */+.mixstack,.partstack{position:relative;isolation:isolate;border-radius:var(--badge-radius)}+.mixstack::before,.mixstack::after,.partstack::before,.partstack::after{content:"";position:absolute;border-radius:inherit;border:1px solid var(--border-15);background:color-mix(in srgb,var(--surface) 84%,var(--video-glow,#15202a));z-index:0}.mixstack::before,.partstack::before{inset:0 12px 8px;transform:translateY(-7px);opacity:.54}.mixstack::after,.partstack::after{inset:0 6px 4px;transform:translateY(-4px);opacity:.78}diff --git a/web/js/stack-cards.js b/web/js/stack-cards.jsnew file mode 100644index 000000000..14e367b37--- /dev/null+++ b/web/js/stack-cards.js@@ -0,0 +1,32 @@+/* 关注卡叠层的三件判断:封面角标数的是哪一组、悬浮翻哪几张、正文还要不要再报一次条数。++ 叠层纸边说的是「这张卡不止一条」,翻动说的是「这几条长得不一样」,两件事分开判。+ 同一段画面的几份翻过去还是那张图,看着像卡住了:alt 与 WIP 是某一段的另一版+ (`follow_variants` 按标题标记判定,服务端随每个成员下发 `variant_kind`),只留纸边、+ 不进翻动。组里独立的几段(booru 连发、同一包短片、跨站的同作品帖)是 `main`,照翻。+ 一条帖子自带的多张媒体没有这个字段,每一张本来就是不同的。 */++const isImage = (entry) => entry?.media_kind === 'image';+const isPiece = (entry) => !entry?.variant_kind || entry.variant_kind === 'main';++export function followStack({+ cover = '', embedded = [], groupedVideos = [], videos = [],+ imageView = false, openable = 0, limit = 9,+} = {}) {+ /* 帖子自带的媒体优先:角标数的就是点开后那一串。没有才数组里的视频成员。 */+ const own = embedded.length > 1 ? embedded : groupedVideos.length > 1 ? groupedVideos : null;+ const source = own || videos;+ const isMix = source.length > 1;+ const mixKind = source.length && source.every(isImage) ? '图片'+ : source.some(isImage) ? '媒体' : '视频';+ /* 图片视图里只翻图片:这一叠说的就是这几张图。第一张是静止封面本身,+ 否则一翻就露出取景差别。 */+ const pieces = source.filter((entry) => (!imageView || isImage(entry)) && isPiece(entry));+ const faces = pieces.length > 1+ ? [...new Set([cover, ...pieces.map((entry) => entry.thumb_url)].filter(Boolean))].slice(0, limit)+ : [];+ /* 封面角标数的是组里的视频成员时,它和「N 个版本」数的是同一组,正文不再说第二遍。+ 角标数的是一条帖子里的媒体时,组里有几条帖子是另一件事,仍然要说。 */+ const showCount = openable > 1 && !(isMix && !own);+ return { isMix, mixCount: isMix ? source.length : 0, mixKind, faces, showCount };+}