Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(detail): 分卷标题栏的卷号从队列补齐

longmeidao70b543bc7365
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 118e513d3..7acecea0b 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -5722,6 +5722,10 @@ class WebUiSourceTests(unittest.TestCase):
"""? `<small class="javedition partlabel">第 ${esc(it.part_label)} 卷</small>`:'';""")
self.assertPageContains("${javTitleHtml(it)}${partLabelBadge(it,queueContext)}")
self.assertPageContains(".javedition.partlabel{color:var(--muted);margin-left:6px}")
+ # `/api/item` 是单条口径,答不出「这是第几卷」;不从队列补,标题栏就一直空着。
+ self.assertPageContains("if(queueContext?.kind==='parts')")
+ self.assertPageContains(
+ "it.part_label=queueContext.items.find(part=>part.id===it.id)?.part_label||'';")
# 队列条目那一侧本来就写着卷号,两处用的是同一个字段。
self.assertPageContains("queue.kind==='parts'?`第 ${esc(x.part_label)} 卷`")
diff --git a/web/app.js b/web/app.js
index 4e6dcc77c..6642af690 100644
--- a/web/app.js
+++ b/web/app.js
@@ -6802,6 +6802,10 @@ async function openItem(id,push=true,queueContext=null,anchor=null){
const it=await surfaceApi(detailSurface,'/api/item?id='+id);
if(!surfaceCurrent(detailSurface))return;
if(it.error)return;
+ /* 卷标只有分卷队列知道:`/api/item` 是单条口径,它答不出「这是第几卷」。不补的话
+ 标题栏里的卷号在深链进来和点开队列另一条时都不出现。 */
+ if(queueContext?.kind==='parts')
+ it.part_label=queueContext.items.find(part=>part.id===it.id)?.part_label||'';
current=it; CACHE[it.id]=it;
barsContext={type:'item',id:it.id,filters:returnBars?.type==='entity'
? {...returnBars.filters}:emptyEntityFilters()};