Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix: 修正关注页视觉验收问题

longmeidao5221719185d2
diff --git a/tests/test_follow_web.py b/tests/test_follow_web.py
index 72919706e..dcd3f8274 100644
--- a/tests/test_follow_web.py
+++ b/tests/test_follow_web.py
@@ -742,6 +742,7 @@ class FollowWebSourceTests(unittest.TestCase):
rule = page[page.index(".followmanage{"):]
rule = rule[:rule.index("}")]
self.assertIn("grid-template-columns:minmax(0,1fr)", rule)
+ self.assertPageContains(".followmanage>.runtimegate{grid-column:1/-1")
def test_sections_have_a_frame_but_their_rows_do_not(self):
"""反模式是卡片**套**卡片,不是「不要任何容器」。
@@ -1068,6 +1069,8 @@ class FollowWebSourceTests(unittest.TestCase):
# 等于说这一组只属于 fanbox,正是这次要消掉的误读。
self.assertPageContains("function followAuthorName(group)")
self.assertPageContains("const name=followAuthorName(group);")
+ self.assertPageContains("const official=group.find(source=>source.official_avatar_url);")
+ self.assertPageContains("if(officialName)return officialName;")
# 取不到头像时是一个明确的空位,不是首字母——首字母会让「未取得」看着像取到了。
self.assertPageContains("这些来源没有可取的头像")
avatar = self.page[self.page.index("function followAuthorAvatar(group)"):]
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index c194d9b61..a9cf1b8d4 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -1076,6 +1076,7 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("搜索记录")
self.assertPageContains("recommendations.map")
self.assertPageContains("rememberSearch(query)")
+ self.assertPageContains("body:JSON.stringify({query})}).catch(()=>null)")
self.assertPageContains(".top:has(.search.open){overflow:visible}")
self.assertPageLacks("setTimeout(runSearch,320)")
self.assertPageContains("runSearch(!picked,true)")
diff --git a/web/app.css b/web/app.css
index fb49321ef..3c19c06a7 100644
--- a/web/app.css
+++ b/web/app.css
@@ -1246,6 +1246,7 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位
控件仍按实测 Geist:32px 高、14px 字、6px 圆角。 */
.followmanage{padding:2px 0 48px;display:grid;grid-template-columns:minmax(0,1fr) 320px;
gap:16px;align-items:start;font-size:var(--fs-md)}
+.followmanage>.runtimegate{grid-column:1/-1;margin-bottom:0}
.fmain{display:grid;gap:16px;min-width:0}
.faside{display:grid;gap:16px;min-width:0}
/* 容器:发丝边 + 比页面亮一档的表面。内部的行不再各自套框。 */
diff --git a/web/app.js b/web/app.js
index f8f379ede..b72d33b8c 100644
--- a/web/app.js
+++ b/web/app.js
@@ -1546,6 +1546,14 @@ function followAuthorAvatar(group){
function followAuthorName(group){
const entity=group.find(source=>source.entity_name);
if(entity)return entity.entity_name;
+ // 官方主页来源不只优先提供头像,也优先提供作者写法;否则 F95 的线程标题
+ // `Lazy Procrastinator Collection` 会因为大写字母更多而抢成分组标题。
+ const official=group.find(source=>source.official_avatar_url);
+ if(official){
+ const officialName=String(official.label||'')
+ .replace(/\s*[·|]\s*[A-Za-z0-9_-]+\s*$/,'').trim();
+ if(officialName)return officialName;
+ }
const names=group.map(source=>String(source.label||'').replace(/\s*[·|]\s*[A-Za-z0-9_-]+\s*$/,''))
.filter(Boolean);
if(!names.length)return group[0].label||group[0].ref||'';
@@ -2747,7 +2755,11 @@ let searchHistory=[];
const readSearchHistory=()=>searchHistory.slice(0,appSettings.searchHistoryLimit);
const loadSearchHistory=()=>api('/api/search-history?limit='+appSettings.searchHistoryLimit).then(d=>{searchHistory=Array.isArray(d.items)?d.items:[];return searchHistory}).catch(()=>searchHistory);
const writeSearchHistory=list=>{searchHistory=list.slice(0,appSettings.searchHistoryLimit);return searchHistory};
-const rememberSearch=async query=>{if(!query)return;await api('/api/search-history',{method:'POST',body:JSON.stringify({query})});writeSearchHistory([query,...readSearchHistory().filter(x=>foldName(x)!==foldName(query))])};
+// 搜索本身是只读能力;账本暂时只读时,历史记录降级为本次页面内存,不能让一个
+// 非关键 POST 变成未处理异常或妨碍搜索结果。
+const rememberSearch=async query=>{if(!query)return;
+ writeSearchHistory([query,...readSearchHistory().filter(x=>foldName(x)!==foldName(query))]);
+ await api('/api/search-history',{method:'POST',body:JSON.stringify({query})}).catch(()=>null)};
function renderSearchMenu(){const menu=$('#searchMenu'),history=readSearchHistory();
const recommendations=[...searchPool()].sort(()=>Math.random()-.5).filter(x=>!history.some(h=>foldName(h)===foldName(x))).slice(0,5);
const row=(value,type)=>`<div class="searchoption" data-search-value="${esc(value)}">${icon(type==='history'?'history':'sparkles')}<span>${esc(value)}</span>${type==='history'?`<button class="removehistory" data-remove-history="${esc(value)}" aria-label="删除历史 ${esc(value)}">${icon('x')}</button>`:''}</div>`;
@@ -2764,7 +2776,7 @@ function renderSearchMenu(){const menu=$('#searchMenu'),history=readSearchHistor
b.onclick=async e=>{
e.stopPropagation();
const value=b.dataset.removeHistory;
- await api('/api/search-history',{method:'POST',body:JSON.stringify({operation:'remove',query:value})});
+ await api('/api/search-history',{method:'POST',body:JSON.stringify({operation:'remove',query:value})}).catch(()=>null);
writeSearchHistory(readSearchHistory().filter(x=>foldName(x)!==foldName(value)));
/* 只摘掉这一行,不整段重建:`renderSearchMenu` 每次都会把推荐词重新洗牌,
删一条历史却换了一批推荐,看着像列表自己跳了。 */