Skip to content

armgit / peach

Public Imported from GitHub
0

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

feat(web): add follow media tabs

longmeidaoa7a749a161ec
diff --git a/docs/STATUS.md b/docs/STATUS.md
index ff29e9e5d..a58d56151 100644
--- a/docs/STATUS.md
+++ b/docs/STATUS.md
@@ -36,6 +36,7 @@
## 本批修正与验证
+- 0.7.13 让关注观看页复用资料页的“视频/图片”媒体 Tab,并在 URL 中保留图片视图;混合更新会同时进入两个视图,点开后默认落到当前媒体类型,待解析的外部文件页继续保留在默认视频视图。普通 Mix、分卷、播放列表与关注多视频合集统一为“左侧媒体、右侧详情、媒体下方切换队列”,不再让队列占用详情栏。接口继续使用既有 `media_kind`/`media_items`,没有新增依赖、迁移或真实 ledger 写入。Windows `follow` 412 项、正式全量 1185 项通过,分别 1/13 项按平台跳过;临时数据库浏览器实测关注页有视频 220、图片 13,1440×900 和 390×844 均无横向溢出;2 项关注合集与 29 项普通 Mix 都保持右侧详情、下方队列,控制台 0 错误。生产尚未切换,生产验收待集成后完成。
- 0.7.12 修复艺人/厂牌资料页从深链或刷新进入时只看 URL 参数、因此漏掉 JAV 三种版式按钮的问题:页面现在从实际返回作品的 `is_jav` 推断资料页能力,并只给 JAV 卡片应用封面比例。照片查看器的缩放加减号改用本地 SVG,桌面和手机实测按钮与图标水平、垂直中心偏差均为 0 px;新增图片详情,显示文件名、来源和大小,切换图片时同步更新,并复用既有 `/api/reveal` 按 asset id 在资源管理器定位,客户端仍不接收或提交原始路径。照片 DTO 只新增安全的 `location`,没有迁移或真实 ledger 写入。Windows `catalog` 402 项、正式全量 1183 项通过,13 项按平台跳过;1440×900 下资料页三种版式按钮均可见,390×844 下详情面板 360 px 且位于 390 px 视口内,两端均无横向溢出和控制台错误。生产托盘已受控重启且继续使用原 0.7.11 EXE,80/443 由新子进程接管;HTTP 与项目 CA 严格 HTTPS `/healthz` 均返回 0.7.12、writer、非只读。生产资料页实测三种版式按钮均可见;真实 115 图片详情显示文件名、来源、大小和 asset id 定位入口,1280 px 与 390×844 下均无横向溢出,缩放图标中心偏差为 0 px。未点击生产定位按钮,未写真实 ledger。
- 0.7.11 将管理画像入口统一命名为“口味”;资源同步不再占用独立管理页,改为统计页末尾,旧 `/resource-sync` 深链自动替换为 `/stats#resource-sync`。同步配置按 Vercel 表单卡重排:主信息在上层,安全说明和 36px 次级操作放在带分隔线的底栏;扫描结果共用一套 12px 外框与内部 1px 分隔线,来源、汇总和确认操作不再各自嵌套卡片或压住边缘。按钮具备明确 hover/focus 和原位旋转忙碌态;窄屏规则提高到组件作用域,避免被后置基础规则覆盖。Windows 正式全量 1181 项通过、13 项按平台跳过。临时数据库的 1280×720 浏览器实测结果为三列来源、两列汇总、底栏按钮完全位于 1176px 外框内;390×844 下来源与汇总均为单列,外框 358px、底栏 356px、按钮 324×36,文档与视口同为 390px,无横向溢出。
- 0.7.11 正式 EXE 已替换为 SHA-256 `FCD54E557D9FE36FE3D3B0FFC50E486701CA5B990334A280F203691BF94EC9B0`,上版备份为 `dist/Peach/Peach.pre-0.7.11-20260829-004620.exe`;打包入口在临时 ledger 上确认 22 个迁移、0 待处理。80/443 均由新进程恢复,OpenSSL 以项目 CA、`peach-win.local` SNI 与主机名严格校验返回 `Verify return code: 0 (ok)`,固定到实际监听地址后的 `/healthz` 返回 0.7.11、writer、非只读,`/stats` 与旧 `/resource-sync` 均为 200。生产浏览器实测管理栏只有“口味”且无独立资源同步入口;1280×720 下配置卡 1166px、底栏 1164px、按钮 102×36,390×844 下卡片 348px、底栏 346px、按钮 314×36、无横向溢出和控制台错误;旧链接原位进入 `/stats#resource-sync`。未点击扫描、未执行同步应用。停止旧 SQLite 连接时主文件 SHA-256 由 `27F540B8F6B296F544EA2B250D159C0D7A2DFA6F59FA962F20AAE4CB2B63A8E3` 变为 `14F30D85F33631B74E99D9E1F48BBA090F57CD1D12AD3804AD47C2CC00FB8F60`,时间点与停服一致且重启后 WAL 为 0 字节,符合关闭连接时的 WAL 回写;只读复核为 `integrity_check=ok`、外键违规 0,asset 81555、follow_source 14、follow_item 1551、entity 8177。
diff --git a/src/peach/__init__.py b/src/peach/__init__.py
index 270771d00..d14798995 100644
--- a/src/peach/__init__.py
+++ b/src/peach/__init__.py
@@ -1,3 +1,3 @@
"""Peach application package."""
-__version__ = "0.7.12"
+__version__ = "0.7.13"
diff --git a/tests/test_follow_web.py b/tests/test_follow_web.py
index f0da5eb07..f8509ebe4 100644
--- a/tests/test_follow_web.py
+++ b/tests/test_follow_web.py
@@ -206,14 +206,16 @@ class FollowContractTests(unittest.TestCase):
"url": "https://store1.gofile.io/download/one.mp4",
"thumb_url": "https://store1.gofile.io/one.jpg",
"resource_provider": "gofile"},
- {"id": "two", "name": "two.mp4", "media_kind": "video",
- "url": "https://store1.gofile.io/download/two.mp4",
+ {"id": "two", "name": "two.jpg", "media_kind": "image",
+ "url": "https://store1.gofile.io/download/two.jpg",
"resource_provider": "gofile"},
]},
),), provider="fanbox", ref="lazyprocrast")
item = self._get()["groups"][0]["primary"]
self.assertTrue(item["playable"])
self.assertEqual([media["index"] for media in item["media_items"]], [0, 1])
+ self.assertEqual([media["media_kind"] for media in item["media_items"]],
+ ["video", "image"])
self.assertEqual(item["media_items"][0]["name"], "one.mp4")
self.assertNotIn("url", item["media_items"][0])
self.assertNotIn("store1.gofile.io/download", json.dumps(item))
@@ -1597,6 +1599,25 @@ class FollowWebSourceTests(unittest.TestCase):
self.assertPageContains('data-follow-queue-item="${item.id}"')
self.assertPageContains("openFollowDetail(+button.dataset.followCollection)")
+ def test_follow_reuses_media_tabs_and_keeps_mixed_updates_in_both_views(self):
+ self.assertPageContains("const followMediaKinds=group=>")
+ self.assertPageContains("function followItemMediaKinds(item)")
+ self.assertPageContains("const item=followItemForMedia(group)")
+ self.assertPageContains('class="mediatabs followmediatabs"')
+ self.assertPageContains('data-follow-media="videos"')
+ self.assertPageContains('data-follow-media="images"')
+ self.assertPageContains("<span>视频</span>")
+ self.assertPageContains("<span>图片</span>")
+ self.assertPageContains("followMediaView=new URLSearchParams(location.search).get('media')==='images'?'images':'videos'")
+ self.assertPageContains("const preferredKind=followMediaView==='images'?'image':'video'")
+
+ def test_mix_and_follow_queues_stay_below_media_with_details_on_the_right(self):
+ self.assertPageContains('grid-template-areas:"media side" "queue side"')
+ self.assertPageContains('.sgrid.mixgrid>.vwrap{grid-area:media}')
+ self.assertPageContains('.sgrid.mixgrid>.side{grid-area:side;max-height:none}')
+ self.assertPageContains('.sgrid.mixgrid>.mixqueue{grid-area:queue;max-height:360px')
+ self.assertPageContains('grid-template-areas:"media" "queue" "side"')
+
def test_follow_uses_the_global_multi_select_mode(self):
self.assertPageContains("const selected=new Set(),followSelected=new Set();")
self.assertPageContains("function toggleFollowSelection(id,range=false)")
diff --git a/web/app.css b/web/app.css
index 96cdb4d1b..633a58546 100644
--- a/web/app.css
+++ b/web/app.css
@@ -784,9 +784,15 @@ body.detail-open .tagbar{position:relative;top:auto;z-index:1}
body.entity-open #tiers,body.entity-open #tagbar,
body.index-open #tiers,body.index-open #tagbar{display:none}
.sgrid{display:grid;grid-template-columns:minmax(0,1fr) minmax(350px,390px)}
-.sgrid.mixgrid{grid-template-columns:minmax(0,1fr) minmax(310px,390px)}
-.sgrid.mixgrid>.side{grid-column:1/-1;max-height:none;border-left:0;border-top:1px solid var(--line-soft)}
-.sgrid.mixgrid .vwrap>.closestage{display:none}
+/* Mix、分卷、播放列表和关注合集都保留普通详情的主结构:媒体在左、信息在右;
+ 切换队列只加在媒体下方,不再抢走详情栏。 */
+.sgrid.mixgrid{grid-template-columns:minmax(0,1fr) minmax(350px,390px);
+ grid-template-areas:"media side" "queue side";align-items:start}
+.sgrid.mixgrid>.vwrap{grid-area:media}
+.sgrid.mixgrid>.side{grid-area:side;max-height:none}
+.sgrid.mixgrid>.mixqueue{grid-area:queue;max-height:360px;border-left:0;border-top:1px solid var(--line-soft)}
+.sgrid.mixgrid .mixqueueactions [data-queue-close],
+.sgrid.mixgrid .mixqueueactions [data-follow-queue-close]{display:none}
.mixqueue{min-width:0;max-height:76vh;display:flex;flex-direction:column;border-left:1px solid var(--line-soft);
background:color-mix(in srgb,var(--video-glow,#15202a) 10%,var(--surface) 90%)}
.mixqueuehead{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:center;
@@ -1124,8 +1130,9 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位
.batchbar .danger{color:var(--drop)}
@media (max-width:1080px){.sgrid,.sgrid.mixgrid{grid-template-columns:minmax(0,1fr)}
+ .sgrid.mixgrid{grid-template-areas:"media" "queue" "side"}
.side,.sgrid.mixgrid>.side{grid-column:auto;border-left:0;border-top:1px solid var(--line-soft);max-height:none}
- .mixqueue{max-height:420px;border-left:0;border-top:1px solid var(--line-soft)}}
+ .mixqueue,.sgrid.mixgrid>.mixqueue{max-height:420px;border-left:0;border-top:1px solid var(--line-soft)}}
@media (max-width:760px){
.readout{display:none} .brand .sub{display:none}
:root{--tile:168px;--topH:52px;--sortH:60px}
@@ -1256,6 +1263,7 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位
.follow{padding:4px 0 42px}
.followhead{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-bottom:14px}
.followhead .pagetitle{margin:0}
+.followmediatabs{margin-bottom:8px}
.follow .fcheck{font-weight:600}
.follow .fcheck svg{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:2}
.follow .fcheck.busy svg,.frowicon.busy svg{animation:follow-spin .8s linear infinite}
diff --git a/web/app.js b/web/app.js
index b1a242b5c..15b9ef546 100644
--- a/web/app.js
+++ b/web/app.js
@@ -1583,6 +1583,28 @@ function followVideoItems(group){
item.playable&&item.media_kind==='video');
}
+/* 关注条目和资料页的作品不是同一种 DTO,但媒体 Tab 的语义相同:一个卡片只要
+ 含对应媒体就进入对应视图。旧的外部文件页没有可判定图片类型,继续留在默认的
+ 视频视图,避免加 Tab 后把原本可见的待解析更新悄悄藏掉。 */
+function followItemMediaKinds(item){
+ const kinds=new Set();
+ const embedded=item.media_items||[];
+ if(embedded.length)embedded.forEach(media=>{
+ if(media.media_kind==='image'||media.media_kind==='video')kinds.add(media.media_kind)});
+ else kinds.add(item.media_kind==='image'?'image':'video');
+ return kinds;
+}
+const followMediaKinds=group=>{
+ const kinds=new Set();
+ followCollectionItems(group).forEach(item=>
+ followItemMediaKinds(item).forEach(kind=>kinds.add(kind)));
+ return kinds;
+};
+const followItemForMedia=(group,view=followMediaView)=>{
+ const wanted=view==='images'?'image':'video';
+ return followCollectionItems(group).find(item=>followItemMediaKinds(item).has(wanted))||group.primary;
+};
+
function followMediaNote(item){
if(item.media_error)return `媒体未取得:${item.media_error}`;
if(item.media_needs_credential)return followCredentialProviders.has(item.provider)
@@ -1670,8 +1692,10 @@ async function openFollowDetail(id,push=true,mediaIndex=null,preserveReturn=fals
const item=await followItemById(+id);if(!item)return;
const group=followGroupByItemId.get(item.id);
const embedded=item.media_items||[];
+ const preferredKind=followMediaView==='images'?'image':'video';
+ const preferredMedia=embedded.find(media=>media.media_kind===preferredKind)||embedded[0];
const selectedMedia=embedded.length
- ?embedded.find(media=>media.index===(mediaIndex??embedded[0].index))||embedded[0]
+ ?embedded.find(media=>media.index===(mediaIndex??preferredMedia.index))||preferredMedia
:null;
const imageMedia=embedded.filter(media=>media.media_kind==='image');
const imagePosition=imageMedia.findIndex(media=>media.index===selectedMedia?.index);
@@ -1788,14 +1812,15 @@ function wireFollowDetail(root){
}
function followCard(group,authorSources=[]){
- const item=group.primary;
+ const item=followItemForMedia(group);
const thumb=item.thumb_url
? `<img src="${esc(item.thumb_url)}" alt="" loading="lazy" referrerpolicy="no-referrer" onerror="this.remove()">`
: `<span class="fnothumb">${esc(item.provider_label)}</span>`;
- const videos=followVideoItems(group),embedded=item.media_items||[];
+ const videos=followMediaView==='videos'?followVideoItems(group):[],embedded=item.media_items||[];
const isMix=embedded.length>1||videos.length>1;
const mixCount=embedded.length>1?embedded.length:videos.length;
- const mixKind=embedded.length&&embedded.every(media=>media.media_kind==='image')?'图片':'视频';
+ 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;
const badges=followBadges(group);
const tags=(item.tags||[]).slice(0,3).map(tag=>followTagChip(item,tag)).join('');
@@ -1853,7 +1878,7 @@ function followCheckSummary(report){
}
/* ── 看的那一页 ── */
-let followAuthor='',followProvider='',followTags=new Set(),followGroupByItemId=new Map(),followItemsById=new Map(),followDetailReturnPath='/follow';
+let followAuthor='',followProvider='',followTags=new Set(),followMediaView='videos',followGroupByItemId=new Map(),followItemsById=new Map(),followDetailReturnPath='/follow';
const TAGGED_PROVIDERS=['rule34video','rule34xxx','rule34paheal'];
function groupTagType(groups,tag){
for(const group of groups){
@@ -1895,7 +1920,7 @@ function renderFollow(){
if(followAuthor&&!authors.has(followAuthor))followAuthor='';
if(followProvider&&!providers.has(followProvider))followProvider='';
followTags=new Set([...followTags].filter(tag=>tagCounts.has(tag)));
- const visible=groups.filter(group=>{
+ const filtered=groups.filter(group=>{
const source=sourceOf(group);
if(!source)return !followAuthor&&!followProvider;
if(followAuthor&&source.author_key!==followAuthor)return false;
@@ -1903,6 +1928,13 @@ function renderFollow(){
if(followTags.size&&![...followTags].every(tag=>(group.primary&&group.primary.tags||[]).includes(tag)))return false;
return true;
});
+ const mediaCounts={videos:0,images:0};
+ filtered.forEach(group=>followMediaKinds(group).forEach(kind=>
+ mediaCounts[kind==='image'?'images':'videos']++));
+ if(followMediaView==='images'&&!mediaCounts.images)followMediaView='videos';
+ if(followMediaView==='videos'&&!mediaCounts.videos&&mediaCounts.images)followMediaView='images';
+ const wantedKind=followMediaView==='images'?'image':'video';
+ const visible=filtered.filter(group=>followMediaKinds(group).has(wantedKind));
const providerPills=[...providers].map(([key,label])=>
`<button class="pill sourcepill" data-follow-provider="${esc(key)}" aria-pressed="${key===followProvider}"
title="${esc(label)}" aria-label="来源:${esc(label)}">${sourceIcon(key)}</button>`).join('');
@@ -1910,6 +1942,10 @@ function renderFollow(){
$('#stats').innerHTML=`<div class="follow">
<div class="followhead"><h2 class="disp pagetitle">关注</h2>
<button class="fbtn primary fcheck" data-follow-manage>${icon('settings')}管理关注</button></div>
+ ${mediaCounts.images?`<div class="mediatabs followmediatabs" aria-label="关注媒体类型">
+ <button data-follow-media="videos" aria-pressed="${followMediaView==='videos'}">${icon('play')}<span>视频</span><b class="mono">${mediaCounts.videos.toLocaleString()}</b></button>
+ <button data-follow-media="images" aria-pressed="${followMediaView==='images'}">${icon('layout-grid')}<span>图片</span><b class="mono">${mediaCounts.images.toLocaleString()}</b></button>
+ </div>`:''}
${authors.size?`<div class="tier followauthors" aria-label="按作者筛选">${[...authors].map(([key,author])=>
`<button class="av" data-follow-author="${esc(key)}" aria-pressed="${key===followAuthor}">
<span class="ring">${followAuthorAvatar(author.sources)}</span><span class="nm">${esc(author.name)}</span></button>`
@@ -1945,6 +1981,9 @@ function renderFollow(){
followCheckReport=null;button.closest('.fcheckreport')?.remove()});
$('#stats').querySelectorAll('[data-follow-filter]').forEach(button=>button.onclick=()=>{
followFilter=button.dataset.followFilter;openFollow(false)});
+ $('#stats').querySelectorAll('[data-follow-media]').forEach(button=>button.onclick=()=>{
+ followMediaView=button.dataset.followMedia;
+ route('/follow'+(followMediaView==='images'?'?media=images':''));renderFollow()});
$('#stats').querySelectorAll('[data-follow-author]').forEach(button=>button.onclick=()=>{
followAuthor=followAuthor===button.dataset.followAuthor?'':button.dataset.followAuthor;renderFollow()});
$('#stats').querySelectorAll('[data-follow-provider]').forEach(button=>button.onclick=()=>{
@@ -1994,7 +2033,9 @@ function wireFollowOlder(){
async function openFollow(push=true,renderForDetail=false){
releaseHoverPreviews();disposeStage(false);
document.body.classList.remove('entity-open','index-open');
- if(push)route('/follow');
+ if(push){followMediaView='videos';route('/follow')}
+ else if(location.pathname==='/follow')
+ followMediaView=new URLSearchParams(location.search).get('media')==='images'?'images':'videos';
$('#stats').hidden=false;$('#index').hidden=true;$('#grid').innerHTML='';
$('#count').textContent='';$('#loadSentinel').hidden=true;$('#shortsSec').hidden=true;
$('#tiers').style.display='none';$('#tagbar').style.display='none';