Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 稳定关注悬停并统一详情浮窗

longmeidaoe8bf11bf2db1
diff --git a/docs/REUSE.md b/docs/REUSE.md
index 7ad838549..6255de523 100644
--- a/docs/REUSE.md
+++ b/docs/REUSE.md
@@ -181,12 +181,14 @@ CloudDrive 为外部应用,本项目不捆绑其二进制或依赖其管理 AP
- 主题三选一(跟随系统/浅色/深色),只存本机,首帧前由内联脚本写进 `<html>` 的 `data-theme`。
- 同番号的分卷派生(A/B、1/2、CD/Disc/DVD/Part/Vol、「首卷裸名 + 后续卷 `-2`/`-3`」)折叠成一张卡并按时长排除完整版;首页、搜索、资料页网格与版次队列、角标计数共用同一套判定。卷号后面还挂着尾缀时先剥掉组内共有的那一段再认,判据是「组内每个文件名都带、且从分隔符起头」而不是版次词表:按词表拆的话 `1080p` 会被读成 `10` 加 `80p`,同一部片的两个清晰度就成了两卷。
- 分卷卡悬浮翻各卷首帧,版次卡(有码/中字/无码)悬浮走分段视频预览:版次是同一段画面的几个来源,翻过去前后两张几乎一样,看着像图卡住了。分卷详情标题带卷号——同一部片各卷的标题、女优、厂牌逐字相同,不写卷号就看不出换了哪一卷。
+- 合集翻图复用 `wireStackFlip`:逐张解码后才显示,失败帧不入队,悬停代际隔离异步结果,退出清理计时器。馆藏与关注详情共用原生 `dialog#stage`,浮窗不参与列表排版,关闭保留关注列表 DOM;图片灯箱沿用现有实现。
+- F95 讨论图片依据已确认的附件身份在采集与读取投影中排除。网盘资源保留,未取得作品预览时显示资源服务图标;不能仅凭 GIF 扩展名过滤作品。
- 普通多女优卡片叠放前 3 个头像、只显示第一位姓名和真实总人数;JAV 小图是整页版式,混入的非番号作品统一为标题、身份、标签三行固定高度。
- JAV 详情持有 `asset.catalog_title`/`original_title` 与官方 Tag 身份,官方标记用常规字重,身份区收齐到同一内容起点。
- JAV 官方封面重探只在面积更大时替换,失败保留原图。
- 播放器按 YouTube 锁定源码对齐控件、状态、图标形变、设置面板动画与悬停提示,倍速五格到 3.0,窄屏按播放器宽度折叠留黑边,沉浸模式按 Shorts 版式,竖屏用居中 9:16 舞台,播放统计两页共用、按传输方式分口径。
- 图片灯箱在本地照片和关注在线图片间复用同一套 Swiper,在线图片只显示来源、合集序号和浏览器实际解析结果;照片标签进入分页图片墙,点开才按原图比例呈现。
-- 两处图片墙(资料页照片、关注在线图片)共用大小与固定比例/瀑布流设置,顶部大小按钮与筛选浮层同步。瀑布流使用 CSS 多栏、`break-inside:avoid` 和图片 `aspect-ratio:auto 1`:懒加载前保留非零高度,加载后使用天然比例;机制见 [MDN aspect-ratio](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/aspect-ratio)。图片 `alt` 保留给读屏,字色透明避免加载时铺满文件名。
+- 两处图片墙(资料页照片、关注在线图片)共用大小与固定比例/瀑布流设置,大小由顶部按钮控制,筛选浮层控制布局。关注图片的「仅显示图片」开关独立保存,隐藏卡片文字与信息角标。瀑布流使用 CSS 多栏、`break-inside:avoid` 和图片 `aspect-ratio:auto 1`:懒加载前保留非零高度,加载后使用天然比例;机制见 [MDN aspect-ratio](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/aspect-ratio)。图片 `alt` 保留给读屏,字色透明避免加载时铺满文件名。
- 缓存型资产路由一律先问缓存,不先解析源文件:`media_engine.file_for()` 里那句存在性检查落在 CloudDrive 挂的网盘上,实测一次 137–402 毫秒,一屏几十张缩略图全部命中缓存也要为这几十次往返等好几秒。缩好之后源文件在不在都不改变响应,`/photo-thumb` 因此先问 `photo_service.cached()`。
- 「只采集」对齐全的行(番号已落库、字段有着落或已在候选表、封面在位)不碰磁盘;文件在不在看目录列表,同目录只列一次;候选 CSV 每 5 秒落盘一次、被打断也在收尾写全;扫描从目录列表自带的大小与时间登记文件,不逐个 stat。账本副本、外部来源换桩、媒体挂载只读的实测(2026-09-13):本地盘 2553 行 2 秒,115 每秒约 65 行、PikPak 约 35 行,进入首行前的准备 0.4 秒;真实运行每条缺资料的行另加联网时间,联网仍是串行。
- 一个控件在两页出现时,选中态怎么表现也归它,不只是外框和材质:首页与资料页的「全部/没看过/稍后看/已标记」共用 `syncViewGlide` 那块滑动玻璃,填充只由玻璃给,两排各自不铺底。找那一排按结构(`#viewPills,.entityviews`)加「此刻量得出宽度」,不按 id:两排在同一份文档里一直都在,另一页开着的时候只是被祖先收起来,写死 id 会一直取到看不见的那一排。
diff --git a/frontend/test/stack-flip.test.ts b/frontend/test/stack-flip.test.ts
new file mode 100644
index 000000000..d1d2010e0
--- /dev/null
+++ b/frontend/test/stack-flip.test.ts
@@ -0,0 +1,100 @@
+import { readFileSync } from 'node:fs';
+import { resolve } from 'node:path';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+// 执行生产函数,隔离整页启动与网络请求。
+const app = readFileSync(resolve(process.cwd(), '../web/app.js'), 'utf8');
+const source = app.slice(app.indexOf('function wireStackFlip('), app.indexOf('function wireMixFlip('));
+const wire = new Function('selectMode', 'censorOn', 'reduceMotion', 'syncJavImages', 'appSettings',
+ 'MIX_FLIP_MS', 'MIX_FLIP_LEAD_MS', `${source};return wireStackFlip`)(
+ false, () => false, () => false, () => {}, {}, 1100, 420);
+const pool = ['a', 'b', 'c'].map(id => `<img src="/${id}.jpg">`);
+function card(stack = true) {
+ const el = document.createElement('article');
+ el.innerHTML = `<img class="base" src="/base.jpg">${stack ? '<div data-mix-faces hidden></div>' : ''}`;
+ document.body.append(el);
+ return el;
+}
+function enter(el: HTMLElement) { el.dispatchEvent(new MouseEvent('mouseenter')); }
+function leave(el: HTMLElement) { el.dispatchEvent(new MouseEvent('mouseleave')); }
+
+describe('悬停合集封面', () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ vi.spyOn(HTMLImageElement.prototype, 'complete', 'get').mockReturnValue(true);
+ vi.spyOn(HTMLImageElement.prototype, 'naturalWidth', 'get').mockReturnValue(320);
+ vi.spyOn(HTMLImageElement.prototype, 'decode').mockResolvedValue();
+ });
+ afterEach(() => { document.body.replaceChildren(); vi.clearAllTimers(); vi.useRealTimers(); });
+
+ it('全部图片解码后才覆盖静止封面,退出清理计时器', async () => {
+ const ready: Array<() => void> = [];
+ vi.mocked(HTMLImageElement.prototype.decode).mockImplementation(() => new Promise<void>(resolve => { ready.push(resolve); }));
+ const el = card(); wire(el, async () => pool.slice(0, 2)); enter(el);
+ await vi.advanceTimersByTimeAsync(340);
+ expect((el.querySelector('[data-mix-faces]') as HTMLElement).hidden).toBe(true);
+ ready[0]!(); await vi.advanceTimersByTimeAsync(0);
+ expect((el.querySelector('[data-mix-faces]') as HTMLElement).hidden).toBe(true);
+ ready[1]!(); await vi.advanceTimersByTimeAsync(0);
+ expect((el.querySelector('[data-mix-faces]') as HTMLElement).hidden).toBe(false);
+ leave(el);
+ await vi.advanceTimersByTimeAsync(6000);
+ expect(el.querySelectorAll('.mixface')).toHaveLength(0);
+ expect(vi.getTimerCount()).toBe(0);
+ });
+
+ it('移出再移入时丢弃旧请求,保持一套翻动计时器', async () => {
+ let stale!: (value: string[]) => void;
+ const load = vi.fn().mockImplementationOnce(() => new Promise(resolve => { stale = resolve; }))
+ .mockResolvedValue(pool);
+ const el = card(); wire(el, load); enter(el);
+ await vi.advanceTimersByTimeAsync(340); leave(el); enter(el);
+ await vi.advanceTimersByTimeAsync(340);
+ stale(['<img src="/stale.jpg">', '<img src="/old.jpg">']);
+ await vi.advanceTimersByTimeAsync(420);
+ expect(el.querySelectorAll('.mixface')).toHaveLength(3);
+ expect(el.querySelector('.on img')?.getAttribute('src')).toBe('/b.jpg');
+ await vi.advanceTimersByTimeAsync(1100);
+ expect(el.querySelector('.on img')?.getAttribute('src')).toBe('/c.jpg');
+ expect(vi.getTimerCount()).toBe(2);
+ leave(el); expect(vi.getTimerCount()).toBe(0);
+ });
+
+ it('加载失败的帧不会进入翻动队列', async () => {
+ vi.mocked(HTMLImageElement.prototype.decode).mockImplementation(function (this: HTMLImageElement) {
+ return this.getAttribute('src') === '/b.jpg' ? Promise.reject(new Error('image')) : Promise.resolve();
+ });
+ const el = card(); wire(el, async () => pool); enter(el);
+ await vi.advanceTimersByTimeAsync(760);
+ expect(el.querySelectorAll('.mixface')).toHaveLength(2);
+ expect(el.querySelector('.on img')?.getAttribute('src')).toBe('/c.jpg');
+ leave(el);
+ });
+
+ it('单版本静止卡片不加载悬停封面', async () => {
+ const el = card(false), load = vi.fn(); wire(el, load); enter(el);
+ await vi.advanceTimersByTimeAsync(10000);
+ expect(load).not.toHaveBeenCalled();
+ expect(el.querySelector('.base')).not.toBeNull();
+ expect(vi.getTimerCount()).toBe(0);
+ });
+});
+
+it('关闭灯箱后到达的图片事件和缩放回调不访问已销毁的轮播', () => {
+ const zoomSource = app.slice(app.indexOf('function wirePhotoZoom('), app.indexOf('const fmtPhotoSize='));
+ const zoom = new Function('syncBoardRange', 'PHOTO_ZOOM_MIN', 'PHOTO_ZOOM_MAX', 'PHOTO_ZOOM_STEP',
+ `${zoomSource};return wirePhotoZoom`)(() => {}, 10, 400, 10);
+ vi.useFakeTimers();
+ const box = document.createElement('div');
+ box.innerHTML = '<div class="photozoom"><input><b></b></div><button data-photo-scale="fit"></button><button data-photo-scale="original"></button><div class="photomain"><div><img></div></div>';
+ document.body.append(box);
+ const img = box.querySelector('img')!;
+ vi.spyOn(img, 'complete', 'get').mockReturnValue(false);
+ const main = { slides: [img.parentElement!] as HTMLElement[] | undefined, activeIndex: 0,
+ destroyed: false, on: vi.fn(), zoom: { in: vi.fn(), out: vi.fn() } };
+ const controller = zoom(box, main);
+ main.destroyed = true; main.slides = undefined; box.remove();
+ expect(() => { img.dispatchEvent(new Event('load')); controller.resize(); vi.runAllTimers(); }).not.toThrow();
+ expect(main.zoom.out).not.toHaveBeenCalled();
+ vi.useRealTimers();
+});
diff --git a/src/peach/follow_sources.py b/src/peach/follow_sources.py
index 75dd58a56..e58cba63e 100644
--- a/src/peach/follow_sources.py
+++ b/src/peach/follow_sources.py
@@ -78,6 +78,23 @@ def resource_links(text: str | None) -> list[str]:
return found
+# 用户逐张确认的讨论表情附件;按附件身份判断,不按 GIF 格式排除作品。
+_F95_DISCUSSION_ATTACHMENTS = frozenset({
+ "6453006_IMG_2124.jpeg", "6456143_attachment-3.gif",
+})
+
+
+def f95_discussion_image(value: object) -> bool:
+ """已确认的 F95 讨论插图不参与封面和媒体投影。"""
+ try:
+ parsed = urllib.parse.urlsplit(str(value or ""))
+ except ValueError:
+ return False
+ return (parsed.hostname == "attachments.f95zone.to"
+ and urllib.parse.unquote(parsed.path.rsplit("/", 1)[-1])
+ in _F95_DISCUSSION_ATTACHMENTS)
+
+
def f95_attachment_media_items(metadata: Mapping[str, object]) -> list[dict[str, object]]:
"""Project F95 image attachments, including rows saved before galleries existed."""
attachments = metadata.get("attachments")
@@ -90,7 +107,7 @@ def f95_attachment_media_items(metadata: Mapping[str, object]) -> list[dict[str,
parsed = urllib.parse.urlsplit(url)
except ValueError:
continue
- if (parsed.scheme != "https" or parsed.hostname != "attachments.f95zone.to"
+ if (f95_discussion_image(url) or parsed.scheme != "https" or parsed.hostname != "attachments.f95zone.to"
or not _IMAGE_URL_RE.search(url)):
continue
name = urllib.parse.unquote(parsed.path.rsplit("/", 1)[-1]) or f"image-{index + 1}"
@@ -1937,10 +1954,11 @@ class F95ZoneConnector(_BaseConnector):
if str(node.get("href", "")).startswith("http")
]
media_links, needs_credential = self._media_links(links)
- attachment_urls = self._attachment_urls(body)
+ attachment_urls = [url for url in self._attachment_urls(body)
+ if not f95_discussion_image(url)]
# F95 会把正文里粘贴的 GIF / meme 也存到 attachments.f95zone.to。
# 它们只是讨论插图,不是作者交付的资源;单凭一张内嵌图片不能让楼层
- # 进入追更。非图片附件仍保留,带文件站链接的楼层也保留全部预览图。
+ # 进入追更。非图片附件仍保留,正文图片按已确认的讨论附件身份过滤。
downloadable_attachments = [
url for url in attachment_urls if not self._INLINE_IMAGE_RE.search(url)
]
diff --git a/src/peach/web_follow.py b/src/peach/web_follow.py
index bcf168740..ed0713717 100644
--- a/src/peach/web_follow.py
+++ b/src/peach/web_follow.py
@@ -32,7 +32,7 @@ from .follow_secrets import (
from .follow_stream import proxyable
from .follow_sources import (
CONNECTORS, KemonoConnector, Rule34VideoConnector, build_connector,
- canonical_source_ref, display_thumb_url, f95_attachment_media_items,
+ canonical_source_ref, display_thumb_url, f95_attachment_media_items, f95_discussion_image,
is_history_end_error, parse_source_url, resource_links,
)
from .follow_store import (
@@ -597,6 +597,8 @@ def _media_items(item) -> list[dict]:
for index, media in enumerate(raw):
if not isinstance(media, dict):
continue
+ if item.provider == "f95zone" and f95_discussion_image(media.get("url") or media.get("thumb_url")):
+ continue
kind = str(media.get("media_kind") or "")
if kind not in {"video", "image"}:
continue
@@ -623,6 +625,8 @@ def _thumb_url(item) -> str | None:
/follow-cover 抽首帧并缓存。这两条是 Peach 自己的路由决定,所以留在这一层;
其余全是「这个站的缩略图 URL 长什么样」,那是站点知识,实现在各连接器里。
"""
+ if item.provider == "f95zone" and f95_discussion_image(item.thumb_url):
+ return next((media["thumb_url"] for media in _media_items(item) if media["thumb_url"]), None)
if item.provider == "fanbox":
thumb = display_thumb_url(item)
media_items = item.metadata.get("media_items") or []
@@ -689,6 +693,17 @@ def _item_payload(item, credential_providers: frozenset[str] = frozenset()) -> d
media_items = _media_items(item)
if media_items:
media_kind = media_items[0]["media_kind"]
+ elif item.provider == "f95zone" and f95_discussion_image(item.thumb_url):
+ media_kind = "external"
+ resource_provider = item.provider
+ try:
+ resource_url = urllib.parse.urlsplit(str(item.media_url or ""))
+ except ValueError:
+ resource_url = urllib.parse.urlsplit("")
+ if (resource_url.hostname in {"gofile.io", "www.gofile.io"}
+ or (resource_url.hostname == "f95zone.to"
+ and resource_url.path.startswith("/masked/gofile.io/"))):
+ resource_provider = "gofile"
recorded_links = item.metadata.get("links")
safe_resource_urls = resource_links(
"\n".join(str(value) for value in recorded_links)
@@ -705,6 +720,7 @@ def _item_payload(item, credential_providers: frozenset[str] = frozenset()) -> d
"id": item.id,
"provider": item.provider,
"provider_label": PROVIDER_LABELS.get(item.provider, item.provider),
+ "resource_provider": resource_provider,
"source_id": item.source_id,
"source_label": item.source_label,
"external_id": item.external_id,
diff --git a/tests/test_follow_sources.py b/tests/test_follow_sources.py
index 768bb0ed7..7f8dce1ad 100644
--- a/tests/test_follow_sources.py
+++ b/tests/test_follow_sources.py
@@ -1056,6 +1056,14 @@ class F95ZoneConnectorTests(unittest.TestCase):
self.assertEqual([row.external_id for row in result.candidates], ["21383374"])
self.assertEqual(result.skipped, 2)
+ def test_confirmed_discussion_images_keep_the_file_resource(self):
+ for name in ("6453006_IMG_2124.jpeg", "6456143_attachment-3.gif"):
+ body = F95_HTML.replace(b"6372325_preview.png", name.encode())
+ candidate = F95ZoneConnector(transport=_transport(body=body)).fetch("50685").candidates[1]
+ self.assertEqual(candidate.media_url, "https://pixeldrain.com/u/preview-pack")
+ self.assertIsNone(candidate.thumb_url)
+ self.assertEqual(candidate.extra["media_items"], ())
+
def test_media_is_flagged_as_needing_a_login_session(self):
# 发现不需要 cookie,取附件需要。下载动作必须先看这个标志。
result = F95ZoneConnector(transport=_transport(body=F95_HTML)).fetch("50685")
diff --git a/tests/test_follow_web.py b/tests/test_follow_web.py
index 453477cdb..83fc38a93 100644
--- a/tests/test_follow_web.py
+++ b/tests/test_follow_web.py
@@ -412,6 +412,25 @@ class FollowContractTests(unittest.TestCase):
self.assertTrue(item["media_needs_credential"])
self.assertTrue(all("url" not in media for media in item["media_items"]))
+ def test_confirmed_discussion_attachment_projects_a_gofile_placeholder(self):
+ image = "https://attachments.f95zone.to/2026/09/6456143_attachment-3.gif"
+ self._seed(candidates=(FollowCandidate(
+ provider="f95zone", external_id="21521132", title="Collection",
+ url="https://f95zone.to/threads/62305/post-21521132",
+ media_url="https://f95zone.to/masked/gofile.io/62305/resource",
+ thumb_url=image,
+ extra={"attachments": [image], "links": ["https://gofile.io/d/resource"],
+ "media_items": [{"url": image, "thumb_url": image,
+ "media_kind": "image", "resource_provider": "f95zone"}]},
+ ),), provider="f95zone", ref="62305", semantics="release")
+ item = self._get()["groups"][0]["primary"]
+ self.assertIsNone(item["thumb_url"])
+ self.assertEqual(item["media_items"], [])
+ self.assertEqual(item["media_kind"], "external")
+ self.assertEqual(item["resource_provider"], "gofile")
+ self.assertFalse(item["playable"])
+ self.assertEqual(item["resource_urls"], ["https://gofile.io/d/resource"])
+
def test_saved_f95_session_forces_one_reparse_instead_of_accepting_304(self):
source_id = self._seed(candidates=(FollowCandidate(
provider="f95zone", external_id="21435168", title="Image set",
@@ -3188,18 +3207,10 @@ class FollowWebSourceTests(unittest.TestCase):
self.assertPageContains("const surface=claimSurface(renderForDetail?surfacePath():'/follow')")
self.assertPageContains("if(!surfaceCurrent(surface))return")
self.assertPageContains("await openFollow(push,true);await openFollowDetail(params.id,push)")
- self.assertPageContains("const followList=$('#stats').querySelector('.followlist')")
- # 就近展开:插在被点击那张卡片所在的一行之后,不是整个列表之前。
- # 插在列表前等于每次都把视线拽回页面顶部,翻了几屏点开一条尤其明显。
- self.assertPageContains("last.after($('#stage'))")
- self.assertPageContains("Math.abs(card.offsetTop-row)<2",
- "按行插入,避免把卡片那一行截断")
- # 列表还没渲染出来时(直达详情链接)仍回退到列表前
- self.assertPageContains("followList.before($('#stage'))")
- self.assertPageContains("followList?.classList.contains('followphotowall')")
- self.assertPageContains(".followlist>.stage{grid-column:1/-1;width:100%;min-width:0}")
- self.assertPageContains("scrollItemDetailIntoView();",
- "滚到舞台本身而不是页面头部")
+ self.assertPageContains("placeItemDetail(detailOriginAnchor,detailOriginAbove);")
+ self.assertPageContains("if(!stage.open)stage.showModal();")
+ self.assertPageLacks("last.after($('#stage'))")
+ self.assertPageContains("if(!$('#stats .followlist')){if(followData)renderFollow();else await openFollow(false)}")
self.assertPageContains("if(stage.parentElement!==main)main.insertBefore(stage,combo)")
def test_follow_filters_put_all_first_and_sources_are_icon_only(self):
@@ -3777,8 +3788,8 @@ class FollowWebSourceTests(unittest.TestCase):
self.assertPageContains("followMediaView==='images'?' followphotowall':''")
self.assertPageContains(".followlist.followphotowall{grid-template-columns:repeat(5,minmax(0,1fr))")
self.assertPageLacks(".followlist.followphotowall>.stage{column-span:all}")
- self.assertPageContains("followList?.classList.contains('followphotowall')",
- "图片详情必须脱离图片网格,避免改变所有行的排列")
+ self.assertPageContains("placeItemDetail(detailOriginAnchor,detailOriginAbove);",
+ "图片详情复用独立浮窗,保持图片墙布局")
self.assertPageContains(".followitem.imagecard .pic{aspect-ratio:4/3;min-height:0")
self.assertPageContains(".followitem.imagecard .followvisual .pic>img{position:absolute")
self.assertPageLacks(".followlist.followphotowall{display:block;column-count:5")
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 905dc0b31..59b3af438 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -6894,7 +6894,7 @@ class WebUiSourceTests(unittest.TestCase):
Mix 不再发第二个请求。
"""
self.assertPageContains('<div class="mixfaces" data-mix-faces hidden></div>')
- self.assertPageContains(".mixface.on{opacity:1;z-index:2;transform:none}")
+ self.assertPageContains(".mixface.on{opacity:1;z-index:2;transform:none;transition:none}")
self.assertPageContains(".mixface.off{opacity:0;z-index:3;transform:translateY(-11%)")
self.assertPageContains("function wireMixFlip(el,seedId){")
self.assertPageContains("wireMixFlip(el,seedId);")
@@ -6988,6 +6988,12 @@ class WebUiSourceTests(unittest.TestCase):
# 遮住静止封面的底色跟着这张卡自己的底走:图片墙是浅底,视频卡是黑底。
self.assertPageContains(".followitem.imagecard .mixfaces{background:var(--sunk)}")
+ def test_follow_image_only_controls_are_scoped_and_reversible(self):
+ self.assertPageContains('data-follow-images-only aria-pressed="${!!appSettings.followImagesOnly}"')
+ self.assertPageContains('appSettings.followImagesOnly=!appSettings.followImagesOnly;saveSettings();syncPhotoWalls();')
+ self.assertPageContains('.followphotowall[data-images-only="true"] .followitem :is(.meta,.badge,.mixbadge,.fstate){display:none}')
+ self.assertPageLacks('data-photo-size')
+
def test_mix_and_persistent_playlists_share_the_routed_side_queue(self):
self.assertPageContains('class="card mixcard" data-mix-seed=')
self.assertPageContains("cards.splice(MIX_SLOT,0,mixCardHtml(seed))")
@@ -7184,37 +7190,23 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("const returnPath=detailReturnPath||'/',restoreSurface=detailReturnNeedsRestore")
self.assertPageContains("if(restoreSurface)await restoreRoute()")
- def test_direct_detail_restores_the_home_list_and_card_details_open_inline(self):
+ def test_direct_detail_restores_the_home_list_and_uses_shared_dialog(self):
self.assertPageContains("const needsReturnRestore=detailReturnNeedsRestore||(!push&&!returnSurfaceReady)")
self.assertPageContains("function placeItemDetail(anchor,above=false)")
- self.assertPageContains("getComputedStyle(container).display==='grid'")
- self.assertPageContains("container.insertBefore(stage,above?edge:edge.nextSibling)")
+ self.assertPageContains('id="stage" aria-label="作品详情" hidden></dialog>')
+ self.assertPageContains("if(stage.parentElement!==main)main.insertBefore(stage,combo);")
self.assertPageContains("anchor.getBoundingClientRect().top+anchor.getBoundingClientRect().height/2>window.innerHeight/2")
self.assertPageContains(".grid>.stage{grid-column:1/-1;width:100%;min-width:0}")
- def test_inline_detail_stays_below_the_visible_sticky_navigation(self):
- """详情展开后停在最后一层粘着的东西下面 8px。
-
- 名单要跟着粘的那一层走:`#tagbar` 与 `#count` 被收进 `.board-filter-frame` 之后
- 自己是 `position:relative`,只按这两个名字量就只剩顶栏那 64px,详情停在 144px、
- 浮层底边却在 168px,最上面 24px 连同关闭键一起压在它下面。这两个名字仍留在名单里:
- `syncFilterFrame()` 判定不是馆藏版式时会把它们放回原位,那时粘着的是它们自己。
-
- 顶栏那一段另有出处:`html` 的 `scroll-padding-top` 已经替它留好,而它和
- `scroll-margin-top` 是叠加的,再算一遍就把落点压低整整一个顶栏(要 176px,
- 实测落在 248px)。
- """
- self.assertPageLacks("body.detail-open .tagbar{position:relative;top:auto;z-index:1}")
- self.assertPageContains("function itemDetailStickyOffset()")
- self.assertPageContains("['.top','.board-filter-frame','#tagbar','#count',"
- "'.entitytagbar','.entitycollectionhead']")
- self.assertPageContains("el.compareDocumentPosition(stage)&Node.DOCUMENT_POSITION_FOLLOWING")
- self.assertPageContains("el.offsetParent===null||css.position!=='sticky'")
- self.assertPageContains("getComputedStyle(document.documentElement).scrollPaddingTop)||0")
- self.assertPageContains("stage.style.scrollMarginTop="
- "`${Math.max(0,itemDetailStickyOffset()+8-paved)}px`")
- self.assertIn("html{color-scheme:light;scroll-padding-top:calc(var(--topH) + 8px);",
- stylesheet_source())
+ def test_detail_dialog_uses_top_layer_and_preserves_list_position(self):
+ """原生模态浮窗提供顶层、焦点与退出行为,列表不参与详情布局。"""
+ self.assertPageContains("if(!stage.open)stage.showModal();")
+ self.assertPageContains("else{disposeStage(false,false,{miniplayer:false});route(detailReturnPath||'/');restoreRoute()}")
+ self.assertPageContains("if(stage.open)stage.close();")
+ self.assertPageContains("box.showModal();")
+ self.assertPageContains("if(stage.open)stage.append(menu);")
+ self.assertPageContains("max-height:calc(100dvh - 32px)")
+ self.assertPageLacks("stage.scrollIntoView(")
self.assertCode("buildBars();\n scrollItemDetailIntoView();")
def test_catalog_skeleton_collects_the_bottom_loading_dots(self):
@@ -8468,7 +8460,7 @@ class WebUiSourceTests(unittest.TestCase):
" return sortControlsHtml({\n"
" shuffleId:'followShuffle',shuffleClass:'',items:FOLLOW_FEED_SORTS,")
self.assertPageContains(''' extra:`<button type="button" class="followrecheck" data-follow-recheck title="检查更新"''')
- self.assertPageContains('''aria-label="检查全部来源的更新">${icon('refresh-cw')}</button>`+(followMediaView==='images'?photoControlsHtml():'')});''')
+ self.assertPageContains('''aria-label="检查全部来源的更新">${icon('refresh-cw')}</button>`+(followMediaView==='images'?photoControlsHtml({follow:true}):'')});''')
# 槽位只剩 extra 一个:排序键一律排在最末,挨着它说明的那批内容。
self.assertPageContains("export function sortControlsHtml({items=[],renderItem=String,extra='',"
"shuffleId='',shuffleClass='entitybatch'}={}){")
@@ -10376,7 +10368,7 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains('id="javImageSetting"')
self.assertPageContains("Object.assign(appSettings,normalizeJavPreferences(appSettings));")
self.assertPageContains("syncJavImages(document,appSettings.javImage);")
- self.assertPageContains("syncJavImages(box,appSettings.javImage);")
+ self.assertPageContains("syncJavImages(staging,appSettings.javImage);")
self.assertPageContains("? javArtwork(it,jav?layout:'small',eager)")
def test_jav_cover_source_and_size_are_independent_settings(self):
diff --git a/web/app.js b/web/app.js
index 64b43c836..2f4ee42c5 100644
--- a/web/app.js
+++ b/web/app.js
@@ -316,6 +316,7 @@ function showDetailLoading(){
const stage=$('#stage');
if(!stage.querySelector('[data-skeleton="detail"]'))stage.innerHTML=detailSkeletonHtml();
stage.hidden=false;document.body.classList.add('detail-open');
+ presentItemDetail();
}
/* 顶部三层只属于首页。深链启动时先画一遍再由路由收起来,等于向管理页和索引页
承诺了三条永远不会到货的横条。 */
@@ -1109,6 +1110,8 @@ function bindOutsideClose(anchor,inside,close){
}
function disposeStage(push=false,preserveInlineOrigin=false,{miniplayer=true}={}){
const stage=$('#stage');
+ closePlayerMenu();
+ if(stage.open)stage.close();
// 关注详情会把舞台插到头像和筛选条之后。离开详情前先放回 main 的固定槽位,
// 否则下一次重绘 #stats 会连同 #stage 一起删掉,后续所有详情都打不开。
const main=$('#main'),combo=$('#combo');
@@ -1378,6 +1381,8 @@ wireMiniplayer();
let playerMenuCleanup=null;
function closePlayerMenu(){
const menu=$('#playerMenu');
+ if(menu?.matches(':popover-open'))menu.hidePopover();
+ if(menu&&menu.parentElement!==document.body)document.body.append(menu);
if(menu)dismissMenu(menu,()=>{menu.innerHTML=''});
if(playerMenuCleanup){playerMenuCleanup();playerMenuCleanup=null}
}
@@ -1416,13 +1421,16 @@ function playerMenuItems(player){
function openPlayerMenu(player,x,y){
const menu=$('#playerMenu');if(!menu)return;
closePlayerMenu();
+ const stage=$('#stage');
+ if(stage.open)stage.append(menu);
+ menu.setAttribute('popover','manual');
const items=playerMenuItems(player);
menu.innerHTML=items.map((item,index)=>{
const checkable='checked' in item;
return `<button type="button" class="playermenuitem" role="${checkable?'menuitemcheckbox':'menuitem'}"${checkable?` aria-checked="${item.checked}"`:''} data-player-menu="${index}">${
icon(item.icon,item.fill?'playermenufill':'')}<span>${esc(item.label)}</span>${checkable?icon('check','playermenucheck'):''}</button>`;
}).join('');
- presentMenu(menu);
+ presentMenu(menu);menu.showPopover();
// 量 offsetWidth/offsetHeight:进场动画起手是 scale(.95),getBoundingClientRect 量到的是缩过的框。
menu.style.left=`${Math.max(8,Math.min(x,innerWidth-menu.offsetWidth-8))}px`;
menu.style.top=`${Math.max(8,Math.min(y,innerHeight-menu.offsetHeight-8))}px`;
@@ -1461,46 +1469,22 @@ function wirePlayerContextMenu(player){
function placeItemDetail(anchor,above=false){
const stage=$('#stage'),main=$('#main'),combo=$('#combo');
- if(!anchor?.isConnected){main.insertBefore(stage,combo);return}
- const card=anchor.closest('[data-id],[data-mix-seed]')||anchor;
- const container=card.parentElement;
- if(container&&getComputedStyle(container).display==='grid'){
- const top=card.getBoundingClientRect().top;
- const siblings=[...container.children].filter(item=>item!==stage&&!item.hidden);
- const row=siblings.filter(item=>Math.abs(item.getBoundingClientRect().top-top)<2);
- const edge=above?row[0]:row[row.length-1];
- if(edge)container.insertBefore(stage,above?edge:edge.nextSibling);
- else container.append(stage);
- return;
- }
- const block=card.closest('.shorts-inline,.srow,.nrow,section')||card;
- const parent=block.parentElement;
- if(parent)parent.insertBefore(stage,above?block:block.nextSibling);
- else main.insertBefore(stage,combo);
+ if(stage.parentElement!==main)main.insertBefore(stage,combo);
}
-function itemDetailStickyOffset(){
+function presentItemDetail(){
const stage=$('#stage');
- /* 玻璃筛选条把 `#tagbar` 与 `#count` 收进 `.board-filter-frame` 之后,粘住的是外面这一层,
- 里面两条成了 `position:relative`。只按里面两个名字量就只剩顶栏那 64px:详情停在 144px,
- 筛选条底边却在 168px,最上面 24px 连同关闭键一起压在它下面。 */
- return ['.top','.board-filter-frame','#tagbar','#count','.entitytagbar','.entitycollectionhead'].reduce((bottom,selector)=>{
- const el=$(selector),css=el&&getComputedStyle(el);
- const beforeStage=!!el&&(el.compareDocumentPosition(stage)&Node.DOCUMENT_POSITION_FOLLOWING);
- if(!beforeStage||el.offsetParent===null||css.position!=='sticky')return bottom;
- const top=parseFloat(css.top);
- return Number.isFinite(top)?Math.max(bottom,top+el.getBoundingClientRect().height):bottom;
- },0);
+ if(stage.hidden)return;
+ stage.oncancel=event=>{
+ event.preventDefault();const close=$('#closeStage');
+ if(close)close.click();
+ else{disposeStage(false,false,{miniplayer:false});route(detailReturnPath||'/');restoreRoute()}
+ };
+ if(!stage.open)stage.showModal();
}
function scrollItemDetailIntoView(){
- const stage=$('#stage');
- /* `html` 的 `scroll-padding-top` 已经替顶栏留了一段,它和 `scroll-margin-top` 是叠加的:
- 把顶栏那 72px 再算一遍,落点就比要的位置低整整一个顶栏。扣掉它之后这个数只负责
- 顶栏以外还粘着的东西,也就是筛选条那一层。 */
- const paved=parseFloat(getComputedStyle(document.documentElement).scrollPaddingTop)||0;
- stage.style.scrollMarginTop=`${Math.max(0,itemDetailStickyOffset()+8-paved)}px`;
- stage.scrollIntoView({behavior:'auto',block:'start'});
+ presentItemDetail();
scheduleStickySurfaces();
}
function bufferedAhead(video){
@@ -3124,30 +3108,56 @@ const reduceMotion=()=>matchMedia('(prefers-reduced-motion:reduce)').matches;
缩略图,两处共用同一套时序和门槛,不各写一份动效。 */
function wireStackFlip(el,loadFaces){
const box=el.querySelector('[data-mix-faces]');if(!box)return;
- let armed=null,lead=null,cycle=null,faces=[],index=0,live=false;
+ let armed=null,lead=null,cycle=null,faces=[],index=0,live=false,generation=0;
+ const pending=new Set(),cleanups=new Set();
const stop=()=>{
- live=false;clearTimeout(armed);armed=null;clearTimeout(lead);lead=null;
+ live=false;generation++;clearTimeout(armed);armed=null;clearTimeout(lead);lead=null;
clearInterval(cycle);cycle=null;
+ pending.forEach(cancel=>cancel());cleanups.forEach(clearTimeout);cleanups.clear();
box.hidden=true;box.innerHTML='';faces=[];index=0;
};
+ const readyImage=img=>new Promise(resolve=>{
+ let settled=false;
+ const finish=ok=>{if(settled)return;settled=true;clearTimeout(timeout);
+ img.removeEventListener('load',loaded);img.removeEventListener('error',failed);
+ pending.delete(cancel);resolve(ok)};
+ const cancel=()=>finish(false),failed=()=>finish(false);
+ const loaded=()=>{if(!img.naturalWidth){finish(false);return}
+ if(typeof img.decode==='function')img.decode().then(()=>finish(true),failed);
+ else finish(true)};
+ const timeout=setTimeout(failed,5000);
+ pending.add(cancel);img.addEventListener('load',loaded);img.addEventListener('error',failed);
+ if(img.complete)loaded();
+ });
const step=()=>{
+ if(!live||faces.length<2)return;
const out=faces[index],next=faces[(index+1)%faces.length];
out.classList.remove('on');out.classList.add('off');
next.classList.remove('off');next.classList.add('on');
// 翻出去的那张得先演完才能卸掉 off,否则会当场弹回原位。
- setTimeout(()=>{if(out!==next)out.classList.remove('off')},MIX_FLIP_MS-120);
+ const cleanup=setTimeout(()=>{out.classList.remove('off');cleanups.delete(cleanup)},MIX_FLIP_MS-120);
+ cleanups.add(cleanup);
index=(index+1)%faces.length;
};
const start=async()=>{
if(selectMode||censorOn()||window.__scrolling||reduceMotion())return;
- live=true;
+ if(live)return;
+ live=true;const current=++generation;
let pool=[];
try{pool=await loadFaces()}catch(_e){return}
- if(!live||selectMode||censorOn())return;
+ if(!live||current!==generation||selectMode||censorOn())return;
if(pool.length<2)return;
- box.innerHTML=pool.map((face,i)=>`<div class="mixface${i?'':' on'}">${face}</div>`).join('');
- syncJavImages(box,appSettings.javImage);
- faces=[...box.children];index=0;box.hidden=false;
+ const staging=document.createElement('div');
+ staging.innerHTML=pool.map(face=>`<div class="mixface">${face}</div>`).join('');
+ syncJavImages(staging,appSettings.javImage);
+ const candidates=[...staging.children];
+ const ready=await Promise.all(candidates.map(async face=>{
+ const images=[...face.querySelectorAll('img')];
+ return images.length>0&&(await Promise.all(images.map(readyImage))).every(Boolean)}));
+ if(!live||current!==generation||selectMode||censorOn()||window.__scrolling)return;
+ faces=candidates.filter((_face,i)=>ready[i]);
+ if(faces.length<2)return;
+ faces[0].classList.add('on');box.replaceChildren(...faces);index=0;box.hidden=false;
lead=setTimeout(()=>{step();cycle=setInterval(step,MIX_FLIP_MS)},MIX_FLIP_LEAD_MS);
};
el.addEventListener('mouseenter',()=>{clearTimeout(armed);armed=setTimeout(start,340)});
@@ -5589,7 +5599,7 @@ async function openFollowDetail(id,push=true,mediaIndex=null,preserveReturn=fals
?`<img class="followdetailposter" src="${src}" alt="${esc(item.title)}">`
:item.thumb_url
?`<img class="followdetailposter" src="${esc(item.thumb_url)}" alt="${esc(item.title)}" referrerpolicy="no-referrer">`
- :`<div class="followdetailplaceholder">${sourceIcon(item.provider)}<span>没有可用预览</span></div>`;
+ :`<div class="followdetailplaceholder">${sourceIcon(item.resource_provider||item.provider)}<span>没有可用预览</span></div>`;
const imageControls=imageCarousel?`<button class="media-circle media-overlay followimagearrow prev" data-follow-image-step="-1" aria-label="上一张图片" title="上一张">${icon('chevron-left')}</button>
<button class="media-circle media-overlay followimagearrow next" data-follow-image-step="1" aria-label="下一张图片" title="下一张">${icon('chevron-right')}</button>
<div class="followimagedots" role="group" aria-label="${imageMedia.length} 张图片">${imageMedia.map((image,index)=>`<button data-follow-image-item="${image.index}" aria-current="${index===imagePosition}" aria-label="第 ${index+1} 张,共 ${imageMedia.length} 张" title="第 ${index+1} 张"></button>`).join('')}</div>`:'';
@@ -5599,31 +5609,7 @@ async function openFollowDetail(id,push=true,mediaIndex=null,preserveReturn=fals
const author=followAuthorName(authorSources)||item.author||item.source_label||'创作者未取得';
const postedBy=item.author&&foldName(item.author)!==foldName(author)?item.author:'';
const mediaIssue=followMediaIssue(item);
- /* 舞台就近展开:插在被点击那张卡片所在的一行之后,而不是整个列表之前。
- 插在列表前等于永远回到页面顶部——翻了几屏点开一条,视线要被拽回最上面,
- 关掉后还得再翻回来。首页的详情早就是就近展开的,关注页一直没跟上。
-
- 按行插入而不是紧跟卡片:列表是网格,插在某张卡片正后面会把它那一行截断。
- 行的判定用 offsetTop——同一行的卡片顶边相同。 */
- const followList=$('#stats').querySelector('.followlist');
- const clicked=followList&&followList.querySelector(`[data-follow-item="${item.id}"]`);
- if(followList?.classList.contains('followphotowall')){
- /* 图片墙是稳定网格;详情独立放在墙前,避免成为网格子项并改变所有行的排列。 */
- followList.before($('#stage'));
- }else if(clicked){
- const cards=[...followList.children];
- const row=clicked.offsetTop;
- // 同一行里最后一张卡片:它之后就是插入点。
- let last=clicked;
- for(const card of cards){
- if(Math.abs(card.offsetTop-row)<2)last=card;
- }
- last.after($('#stage'));
- }else if(followList){
- followList.before($('#stage'));
- }else{
- placeItemDetail(detailOriginAnchor,detailOriginAbove);
- }
+ placeItemDetail(detailOriginAnchor,detailOriginAbove);
$('#stage').hidden=false;document.body.classList.add('detail-open');
$('#stage').innerHTML=`<div class="sgrid followdetailgrid${collection||embeddedQueue?' mixgrid':''}">
<div class="vwrap followdetailmedia${selectedKind==='image'?' image':''}">${selectedKind==='video'?'<canvas class="ambientcanvas" width="32" height="18"></canvas>':''}<button class="closestage" id="closeStage" title="关闭" aria-label="关闭">${icon('x')}</button>${selectedKind==='video'?playerStatsOverlayHtml():''}${media}${imageControls}</div>
@@ -5655,7 +5641,7 @@ async function openFollowDetail(id,push=true,mediaIndex=null,preserveReturn=fals
disposeStage(false,false,{miniplayer:false});
route(followDetailReturnPath||'/follow');
if(location.pathname!=='/follow'){await restoreRoute();return}
- if(followData)renderFollow();else await openFollow(false);
+ if(!$('#stats .followlist')){if(followData)renderFollow();else await openFollow(false)}
};
$('#closeStage').onclick=closeDetail;
$('#stage').querySelectorAll('[data-follow-queue-close]').forEach(button=>button.onclick=closeDetail);
@@ -5777,7 +5763,7 @@ function followCard(group,authorSources=[]){
const thumbUrl=selectedMedia?.thumb_url||item.thumb_url;
const thumb=thumbUrl
? `<img src="${esc(thumbUrl)}" alt="" loading="lazy" referrerpolicy="no-referrer" data-drop="self">`
- : `<span class="fnothumb">${esc(item.provider_label)}</span>`;
+ : `<span class="fnothumb">${sourceIcon(item.resource_provider||item.provider)}</span>`;
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');
@@ -5966,7 +5952,7 @@ function followFeedControlsHtml(){
shuffleId:'followShuffle',shuffleClass:'',items:FOLLOW_FEED_SORTS,
renderItem:([key,label])=>sortButtonHtml(key,label,followSort,followDir,'data-follow-sort',FOLLOW_FEED_DIR_WORDS),
extra:`<button type="button" class="followrecheck" data-follow-recheck title="检查更新"
- aria-label="检查全部来源的更新">${icon('refresh-cw')}</button>`+(followMediaView==='images'?photoControlsHtml():'')});
+ aria-label="检查全部来源的更新">${icon('refresh-cw')}</button>`+(followMediaView==='images'?photoControlsHtml({follow:true}):'')});
}
/* 看的那一页上唯一一次联网:去问每个来源有没有新东西。管理页那几枚按的是同一条路径,
区别在它还要把失败详情摊进那一页的报告块;这一页上没有放报告的地方,失败只留一条
@@ -8002,19 +7988,23 @@ function photoSize(){
function photoLayout(){return allowedSetting(appSettings.photoLayout,['fixed','masonry'],'masonry')}
function photoViewActive(){return [...document.querySelectorAll('.photowall,.followphotowall')]
.some(wall=>wall.getClientRects().length>0)}
-function photoControlsHtml(){return iconSwitchHtml('photo-size','照片大小',PHOTO_SIZES,photoSize(),
- {attr:'data-photo-size',className:'photosize'})+iconSwitchHtml('photo-layout','图片布局',PHOTO_LAYOUTS,photoLayout(),
- {attr:'data-photo-layout',className:'photolayout'})}
+function photoControlsHtml({follow=false}={}){return iconSwitchHtml('photo-layout','图片布局',PHOTO_LAYOUTS,photoLayout(),
+ {attr:'data-photo-layout',className:'photolayout'})+(follow?`<button type="button" data-follow-images-only aria-pressed="${!!appSettings.followImagesOnly}">仅显示图片</button>`:'')}
function syncPhotoWalls(){
document.querySelectorAll('.photowall,.followphotowall').forEach(wall=>{
wall.dataset.size=photoSize();wall.dataset.layout=wall.closest('.skeletonpanel')?'fixed':photoLayout()});
+ document.querySelectorAll('.followphotowall').forEach(wall=>{
+ wall.dataset.imagesOnly=String(!!appSettings.followImagesOnly)});
if(photoViewActive()){
$('#density').setAttribute('aria-pressed',String(photoSize()==='small'));
$('#density').title='当前:'+(photoSize()==='big'?'大图':'小图');
}else applyDensity();
}
function wirePhotoControls(root){
- wireIconSwitch(root,'data-photo-size',setPhotoSize);
+ const imagesOnly=root?.querySelector('[data-follow-images-only]');
+ if(imagesOnly)imagesOnly.onclick=()=>{
+ appSettings.followImagesOnly=!appSettings.followImagesOnly;saveSettings();syncPhotoWalls();
+ imagesOnly.setAttribute('aria-pressed',String(appSettings.followImagesOnly))};
wireIconSwitch(root,'data-photo-layout',value=>{
appSettings.photoLayout=allowedSetting(value,['fixed','masonry'],'masonry');saveSettings();syncPhotoWalls()});
}
@@ -8023,8 +8013,6 @@ function wirePhotoControls(root){
function setPhotoSize(value){
appSettings.photoSize=allowedSetting(value,PHOTO_SIZES.map(([key])=>key),'small');
saveSettings();
- document.querySelectorAll('[data-photo-size]').forEach(input=>{
- input.checked=input.value===appSettings.photoSize});
syncPhotoWalls();
}
const photoCell=(item,index)=>`<button class="photocell" data-photo-index="${index}" title="${esc(item.name)}">
@@ -8191,7 +8179,7 @@ function wirePhotoZoom(box, main){
const slider=box.querySelector('.photozoom input');
const label=box.querySelector('.photozoom b');
let target='fit';
- const image=()=>main.slides[main.activeIndex]?.querySelector('img');
+ const image=()=>main.slides?.[main.activeIndex]?.querySelector('img');
const fitPercent=()=>{
const img=image();
if(!img?.naturalWidth||!img.naturalHeight)return 100;
@@ -8199,6 +8187,7 @@ function wirePhotoZoom(box, main){
};
const show=percent=>{const value=Math.round(percent);slider.value=value;label.textContent=value+'%';syncBoardRange(slider)};
const apply=raw=>{
+ if(main.destroyed||!box.isConnected)return;
const fit=fitPercent();
const percent=raw==='fit'?fit:Math.min(PHOTO_ZOOM_MAX,Math.max(PHOTO_ZOOM_MIN,Number(raw)||fit));
target=raw==='fit'?'fit':percent;show(percent);
@@ -8268,7 +8257,7 @@ function closePhotoLightbox(){
activeLightbox.detail?.dismiss();
activeLightbox.resize?.disconnect();
activeLightbox.main.destroy(true,true);activeLightbox.strip.destroy(true,true);
- activeLightbox.box.remove();activeLightbox=null;
+ activeLightbox.box.close();activeLightbox.box.remove();activeLightbox=null;
document.body.classList.remove('photolight-open');
}
async function openPhotoLightbox(index,source=null){
@@ -8278,7 +8267,8 @@ async function openPhotoLightbox(index,source=null){
try{SwiperCtor=await loadSwiper()}
catch(_e){window.open(items[index].src,'_blank','noopener');return}
closePhotoLightbox();
- const box=document.createElement('div');
+ const box=document.createElement('dialog');
+ box.setAttribute('aria-label','图片浏览');
box.className='photolight'+(items.length>1?' has-strip':'');
box.innerHTML=`<button class="media-circle media-overlay photoclose" type="button" aria-label="关闭">${icon('x')}</button>
<div class="swiper photomain" role="region" aria-roledescription="轮播" aria-label="图片浏览"><div class="swiper-wrapper">${items.map(item=>
@@ -8308,6 +8298,8 @@ async function openPhotoLightbox(index,source=null){
<div class="swiper photostrip"><div class="swiper-wrapper">${items.map(item=>
`<div class="swiper-slide"><img src="${esc(item.thumb)}" alt="" loading="lazy" referrerpolicy="no-referrer"></div>`).join('')}</div></div>`;
document.body.appendChild(box);
+ box.showModal();
+ box.oncancel=event=>{event.preventDefault();closePhotoLightbox()};
document.body.classList.add('photolight-open');
const counter=box.querySelector('.photocount');
const strip=new SwiperCtor(box.querySelector('.photostrip'),{
diff --git a/web/css/08-photos.css b/web/css/08-photos.css
index 4d1610b2d..d270dfd74 100644
--- a/web/css/08-photos.css
+++ b/web/css/08-photos.css
@@ -30,6 +30,7 @@
旧三行 grid 会和动态后载的 Swiper 百分比高度形成循环,超宽视口下主图行收成 0,
结果就是工具跑到顶部、缩略图贴左、原图按自然尺寸溢出。 */
.photolight{position:fixed;inset:0;z-index:200;background:#000;display:block;overflow:hidden}
+.photolight:modal{margin:0;padding:0;border:0;max-width:none;max-height:none;width:100vw;height:100dvh;color:#fff}
body.photolight-open{overflow:hidden}
/* 主画布始终占满视口,安全内边距为顶部工具、左右翻页和底部缩略图留位;
单图没有缩略图条,底部空间会自动还给图片。 */
diff --git a/web/css/12-cards.css b/web/css/12-cards.css
index d0028f438..28c0deb26 100644
--- a/web/css/12-cards.css
+++ b/web/css/12-cards.css
@@ -112,7 +112,7 @@ body.refreshing #batchAction svg,
.mixfaces{position:absolute;inset:0;z-index:2;pointer-events:none;background:#000} /* 遮住静止封面:不遮的话两张正在交接的时候它会从中间透出来 */
.mixface{position:absolute;inset:0;opacity:0;transform:scale(.985);transform-origin:50% 88%;
transition:transform .46s cubic-bezier(.34,.02,.24,1),opacity .4s ease}
-.mixface.on{opacity:1;z-index:2;transform:none}
+.mixface.on{opacity:1;z-index:2;transform:none;transition:none}
.mixface.off{opacity:0;z-index:3;transform:translateY(-11%) rotate(-3.4deg) scale(.94)}
.mixbadge{position:absolute;right:9px;bottom:9px;z-index:6;display:flex;align-items:center;gap:6px;
min-height:28px;padding:4px 9px;border-radius:var(--control-radius);background:rgba(12,8,8,.72);color:#fff;
diff --git a/web/css/13-stage.css b/web/css/13-stage.css
index e3d77a1fe..69f454a12 100644
--- a/web/css/13-stage.css
+++ b/web/css/13-stage.css
@@ -1,12 +1,16 @@
-/* ── 放大播放(就地展开) ── */
+/* ── 作品详情浮窗 ── */
/* 氛围色定义在这里,右侧详情栏、切换队列和「接着看」共用同一档。三块同属
一格详情,底色差 4% 就会在整幅宽度上留下一条界线,看着像两块面板拼起来;
分块靠留白和小标题,不靠色差。 */
.stage{--detail-surface:color-mix(in srgb,var(--video-glow,#15202a) 12%,var(--surface) 88%);
- margin:0 0 22px;border-radius:var(--floating-radius);
+ position:fixed;inset:16px;margin:auto;padding:0;width:min(1440px,calc(100vw - 32px));
+ max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);height:fit-content;
+ color:var(--ink);border-radius:var(--floating-radius);overscroll-behavior:contain;
background:radial-gradient(circle at 28% 24%,color-mix(in srgb,var(--video-glow,#15202a) 40%,transparent),transparent 58%),
color-mix(in srgb,var(--surface) 88%,transparent);scroll-margin-top:calc(var(--topH) + 8px);
- border:1px solid var(--line);overflow:hidden}
+ border:1px solid var(--line);overflow:auto}
+.stage::backdrop{background:rgba(0,0,0,.35)}
+body.detail-open{overflow:hidden}
.stage:not(.ambient-on){background:color-mix(in srgb,var(--surface) 88%,transparent)}
.stage[hidden]{display:none}
.grid>.stage{grid-column:1/-1;width:100%;min-width:0}
diff --git a/web/css/21-online.css b/web/css/21-online.css
index 826b10139..c5efc8378 100644
--- a/web/css/21-online.css
+++ b/web/css/21-online.css
@@ -23,6 +23,8 @@
@media (max-width:1400px){.followlist.followphotowall{grid-template-columns:repeat(4,minmax(0,1fr))}}
@media (max-width:1000px){.followlist.followphotowall{grid-template-columns:repeat(3,minmax(0,1fr))}}
.followitem{min-width:0}
+.followphotowall[data-images-only="true"] .followitem :is(.meta,.badge,.mixbadge,.fstate){display:none}
+.followphotowall[data-images-only="true"] .skeletoncard :is(b,em){display:none}
.followitem.imagecard{display:flex;width:100%;margin:0}
.followitem.imagecard .pic{aspect-ratio:4/3;min-height:0;background:var(--sunk)}
.followitem.imagecard .followvisual .pic>img{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;background:var(--sunk)}
diff --git a/web/css/24-miniplayer.css b/web/css/24-miniplayer.css
index dff0ac7ad..7822319bb 100644
--- a/web/css/24-miniplayer.css
+++ b/web/css/24-miniplayer.css
@@ -76,6 +76,7 @@
左右各 10px),标签右留 15px,悬停 rgba(255,255,255,.1);勾选项右侧 24px 白勾。字号取实测 13px。 */
.popmenu.playermenu{padding:8px 0;border:0;gap:0;background:rgba(0,0,0,.6);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);
box-shadow:none;color:#eee;min-width:220px;max-width:calc(100vw - 16px);text-shadow:0 0 1px rgba(0,0,0,.8)}
+.playermenu[popover]{inset:auto;margin:0}
.playermenuitem{box-sizing:border-box;display:grid;grid-template-columns:44px minmax(0,1fr) 44px;align-items:center;width:100%;height:40px;
margin:0;padding:0 15px 0 0;border:0;border-radius:0;background:transparent;color:inherit;font:inherit;font-size:var(--fs-sm);font-weight:500;line-height:1.3;text-align:left;white-space:nowrap;cursor:pointer}
.playermenuitem:hover,.playermenuitem:focus-visible{background:rgba(255,255,255,.1);outline:0}
diff --git a/web/index.html b/web/index.html
index 9d736b8c0..5b927e91f 100644
--- a/web/index.html
+++ b/web/index.html
@@ -208,7 +208,7 @@
<main id="main" tabindex="-1">
<div id="libraryProcessingNotice"></div>
- <section class="stage" id="stage" hidden></section>
+ <dialog class="stage" id="stage" aria-label="作品详情" hidden></dialog>
<div class="combo" id="combo"></div>
<section class="index" id="index" hidden></section>
<nav class="managebar" id="managebar" hidden></nav>
diff --git a/web/js/ui-components.js b/web/js/ui-components.js
index 7074b8e24..223fd3bf8 100644
--- a/web/js/ui-components.js
+++ b/web/js/ui-components.js
@@ -142,7 +142,7 @@ export function mountFilterFrame(top,bottom,{views,tags,readout,controls}){
const previous=frame.querySelector('[data-filter-row="bottom"]');
if(previous!==bottom){
const active=document.activeElement;
- const key=previous?.contains(active)?['id','data-sort','data-entity-sort','data-photo-size','aria-label'].map(attr=>[attr,active.getAttribute(attr)]).find(([,value])=>value):null;
+ const key=previous?.contains(active)?['id','data-sort','data-entity-sort','aria-label'].map(attr=>[attr,active.getAttribute(attr)]).find(([,value])=>value):null;
previous?.remove();frame.append(bottom);
if(key)[...bottom.querySelectorAll('button,input,[tabindex]')].find(node=>node.getAttribute(key[0])===key[1])?.focus({preventScroll:true});
}