Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 统一图片大小与瀑布流切换并修复关注卡片封面

longmeidao2bf6cf3b7b59
diff --git a/docs/REUSE.md b/docs/REUSE.md
index 1b24e35d4..f73119086 100644
--- a/docs/REUSE.md
+++ b/docs/REUSE.md
@@ -186,7 +186,7 @@ CloudDrive 为外部应用,本项目不捆绑其二进制或依赖其管理 AP
- JAV 官方封面重探只在面积更大时替换,失败保留原图。
- 播放器按 YouTube 锁定源码对齐控件、状态、图标形变、设置面板动画与悬停提示,倍速五格到 3.0,窄屏按播放器宽度折叠留黑边,沉浸模式按 Shorts 版式,竖屏用居中 9:16 舞台,播放统计两页共用、按传输方式分口径。
- 图片灯箱在本地照片和关注在线图片间复用同一套 Swiper,在线图片只显示来源、合集序号和浏览器实际解析结果;照片标签进入分页图片墙,点开才按原图比例呈现。
-- 账本没有图片宽高,两处图片墙(资料页照片、关注在线图片)一律等宽网格配固定比例格子,不用多列流式排版:缩略图懒加载到达之前每格高度是 0,分栏按零高摊格子,会把一屏格子整批塞进最后一列。格子按比例占位之后,等图那一刻浏览器有地方画 `alt`,一屏就是满屏文件名;字色调透明隐去,`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()`。
- 一个控件在两页出现时,选中态怎么表现也归它,不只是外框和材质:首页与资料页的「全部/没看过/稍后看/已标记」共用 `syncViewGlide` 那块滑动玻璃,填充只由玻璃给,两排各自不铺底。找那一排按结构(`#viewPills,.entityviews`)加「此刻量得出宽度」,不按 id:两排在同一份文档里一直都在,另一页开着的时候只是被祖先收起来,写死 id 会一直取到看不见的那一排。
- 统计与口味两页按登录态 Vercel Analytics/Speed Insights 的当前页面重做,排行与数据源共用父网格的引导线。
diff --git a/scripts/vendor_web_dependencies.mjs b/scripts/vendor_web_dependencies.mjs
index acca1ef51..106479b65 100644
--- a/scripts/vendor_web_dependencies.mjs
+++ b/scripts/vendor_web_dependencies.mjs
@@ -83,6 +83,7 @@ const lucideIcons = new Map([
["clapperboard", "clapperboard"], ["briefcase", "briefcase"],
["home", "home"], ["panel-left", "panel-left"], ["search", "search"],
["layout-grid", "layout-grid"], ["square-check-big", "square-check-big"],
+ ["columns-2", "columns-2"],
["refresh-cw", "refresh-cw"], ["user-round", "user-round"], ["tags", "tags"],
["list-filter", "list-filter"], ["chart", "chart-no-axes-column"],
["settings", "settings"], ["gauge", "gauge"],
diff --git a/src/peach/follow_covers.py b/src/peach/follow_covers.py
index 109bc74e9..d07c9654a 100644
--- a/src/peach/follow_covers.py
+++ b/src/peach/follow_covers.py
@@ -64,11 +64,19 @@ class FollowCoverService:
self._slots = threading.BoundedSemaphore(2)
def cover(self, item: FollowItemRow) -> Path:
- if (item.provider != "rule34paheal"
+ media_index = None
+ if item.provider == "fanbox":
+ media_index = next((index for index, media in enumerate(
+ item.metadata.get("media_items") or []) if isinstance(media, dict)
+ and media.get("media_kind") == "video"
+ and media.get("resource_provider") == "fanbox"), None)
+ if not (item.provider == "fanbox" and media_index is not None) and (
+ item.provider != "rule34paheal"
or str(item.metadata.get("media_kind") or "") != "video"):
raise FollowCoverUnavailable("该条目不需要生成视频封面")
try:
- target = self.media_resolver.resolve(item)
+ target = (self.media_resolver.resolve(item, media_index)
+ if media_index is not None else self.media_resolver.resolve(item))
except FollowMediaUnavailable as exc:
raise FollowCoverUnavailable(str(exc)) from exc
choice = self.resolver.ffmpeg()
@@ -90,13 +98,14 @@ class FollowCoverService:
f"{destination.stem}.{os.getpid()}.{threading.get_ident()}.tmp.jpg")
command = [
str(choice.path), "-y", "-v", "error",
+ "-threads", "2", "-filter_threads", "1",
"-rw_timeout", "15000000", "-user_agent", USER_AGENT,
]
if target.referer:
command.extend(("-referer", target.referer))
command.extend((
"-t", str(FOLLOW_COVER_SCAN_SECONDS), "-i", target.url,
- "-frames:v", "1", "-vf", FOLLOW_COVER_FILTER, "-update", "1",
+ "-frames:v", "1", "-threads", "2", "-vf", FOLLOW_COVER_FILTER, "-update", "1",
"-q:v", "4", str(temporary),
))
try:
diff --git a/src/peach/web_follow.py b/src/peach/web_follow.py
index 2bf2b334b..bcf168740 100644
--- a/src/peach/web_follow.py
+++ b/src/peach/web_follow.py
@@ -623,6 +623,15 @@ def _thumb_url(item) -> str | None:
/follow-cover 抽首帧并缓存。这两条是 Peach 自己的路由决定,所以留在这一层;
其余全是「这个站的缩略图 URL 长什么样」,那是站点知识,实现在各连接器里。
"""
+ if item.provider == "fanbox":
+ thumb = display_thumb_url(item)
+ media_items = item.metadata.get("media_items") or []
+ videos = [media for media in media_items if isinstance(media, dict)
+ and media.get("media_kind") == "video"
+ and media.get("resource_provider") == "fanbox"]
+ if videos and (not thumb or thumb in {media.get("url") for media in videos}
+ or urllib.parse.urlsplit(thumb).path.lower().endswith((".mp4", ".webm", ".mov", ".m4v"))):
+ return f"/follow-cover?id={item.id}"
if item.provider == "rule34paheal" and item.media_url:
kind = _media_kind(item)
if kind == "image":
diff --git a/tests/test_follow_covers.py b/tests/test_follow_covers.py
index 03b16d89c..223445404 100644
--- a/tests/test_follow_covers.py
+++ b/tests/test_follow_covers.py
@@ -111,7 +111,26 @@ class FollowCoverServiceTests(unittest.TestCase):
self.assertLess(green, 80)
self.assertLess(blue, 80)
- def test_only_paheal_videos_enter_the_generator(self):
+ def test_fanbox_uses_first_video_after_images_and_caches_it(self):
+ item = self._item("fanbox")
+ item.metadata = {"media_items": [
+ {"media_kind": "image", "resource_provider": "fanbox"},
+ {"media_kind": "video", "resource_provider": "fanbox"},
+ ]}
+ resolver = mock.Mock()
+ resolver.resolve.return_value = ResolvedFollowMedia(
+ "https://downloads.fanbox.cc/files/video.mp4", item.url)
+ service = FollowCoverService(_FFmpeg(), resolver, self.root)
+ def run(command, **kwargs):
+ Path(command[-1]).write_bytes(b"jpeg")
+ return subprocess.CompletedProcess(command, 0, b"", b"")
+ with mock.patch("peach.follow_covers.subprocess.run", side_effect=run) as ffmpeg:
+ first = service.cover(item)
+ self.assertEqual(service.cover(item), first)
+ resolver.resolve.assert_called_with(item, 1)
+ self.assertEqual(ffmpeg.call_count, 1)
+
+ def test_only_supported_videos_enter_the_generator(self):
for provider, kind in (("rule34xxx", "video"),
("rule34paheal", "image")):
with self.subTest(provider=provider, kind=kind):
diff --git a/tests/test_follow_web.py b/tests/test_follow_web.py
index 7094e5b70..453477cdb 100644
--- a/tests/test_follow_web.py
+++ b/tests/test_follow_web.py
@@ -559,6 +559,19 @@ class FollowContractTests(unittest.TestCase):
f"/follow-stream?id={items['image']['id']}")
self.assertNotIn("r34i.paheal-cdn.net", json.dumps(items))
+ def test_fanbox_video_poster_uses_cover_when_missing_or_a_video_url(self):
+ video = "https://downloads.fanbox.cc/files/example.mp4"
+ image = "https://downloads.fanbox.cc/images/example.jpeg"
+ self._seed(candidates=tuple(FollowCandidate(
+ provider="fanbox", external_id=str(index), title=f"Clip {index}",
+ url=f"https://creator.fanbox.cc/posts/{index}", thumb_url=thumb,
+ extra={"media_items": [{"media_kind": "video", "resource_provider": "fanbox", "url": video}]},
+ ) for index, thumb in enumerate((None, video, image), 1)), provider="fanbox", ref="creator")
+ items = {group["primary"]["external_id"]: group["primary"] for group in self._get()["groups"]}
+ for key in ("1", "2"):
+ self.assertEqual(items[key]["thumb_url"], f"/follow-cover?id={items[key]['id']}")
+ self.assertEqual(items["3"]["thumb_url"], image)
+
def test_named_large_collection_is_hidden_but_not_deleted(self):
self._seed(candidates=(FollowCandidate(
provider="rule34video", external_id="4533145", title="Large collection",
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 771043171..905dc0b31 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -7327,7 +7327,7 @@ class WebUiSourceTests(unittest.TestCase):
"const pageSkeletonHtml=(label,{cards=false,className='',variant='',count,fill}={})=>")
self.assertPageContains("skeletonHtml(label,{variant:variant||(cards?'cards':'panel'),className,")
self.assertPageContains(
- "export function skeletonHtml(label='正在读取内容',{className='',variant='panel',count=6,fill=true,gridClass=''}={})")
+ "export function skeletonHtml(label='正在读取内容',{className='',variant='panel',count=6,fill=true,gridClass='',gridSize=''}={})")
self.assertPageContains("?Array.from({length:Math.max(1,count)},")
# 版式:一列对上 .followmanage,宽度也跟它一样是 812px 居中。
self.assertPageContains(
@@ -8265,6 +8265,8 @@ class WebUiSourceTests(unittest.TestCase):
".avatarpick-cell span",
".entitylinklabel",
".fauthor .fsource.frow>b", ".fauthorhead b",
+ # 作者是展示名,尾部省略;完整身份保留在 title。
+ ".followbyline .followauthor",
# 四段计数按重要性从左排(未看在最前),尾部省略切掉的正是最不影响判断的那几段;
# 它不是标识符,中间截断只会把「未看 3」也切开。
".fbulkcounts",
@@ -8466,7 +8468,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>`});''')
+ self.assertPageContains('''aria-label="检查全部来源的更新">${icon('refresh-cw')}</button>`+(followMediaView==='images'?photoControlsHtml():'')});''')
# 槽位只剩 extra 一个:排序键一律排在最末,挨着它说明的那批内容。
self.assertPageContains("export function sortControlsHtml({items=[],renderItem=String,extra='',"
"shuffleId='',shuffleClass='entitybatch'}={}){")
@@ -10915,21 +10917,7 @@ class WebUiSourceTests(unittest.TestCase):
".photowall{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px}")
def test_photo_wall_columns_all_start_at_the_top_before_any_thumbnail_arrives(self):
- """每格先占好位置,分栏不再取决于哪几张图先到。
-
- 账本没有图片宽高,缩略图带 `loading="lazy"`,到达之前每格高度是 0。多列流式排版
- 按分栏那一刻的高度摊格子:一屏 240 个零高的格子会被整批摊进最后一列,前几列只
- 留下已经加载出来的十几张,右边几列从顶上就空着,390 宽的手机上收成半幅一列。
- 实测 1440×900 那一屏是 12/12/12/12/192,最后一列一个人扛下 192 格。
-
- 齐平还顺带修掉一件事:墙塌成零高时「载入更多」一开页就在视口里,自动翻页会连着
- 触发,一进来就是 240 项。
-
- 固定比例的格子与加载顺序无关。关注页的图片墙同样是从多列换成网格才稳住的,
- 那边的判据在 `tests/test_follow_web.py`。方框配 cover 是因为这个库横竖两种取景
- 各占一半(805 张已缓存缩略图里 415 横 381 竖),任何一种长框都会把另一半压成
- 一条;点开灯箱仍是全图。
- """
+ """固定比例格子和瀑布流图片都在懒加载前占位,防止零高分栏和连续自动翻页。"""
self.assertPageContains(
".photowall{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px}")
self.assertPageContains(
@@ -10944,7 +10932,6 @@ class WebUiSourceTests(unittest.TestCase):
for lacking, why in (
(".photowall{column-count:5;column-gap:10px}", "多列流式排版会按零高摊格子"),
(".photowall{column-count:2;column-gap:8px}", "窄屏那两列同样不能靠图片撑高"),
- ("break-inside:avoid", "网格里没有需要避免的断栏"),
(".photocell img{width:100%;height:auto", "高度得由格子给,不能等图片撑"),
):
self.assertPageLacks(lacking, why)
@@ -10977,7 +10964,7 @@ class WebUiSourceTests(unittest.TestCase):
照片视图下收起来。等着的那一下骨架也带着下半,浮层不会缺一截。"""
self.assertPageContains("const photoHeadHtml=(data,{back=false}={})=>collectionHeaderHtml({className:'photohead'")
self.assertPageContains(
- "controls:sortControlsHtml({extra:iconSwitchHtml('photo-size','照片大小',PHOTO_SIZES,photoSize(),")
+ "controls:sortControlsHtml({extra:photoControlsHtml()")
self.assertPageLacks("photorefresh")
self.assertPageContains("shufflePhotos(kind,name,filters,entityWide?0:data.id,event.currentTarget)")
# 换过一批,后面几页沿用同一粒种子。
@@ -10985,7 +10972,11 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("offset=${photoWallItems.length}${seed}`")
# 大小:存进设置,改的只是那面墙上的一个属性。
self.assertPageContains("photoSize:'small',")
- self.assertPageContains("if(wall)wall.dataset.size=appSettings.photoSize;")
+ self.assertPageContains("wall.dataset.size=photoSize();wall.dataset.layout=wall.closest('.skeletonpanel')?'fixed':photoLayout()")
+ self.assertPageContains("setPhotoSize(photoSize()==='big'?'small':'big')")
+ self.assertPageContains("wirePhotoControls(countRow);syncPhotoWalls()")
+ self.assertPageContains("[data-layout=\"masonry\"]>.photocell img{height:auto;aspect-ratio:auto 1}")
+ self.assertPageContains("break-inside:avoid;margin:0 0 14px")
self.assertPageContains(
'.photowall[data-size="big"]{grid-template-columns:repeat(3,minmax(0,1fr))}')
self.assertPageContains(
diff --git a/web/app.js b/web/app.js
index de4529b03..64b43c836 100644
--- a/web/app.js
+++ b/web/app.js
@@ -198,6 +198,7 @@ window.peachRegisterRoute=registerRoute;
const pageSkeletonHtml=(label,{cards=false,className='',variant='',count,fill}={})=>
skeletonHtml(label,{variant:variant||(cards?'cards':'panel'),className,
gridClass:className.includes('follow-content-skeleton')&&new URLSearchParams(location.search).get('media')==='images'?'followlist followphotowall':'',
+ gridSize:className.includes('follow-content-skeleton')?photoSize():'',
...(count?{count}:{}),...(fill===undefined?{}:{fill})});
/* 关注页的骨架跟首页共用海报卡那套几何:网格算式、卡内每一格都一样,只有归属行
高一点(`.followitem .meta .s` 有 min-height)。上面是它自己的创作者行、题材行和那块
@@ -473,6 +474,7 @@ const JAV_LAYOUTS=[['big','大图','maximize'],['small','小图','layout-grid']]
/* 图片墙是等宽网格,改的是列数。默认小图——一套图几十上百张,先看得见全貌,挑中
哪一张再点开看大的。 */
const PHOTO_SIZES=[['big','大图','maximize'],['small','小图','layout-grid']];
+const PHOTO_LAYOUTS=[['fixed','固定比例','layout-grid'],['masonry','瀑布流','columns-2']];
/* 显示器用于跟随系统主题和详情页的画面分辨率。 */
const THEME_OPTIONS=[['system','跟随系统','monitor'],['light','浅色','sun'],['dark','深色','moon']];
const DEFAULT_SETTINGS={batchSize:60,defaultSort:'seed',sortDefaultsVersion:3,hoverDelaySeconds:5,seekSeconds:10,searchHistoryLimit:10,relatedLimit:20,javLayout:'big',javImage:'cover',followLayout:'default',peopleLayout:'big',photoSize:'small',ambientMode:true,miniplayer:true,theaterMode:false,theme:'system',groupCollapse:true,sidebarOrder:DEFAULT_SIDEBAR_ORDER};
@@ -2395,7 +2397,9 @@ function applyDensity(){document.documentElement.style.setProperty('--tile',TILE
document.body.dataset.density=density;
$('#density').setAttribute('aria-pressed',density==='dense');
$('#density').title='当前:'+(density==='big'?'大图':'密集')}
-$('#density').onclick=()=>{density=density==='big'?'dense':'big';
+$('#density').onclick=()=>{if(photoViewActive()){
+ setPhotoSize(photoSize()==='big'?'small':'big');return}
+ density=density==='big'?'dense':'big';
localStorage.setItem('density',density);applyDensity()};
applyDensity();
@@ -5789,6 +5793,9 @@ function followCard(group,authorSources=[]){
.filter(entry=>!imageView||entry.media_kind==='image')
.map(entry=>entry.thumb_url)].filter(Boolean))].slice(0,MIX_FLIP_FACES):[];
const badges=followBadges(group);
+ 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;
const tags=followCardTags(item).slice(0,3).map(tag=>followTagChip(item,tag)).join('');
const mediaIssue=followMediaIssue(item);
const open=`<button class="cardopenhit" data-follow-detail="${item.id}" aria-label="打开 ${esc(item.title)} 详情"></button>`;
@@ -5806,7 +5813,8 @@ function followCard(group,authorSources=[]){
</div></div></div>
<div class="meta"><span class="mav fsourceavatar" title="创作者头像">${followAuthorAvatar(authorSources)}</span>
<div class="mtext"><button class="t cardtitle" data-follow-detail="${item.id}">${esc(item.title)}</button>
- <div class="s mono"><span>${followWhen(item)}</span>${badges?`<span class="fbadges">${badges}</span>`:''}</div>
+ <div class="s followbyline"><span class="followauthor" title="${esc(author)}">${esc(author)}</span><time class="mono" datetime="${esc(item.published_at||'')}" title="${esc(when)}">${esc(compactWhen)}</time></div>
+ ${badges?`<div class="fbadges">${badges}</div>`:''}
${tags?`<div class="ctags">${tags}</div>`:''}${mediaIssue?`<span class="fnote followmediaissue">${esc(mediaIssue)}</span>`:''}</div></div>
<span class="fstate" aria-live="polite"></span></article>`;
}
@@ -5958,7 +5966,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>`});
+ aria-label="检查全部来源的更新">${icon('refresh-cw')}</button>`+(followMediaView==='images'?photoControlsHtml():'')});
}
/* 看的那一页上唯一一次联网:去问每个来源有没有新东西。管理页那几枚按的是同一条路径,
区别在它还要把失败详情摊进那一页的报告块;这一页上没有放报告的地方,失败只留一条
@@ -6119,6 +6127,7 @@ function renderFollow(){
void wireFollowProgress();
/* 上下两排收进同一块外框,材质与吸顶归外框;玻璃的坐标基准也是它,所以先搭框再量。 */
const filterRow=$('#stats').querySelector('.followfilters'),countRow=$('#stats').querySelector('.followcount');
+ wirePhotoControls(countRow);syncPhotoWalls();
mountFilterFrame(filterRow,countRow,{views:filterRow.querySelector('.followviews'),
tags:filterRow.querySelector('.followtags'),readout:countRow.querySelector('.mono'),
controls:countRow.querySelector('.sorts')});
@@ -7990,6 +7999,25 @@ async function shufflePhotos(kind,name,filters,setId,button){
function photoSize(){
return allowedSetting(appSettings.photoSize,PHOTO_SIZES.map(([key])=>key),'small');
}
+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 syncPhotoWalls(){
+ document.querySelectorAll('.photowall,.followphotowall').forEach(wall=>{
+ wall.dataset.size=photoSize();wall.dataset.layout=wall.closest('.skeletonpanel')?'fixed':photoLayout()});
+ if(photoViewActive()){
+ $('#density').setAttribute('aria-pressed',String(photoSize()==='small'));
+ $('#density').title='当前:'+(photoSize()==='big'?'大图':'小图');
+ }else applyDensity();
+}
+function wirePhotoControls(root){
+ wireIconSwitch(root,'data-photo-size',setPhotoSize);
+ wireIconSwitch(root,'data-photo-layout',value=>{
+ appSettings.photoLayout=allowedSetting(value,['fixed','masonry'],'masonry');saveSettings();syncPhotoWalls()});
+}
/* 换大小一次请求都不发,也不重拼这面墙:列数是 CSS 的事,重画只会把已经取回的缩略图
丢掉再要一遍,还把人滚到的位置带走。 */
function setPhotoSize(value){
@@ -7997,8 +8025,7 @@ function setPhotoSize(value){
saveSettings();
document.querySelectorAll('[data-photo-size]').forEach(input=>{
input.checked=input.value===appSettings.photoSize});
- const wall=$('#index').querySelector('.photowall');
- if(wall)wall.dataset.size=appSettings.photoSize;
+ syncPhotoWalls();
}
const photoCell=(item,index)=>`<button class="photocell" data-photo-index="${index}" title="${esc(item.name)}">
<img src="/photo-thumb?id=${item.id}" alt="${esc(item.name)}" loading="lazy"
@@ -8015,8 +8042,7 @@ const photoCell=(item,index)=>`<button class="photocell" data-photo-index="${ind
const photoHeadHtml=(data,{back=false}={})=>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()} 张`,
- controls:sortControlsHtml({extra:iconSwitchHtml('photo-size','照片大小',PHOTO_SIZES,photoSize(),
- {attr:'data-photo-size',className:'photosize'})+(back?sourceTools(data.id):'')})});
+ controls:sortControlsHtml({extra:photoControlsHtml()+(back?sourceTools(data.id):'')})});
function renderPhotoWall(kind,name,filters,data,append=false){
const section=$('#index').querySelector('.entitysection');if(!section)return;
const entityWide=!data.id;
@@ -8026,7 +8052,7 @@ function renderPhotoWall(kind,name,filters,data,append=false){
+`<div class="photowall" data-size="${photoSize()}"></div>
<button class="entitymore" type="button">载入更多</button>`;
const head=section.querySelector('.photohead');
- wireIconSwitch(head,'data-photo-size',setPhotoSize);
+ wirePhotoControls(head);syncPhotoWalls();
head.querySelector('.entitybatch').onclick=event=>
shufflePhotos(kind,name,filters,entityWide?0:data.id,event.currentTarget);
if(!entityWide){
@@ -9078,6 +9104,7 @@ function syncHeaderActions(){
const canSelect=catalog||entity||path==='/tags'||path==='/follow';
const canDensity=catalog||entity||path==='/follow';
$('#selectMode').hidden=!canSelect;$('#density').hidden=!canDensity;
+ syncPhotoWalls();
if(!canSelect&&selectMode)setSelectMode(false,true);
}
function buildEdge(){
diff --git a/web/css/08-photos.css b/web/css/08-photos.css
index 0860d9949..4d1610b2d 100644
--- a/web/css/08-photos.css
+++ b/web/css/08-photos.css
@@ -2,13 +2,8 @@
按默认的 fill:black/stroke:none 画成黑块——深色底上等于看不见。 */
.photoback svg{width:15px;height:15px;stroke:currentColor;fill:none;stroke-width:2}
.photoback:hover{background:var(--overlay-5);color:var(--ink)}
-/* 等宽网格,每格先占好位置再等图。账本没有图片宽高,缩略图在懒加载前高度是 0,而多列
- 流式排版是按分栏那一刻的高度摊的:一屏 240 个零高的格子会被整批摊进最后一列,前几列
- 只留下已经加载出来的那十几张,右边几列从顶上就空着,窄屏则收成半幅一列。固定比例的
- 格子与加载顺序无关,各列自然齐平;关注页的图片墙同样是从多列换成网格才稳住的。
- 方框配 cover:这个库横竖两种取景各占一半,长框总有一半图要被压成一条,方框对两种各
- 裁四分之一,点开就是全图。大小就是列数。窄屏两档一起收,但大图那档始终比小图少两列
- ——收成同一个数等于这个开关在这块屏幕上不起作用,而按钮上还亮着人上一次点的那一档。 */
+/* 固定比例视图使用方框和 cover;瀑布流、响应式列数与关注图片墙共用 21-online.css。
+ 两种视图在缩略图懒加载前都有非零高度,灯箱使用全图。 */
.photowall{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px}
.photowall[data-size="big"]{grid-template-columns:repeat(3,minmax(0,1fr))}
@media (max-width:1400px){.photowall{grid-template-columns:repeat(4,minmax(0,1fr))}
diff --git a/web/css/21-online.css b/web/css/21-online.css
index 957299e29..826b10139 100644
--- a/web/css/21-online.css
+++ b/web/css/21-online.css
@@ -19,7 +19,7 @@
.fauthorhead .ficon{margin-right:2px}
.followlist{display:grid;grid-template-columns:repeat(auto-fill,minmax(var(--tile),1fr));gap:16px 8px}
.followlist.followphotowall{grid-template-columns:repeat(5,minmax(0,1fr));gap:14px 10px;align-items:start}
-/* 固定媒体框在懒加载前就占好高度;多栏会随图片天然高度反复重新分栏,造成滚动位移。 */
+/* 固定比例视图的媒体框在懒加载前占好高度。 */
@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}
@@ -47,6 +47,9 @@
.followitem .r34-metadata,.followdetailtags .r34-metadata,.followfilters .r34-metadata{--r34-tag:#F5A24A}
.followdetailtags .r34-unknown{--r34-tag:var(--muted)}
.followitem .meta .s{min-height:21px}.fbadges{display:flex;flex-wrap:nowrap;gap:5px;min-width:0;overflow:hidden}
+.followitem .meta .followbyline{display:flex;flex-wrap:nowrap;gap:6px;min-width:0;overflow:hidden}
+.followbyline .followauthor{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+.followbyline time{flex:none;white-space:nowrap}
.fbadge{padding:2px 8px;border:1px solid var(--border-15);border-radius:var(--badge-radius);font-size:var(--fs-xs);color:var(--ink-2)}
.fbadge.wip{border-color:var(--meter);color:var(--meter)}
/* 「含 WIP」说的是同组里还有一条半成品,这一条本身不是;配色要弱于 WIP 本体。 */
@@ -95,3 +98,20 @@
.followdetailmedia{--follow-image-arrow-inset:10px}.followimagearrow{width:44px;height:44px}.followimagedots{bottom:12px}
}
+/* 图片墙共用列数与布局;未加载图片由备用比例占位,加载后使用天然比例。 */
+:is(.photowall,.followlist.followphotowall)[data-size]{--photo-columns:5;grid-template-columns:repeat(var(--photo-columns),minmax(0,1fr))}
+:is(.photowall,.followlist.followphotowall)[data-size="big"]{--photo-columns:3}
+@media(max-width:1400px){:is(.photowall,.followlist.followphotowall)[data-size]{--photo-columns:4}
+ :is(.photowall,.followlist.followphotowall)[data-size="big"]{--photo-columns:2}}
+@media(max-width:1000px){:is(.photowall,.followlist.followphotowall)[data-size]{--photo-columns:3}
+ :is(.photowall,.followlist.followphotowall)[data-size="big"]{--photo-columns:1}}
+@media(max-width:640px){:is(.photowall,.followlist.followphotowall)[data-size]{--photo-columns:2}
+ :is(.photowall,.followlist.followphotowall)[data-size="big"]{--photo-columns:1}}
+:is(.photowall,.followlist.followphotowall)[data-layout="masonry"]{display:block;column-count:var(--photo-columns);column-gap:10px}
+[data-layout="masonry"]>.emptystate{column-span:all}
+[data-layout="masonry"]>.photocell,[data-layout="masonry"]>.followitem.imagecard{break-inside:avoid;margin:0 0 14px}
+[data-layout="masonry"]>.photocell{aspect-ratio:auto}
+[data-layout="masonry"]>.photocell img{height:auto;aspect-ratio:auto 1}
+[data-layout="masonry"] .followitem.imagecard .pic{aspect-ratio:1}
+[data-layout="masonry"] .followitem.imagecard .pic:has(>img){aspect-ratio:auto}
+[data-layout="masonry"] .followitem.imagecard .followvisual .pic>img{position:static;height:auto;aspect-ratio:auto 1}
diff --git a/web/index.html b/web/index.html
index 553f7e2a8..9d736b8c0 100644
--- a/web/index.html
+++ b/web/index.html
@@ -71,6 +71,7 @@
<symbol id="i-home" viewBox="0 0 24 24"><path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8" /><path d="M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" /></symbol>
<symbol id="i-panel-left" viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M9 3v18" /></symbol>
<symbol id="i-search" viewBox="0 0 24 24"><path d="m21 21-4.34-4.34" /><circle cx="11" cy="11" r="8" /></symbol>
+ <symbol id="i-columns-2" viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M12 3v18" /></symbol>
<symbol id="i-layout-grid" viewBox="0 0 24 24"><rect width="7" height="7" x="3" y="3" rx="1" /><rect width="7" height="7" x="14" y="3" rx="1" /><rect width="7" height="7" x="14" y="14" rx="1" /><rect width="7" height="7" x="3" y="14" rx="1" /></symbol>
<!-- Beeg PicsIcon,取自 2026-08-30 锁定的 main.9442c3b8.js(module 83646)。 -->
<symbol id="i-pics" viewBox="-1.6 -1.6 19.2 19.2" fill="currentColor" stroke="none"><path d="M8 3.5C8 4.052 7.552 4.5 7 4.5C6.448 4.5 6 4.052 6 3.5C6 2.948 6.448 2.5 7 2.5C7.552 2.5 8 2.948 8 3.5Z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M3.49402 10.5C3.49402 11.605 4.38902 12.5 5.49402 12.5L14 12.501C15.105 12.501 16 11.606 16 10.501V2.001C16 0.896 15.105 0.001 14 0.001L5.49402 0C4.38902 0 3.49402 0.895 3.49402 2V10.5ZM4.49402 2C4.49402 1.448 4.94202 1 5.49402 1L14 1.001C14.552 1.001 15 1.449 15 2.001V5.84603L14.459 5.30103C14.045 4.88703 13.518 4.71503 13.045 4.71503C12.572 4.71503 12.063 4.87003 11.632 5.30103L9.04502 7.85603C8.91602 7.96603 8.78702 7.98303 8.71902 7.98303C8.64702 7.98303 8.48502 7.96603 8.35502 7.83203L7.64702 7.14803C7.26402 6.82503 6.87702 6.61403 6.23902 6.61403C5.83202 6.61403 5.27002 6.79003 4.87102 7.19903L4.49402 7.58003V2ZM4.49402 8.98503V10.5C4.49402 11.052 4.94202 11.5 5.49402 11.5L14 11.501C14.552 11.501 15 11.053 15 10.501V7.25603L13.752 6.00803C13.521 5.77703 13.23 5.71503 13.045 5.71503C12.85 5.71503 12.556 5.78603 12.339 6.00803L9.76602 8.55303C9.49302 8.82603 9.08202 8.98503 8.75102 8.98503C8.35402 8.98503 8.01102 8.86203 7.71302 8.60403L6.94102 7.86703C6.76302 7.71803 6.54702 7.61303 6.26102 7.61903C5.97402 7.62503 5.74102 7.74803 5.58102 7.90703L4.49402 8.98503Z"/><path d="M0.0310299 12.174C-0.16097 13.262 0.56503 14.299 1.65303 14.491L10.03 15.969C11.119 16.161 12.155 15.435 12.347 14.347L12.496 13.501H11.481L11.362 14.173C11.267 14.717 10.748 15.08 10.204 14.984L1.82703 13.506C1.28303 13.41 0.92003 12.891 1.01603 12.348L2.49203 3.97702C2.49203 3.97302 2.49303 3.96902 2.49403 3.96502V2.40802C1.99103 2.69202 1.61503 3.19002 1.50703 3.80302L0.0310299 12.174Z"/></symbol>
diff --git a/web/js/ui-components.js b/web/js/ui-components.js
index a89a511d0..7074b8e24 100644
--- a/web/js/ui-components.js
+++ b/web/js/ui-components.js
@@ -318,7 +318,7 @@ export function loadingDotsHtml(label='正在处理', {className=''}={}){
/** Geist Skeleton: reserve a large content region while its structure is loading. */
/* `count` 只对 cards 生效:块数是骨架说出口的结构预告,六块对上的是海报网格,
而行政界面往往只有两三个大区。多画的块加载完就消失,那不是占位是误报。 */
-export function skeletonHtml(label='正在读取内容',{className='',variant='panel',count=6,fill=true,gridClass=''}={}){
+export function skeletonHtml(label='正在读取内容',{className='',variant='panel',count=6,fill=true,gridClass='',gridSize=''}={}){
const kind=new Set(['panel','cards','dashboard']).has(variant)?variant:'panel';
const body=kind==='cards'
?Array.from({length:Math.max(1,count)},
@@ -340,7 +340,7 @@ export function skeletonHtml(label='正在读取内容',{className='',variant='p
return `<div class="skeletonpanel skeleton-${kind}${className?` ${esc(className)}`:''}"
data-skeleton="${esc(kind)}${className?`/${esc(className)}`:''}"${kind==='cards'&&fill?' data-fill=""':''}
role="status" aria-label="${esc(label)}"><span class="sr-only">${esc(label)}</span>
- <div${gridClass?` class="${esc(gridClass)}"`:''} aria-hidden="true">${body}</div></div>`;
+ <div${gridClass?` class="${esc(gridClass)}"`:''}${gridSize?` data-size="${esc(gridSize)}"`:''} aria-hidden="true">${body}</div></div>`;
}
/** 索引占位复用最终网格、头像和词表的尺寸。 */
diff --git a/web/vendor/lucide-ORIGIN.md b/web/vendor/lucide-ORIGIN.md
index 5421226c3..4bac079ed 100644
--- a/web/vendor/lucide-ORIGIN.md
+++ b/web/vendor/lucide-ORIGIN.md
@@ -3,7 +3,7 @@
- npm 包:`[email protected]`
- npm lock integrity:`sha512-ln37Ng6A709exLQH4pBxrbl6FAUk/ZBLTJnLrj02HN/Bb84eUGzlA2JjMglScI0TEab6vH2UVs0hm4vGgLzTrQ==`
- 许可证:ISC;原文见 `lucide-LICENSE.txt`
-- 消费者:`web/index.html` 内联的 115 个 symbol
+- 消费者:`web/index.html` 内联的 116 个 symbol
雪碧图里另有 6 枚自绘 symbol(shuffle、alert、pics、jav、theater-enter、theater-exit)与 16 枚 player-* 前缀的播放器图标,都没有上游可对。
RSS 与拖动点保留填充修正,避免小圆点在全局描边样式下消失。