Peach: Local-first video metadata scraper and media manager.
修复详情吸顶导航与滚动偏移
longmeidao40f9db1a9b8c
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex 15645fab7..44bd7e025 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -1481,6 +1481,15 @@ class WebUiSourceTests(unittest.TestCase):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):+ self.assertPageLacks("body.detail-open .tagbar{position:relative;top:auto;z-index:1}")+ self.assertPageContains("function itemDetailStickyOffset()")+ self.assertPageContains("['.top','#tagbar','#count','.entitycollectionhead']")+ self.assertPageContains("el.compareDocumentPosition(stage)&Node.DOCUMENT_POSITION_FOLLOWING")+ self.assertPageContains("el.offsetParent===null||css.position!=='sticky'")+ self.assertPageContains("stage.style.scrollMarginTop=`${itemDetailStickyOffset()+8}px`")+ self.assertPageContains("buildBars();\n scrollItemDetailIntoView();")+def test_catalog_and_item_detail_loading_reuse_the_spinner_component(self):self.assertPageContains("function renderCatalogLoading(label='正在读取作品')")self.assertPageContains("count.innerHTML=`${spinnerHtml(label)}<span>载入中…</span>`")diff --git a/web/app.css b/web/app.cssindex b9972875f..94a8d9b98 100644--- a/web/app.css+++ b/web/app.css@@ -921,7 +921,6 @@ body[data-density="dense"] .card .meta .watchcount{display:none}.grid>.stage{grid-column:1/-1;width:100%;min-width:0}.detailpending{min-height:144px;display:flex;align-items:center;justify-content:center;gap:10px;color:var(--muted)}.detailpending .geist-spinner{color:var(--ink)}-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)}diff --git a/web/app.js b/web/app.jsindex f50402823..34da2dd3e 100644--- a/web/app.js+++ b/web/app.js@@ -396,6 +396,24 @@ function showItemDetailLoading(anchor,above){stage.innerHTML=`<div class="detailpending" role="status" aria-busy="true">${spinnerHtml('正在加载详情')}<span>正在加载详情…</span></div>`;}++function itemDetailStickyOffset(){+ const stage=$('#stage');+ return ['.top','#tagbar','#count','.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);+}++function scrollItemDetailIntoView(){+ const stage=$('#stage');+ stage.style.scrollMarginTop=`${itemDetailStickyOffset()+8}px`;+ stage.scrollIntoView({behavior:'auto',block:'start'});+ scheduleStickySurfaces();+}function bufferedAhead(video){const at=video.currentTime||0;for(let i=0;i<video.buffered.length;i++)if(video.buffered.start(i)<=at&&video.buffered.end(i)>=at)@@ -5004,8 +5022,8 @@ async function openItem(id,push=true,queueContext=null,anchor=null){else if(g)g.onclick=()=>{vv.hidden=false;g.remove();const mounted=mountDetailPlayer(it,vv,true);stopAmbient=mountPlayerAmbient(vv);mounted?.one?.('dispose',stopAmbient)};else{const mounted=mountDetailPlayer(it,vv,true);stopAmbient=mountPlayerAmbient(vv);mounted?.one?.('dispose',stopAmbient)}vv.addEventListener('emptied',()=>stopAmbient(),{once:true});- $('#stage').scrollIntoView({behavior:'auto',block:'start'});buildBars();+ scrollItemDetailIntoView();if(!queueContext)api('/api/related?id='+it.id+'&limit='+appSettings.relatedLimit).then(d=>{const n=$('#nrow'); if(!n)return; cache(d.items);