Peach: Local-first video metadata scraper and media manager.
fix(web): 账本只读那一条改用 Note,图标与文字跟着色调走
longmeidaob150daa7d33b
diff --git a/frontend/src/legacy/ui.d.ts b/frontend/src/legacy/ui.d.tsindex eca87f85d..b2cea66f9 100644--- a/frontend/src/legacy/ui.d.ts+++ b/frontend/src/legacy/ui.d.ts@@ -48,6 +48,8 @@ export declare function noteHtml(className?: string;size?: 'small' | 'medium';actionLabel?:string; filled?: boolean;+ /** 恢复动作要离开本页才做得成时给出目标地址,动作由按钮换成同格子的链接。 */+ actionHref?: string;/** 逐条明细,收在 Note 里默认折叠的 details;`hint` 放路径这类次要标注。 */details?: {label: string;diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex f2ec66d2c..d2d4222fa 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -4714,15 +4714,35 @@ class WebUiSourceTests(unittest.TestCase):def test_note_and_info_surfaces_reuse_the_photo_detail_info_icon(self):self.assertPageContains('<symbol id="i-info" viewBox="0 0 24 24">')- self.assertPageContains('<div class="runtimegate">${icon(\'info\')}<span>${esc(mirrorText)}</span>')- self.assertPageContains('<div class="runtimegate">${icon(\'info\')}<span>${esc(followRuntime.ledger_read_only_message')self.assertPageContains("${icon('info')}<div><p><b>${exhausted.length} 个来源没有更多内容</b>")self.assertPageContains('aria-label="凭据存放位置说明">${icon(\'info\')}</button>')self.assertPageContains('aria-label="图片详情" title="图片详情">${icon(\'info\')}</button>')- self.assertPageContains('.runtimegate{display:grid;grid-template-columns:16px minmax(0,1fr) auto;align-items:center;gap:12px')- self.assertPageContains('.runtimegate>svg{width:16px;height:16px;flex:none;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}')self.assertPageContains('.geist-note>svg{width:16px;height:24px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}')- self.assertPageContains('.runtimegate a{grid-column:2/-1}')++ def test_the_ledger_gate_is_a_note_and_keeps_its_own_tone(self):+ # 账本只读那一条是 Note:色调由 --feedback-color 一处给出,底色、图标和正文+ # 出自同一个色调。自画一只框的写法会让底色说「注意」、字说「普通说明」。+ self.assertPageContains("function ledgerGateNote(runtime,message,actionLabel,actionHref){")+ self.assertPageContains("variant:runtime?.ledger_sync==='conflict'?'warning':'secondary'")+ self.assertPageContains("className:'runtimegate',actionLabel:actionHref?actionLabel:'',actionHref}")+ self.assertPageContains("ledgerGateNote(reviewRuntime,mirrorText,'前往写入端复核',writer)")+ self.assertPageContains("ledgerGateNote(followRuntime,followRuntime.ledger_read_only_message||'本机当前只能浏览',")+ self.assertPageContains('.geist-note.runtimegate{margin:0 0 12px}')+ # 这个类名只剩定位:框、字形和颜色再出现一份就又能和 Note 走散。+ self.assertPageLacks('.runtimegate{display:grid')+ self.assertPageLacks('.runtimegate a{')+ self.assertPageLacks('<div class="runtimegate">')+ # 四个色调各自给出前景与背景,前景既是文字色也是图标色(currentColor)。+ self.assertPageContains('.geist-note{--feedback-color:var(--muted);')+ self.assertPageContains('background:color-mix(in srgb,var(--feedback-color) 8%,var(--ground));color:var(--feedback-color)')+ self.assertPageContains('.geist-note-warning{--feedback-color:var(--meter);')+ self.assertPageContains('.geist-note-error{--feedback-color:var(--drop);')+ self.assertPageContains('.geist-note-success{--feedback-color:var(--feedback-success);')+ # 恢复动作在另一台机器上时是链接;两种形态占同一个格子。+ self.assertPageContains(+ '<a class="geist-button" href="${esc(actionHref)}" data-note-action>${esc(actionLabel)}</a>')+ self.assertPageContains(+ '<button type="button" class="geist-button primary" data-note-action>${esc(actionLabel)}</button>')# 横幅是第四个装这两枚字形的容器。圆点是长度 .01 的路径,缺了圆头就渲染成# 看不见的薄片,警告只剩上半截竖杠。选择器认直接子元素:带进度时横幅里那一枚# 圆环归 `.geist-gauge`,它的端点是弧的两头而不是字形笔画。diff --git a/web/app.js b/web/app.jsindex 6d8e699ef..1abe846f3 100644--- a/web/app.js+++ b/web/app.js@@ -3726,6 +3726,17 @@ function renderCombo(){}/* ── 统计与管理 ── */+/* 账本只读时铺在复核页与关注管理页顶上的那一条,用的就是 Note,不另画一只框:+ 图标、文字和底色要出自同一个色调,自己描一圈暖色边再把字写成 --ink 的话,+ 背景说的是「注意」、字说的是「普通说明」,两句话对不上。++ 色调跟着成因走:另一台机器持有写入权是正常分工,只是说明现状,走中性档;+ 冲突要人照日志处理,属于必须先被看见的故障,走 warning。恢复动作在另一台+ 机器上,所以是链接不是按钮。 */+function ledgerGateNote(runtime,message,actionLabel,actionHref){+ return noteHtml(message,{variant:runtime?.ledger_sync==='conflict'?'warning':'secondary',+ className:'runtimegate',actionLabel:actionHref?actionLabel:'',actionHref});+}/* 整页视图接管页面主体。这段六行的显隐此前在八个入口里各抄了一份,每份还带着随手的小差异:空格、顺序、@@ -4059,7 +4070,7 @@ function wireResourceApplyProgress(){return wireOperationProgress({host:$('#resource-sync'),path:'/api/resource-sync/apply',key:'peach-resource-apply-job',title:'正在检查文件并清理…',busy:running=>{const button=$('#resourceApply');if(button){setActionBusy(button,running);if(!running)button.textContent='清理失效记录与缓存'}},complete:out=>{const failed=out.cache_blocked||[];- $('#resourceSyncResult').innerHTML=noteHtml(`已把 ${out.moved_to_trash} 项记录移入回收站,清理 ${out.cache_removed} 个缓存,释放 ${fmtSize(out.bytes_reclaimed||0)}。${failed.length?`${failed.length} 个缓存未能清理,请重新检查后重试。`:''}`,{label:failed.length?'部分完成':'清理结果',variant:failed.length?'warning':'default'});+ $('#resourceSyncResult').innerHTML=noteHtml(`已把 ${out.moved_to_trash} 项记录移入回收站,清理 ${out.cache_removed} 个缓存,释放 ${fmtSize(out.bytes_reclaimed||0)}。${failed.length?`${failed.length} 个缓存未能清理,请重新检查后重试。`:''}`,{label:failed.length?'部分完成':'清理结果',variant:failed.length?'warning':'success'});if(!failed.length)actionReceipt('已清理失效记录与缓存')}});}/* 旧直达 URL 仍然可用,落点跟着面板一起搬到数据管理。 */@@ -4785,8 +4796,7 @@ async function openReview(push=true){:mirror?.error||reviewRuntime.ledger_read_only_message||'';const value=row=>row.tags||row.japanese_name||row.path||row.suggested_query||'';$('#stats').innerHTML=`<div class="review review-workspace">- ${locked?`<div class="runtimegate">${icon('info')}<span>${esc(mirrorText)}</span>${writer- ?`<a href="${esc(writer)}">前往写入端复核</a>`:''}</div>`:''}${+ ${locked?ledgerGateNote(reviewRuntime,mirrorText,'前往写入端复核',writer):''}${/* 收录 genre 时的候选词表。给的是静态表已经投影到的那批内容标签,一份挂在整页上:每张卡各写一遍的话,同一百来个 option 会在 DOM 里重复几十份。 */(reviewData.genre_tags||[]).length?`<datalist id="reviewgenretags">${@@ -6265,8 +6275,8 @@ function renderFollowManage(credentials){const writer=followRuntime?.ledger_writer_origin?new URL('/follow-manage',followRuntime.ledger_writer_origin).href:'';$('#stats').innerHTML=`<div class="follow followmanage">- ${locked?`<div class="runtimegate">${icon('info')}<span>${esc(followRuntime.ledger_read_only_message||'本机当前只能浏览')}</span>${writer- ?`<a href="${esc(writer)}">前往写入端管理关注</a>`:''}</div>`:''}+ ${locked?ledgerGateNote(followRuntime,followRuntime.ledger_read_only_message||'本机当前只能浏览',+ '前往写入端管理关注',writer):''}<div class="fmanageoverview" aria-label="关注概览"><div><span>关注作者</span><b>${groups.length}<small> 位</small></b></div><div><span>启用来源</span><b>${sources.filter(source=>source.enabled).length}<small> / ${sources.length}</small></b></div>diff --git a/web/css/04-manage.css b/web/css/04-manage.cssindex 642a26120..2349da0ae 100644--- a/web/css/04-manage.css+++ b/web/css/04-manage.css@@ -9,7 +9,10 @@/* 一份播放列表就是一叠视频,和首页那张 Mix 卡是同一件东西:封面、叠层、悬浮翻动和署名行全部走 .card / .mixstack / .mixmeta,这里只定这一页的栅格。 */.playlistcards{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:18px}-.runtimegate{display:grid;grid-template-columns:16px minmax(0,1fr) auto;align-items:center;gap:12px;margin:0 0 12px;padding:10px 12px;border:1px solid color-mix(in srgb,var(--meter) 35%,var(--line));border-radius:var(--control-radius);background:color-mix(in srgb,var(--meter) 8%,var(--surface));color:var(--ink);font-size:var(--fs-sm)}.runtimegate>svg{width:16px;height:16px;flex:none;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}.runtimegate span{min-width:0}.runtimegate a{color:var(--ink);font-weight:600;text-decoration:none}.runtimegate a:hover{color:var(--ink-2)}+/* 账本只读那一条是 Note:框、图标字形和整套色调都在 `.geist-note` 那一份里,这里只留+ 它在页面里的位置。自己再描一圈暖色边、把字写成 --ink 的话,底色说的是「注意」、+ 文字说的是「普通说明」,同一条提示上两句话对不上。 */+.geist-note.runtimegate{margin:0 0 12px}.review{--review-fieldset-height:440px;padding:0 0 42px}.reviewsection{margin-bottom:20px}.reviewsection h3{margin:0 0 9px;font-size:var(--fs-lg)}.reviewlist{display:grid;grid-template-columns:repeat(auto-fill,minmax(360px,1fr));gap:14px;align-items:start}/* 判定状态用左侧色条表达:整卡描边在一列里扫过去时反而认不出来 */.reviewitem{position:relative;display:flex;flex-direction:column;box-sizing:border-box;height:var(--review-fieldset-height);margin:0;padding:0;min-width:0;overflow:hidden;background:var(--ground);border:1px solid var(--field-ring);border-radius:var(--floating-radius)}.reviewitem::before{content:'';position:absolute;z-index:3;left:0;top:0;bottom:0;width:3px;background:transparent}.reviewitem[data-decision="approved"]::before{background:var(--keep)}.reviewitem[data-decision="rejected"]::before{background:var(--drop)}.reviewitem[data-decision="skipped"]::before{background:var(--muted)}.reviewitem[data-decision="rejected"],.reviewitem[data-decision="skipped"]{opacity:.6}.reviewitem h4{margin:0 0 6px;font-size:var(--fs-lg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.reviewitem p{margin:4px 0;color:var(--muted);font-size:var(--fs-xs);line-height:1.55;overflow-wrap:anywhere}diff --git a/web/css/19-immersive.css b/web/css/19-immersive.cssindex b46eebee4..d8ec5f834 100644--- a/web/css/19-immersive.css+++ b/web/css/19-immersive.css@@ -120,7 +120,6 @@ body:has(#batchbar:not([hidden])) #stage{padding-bottom:180px}.managebar-menu{display:none;margin-top:8px;padding:6px;border:1px solid var(--line-soft);border-radius:var(--floating-radius);background:var(--ground);grid-template-columns:repeat(2,minmax(0,1fr));gap:4px}.managebar.is-open .managebar-menu{display:grid}- .runtimegate a{grid-column:2/-1}.managebar-menu button{width:100%;min-height:42px;justify-content:flex-start;padding:9px 11px}.cleanupgrid{grid-template-columns:minmax(0,1fr)}/* 说明行右端的动作在手机上要够手指点:桌面 32px 是 Geist 的控件高度,触摸区按本项目diff --git a/web/js/ui-components.js b/web/js/ui-components.jsindex 5ae938c1f..8e883720c 100644--- a/web/js/ui-components.js+++ b/web/js/ui-components.js@@ -167,13 +167,18 @@ export function collectionSummaryHtml(label,value,detail=''){return `<header class="collection-summary"><div><span>${esc(label)}</span><strong>${esc(value)}</strong></div>${detail?`<p>${esc(detail)}</p>`:''}</header>`;}-/** Inline, persistent context beside the field/card/section it describes. */-export function noteHtml(message,{variant='secondary',label='',className='',size='medium',filled=false,actionLabel='',details=null}={}){+/* Inline, persistent context beside the field/card/section it describes.+ 恢复动作有两种形态:留在本页执行的走按钮,要离开本页才做得成的走链接。+ 两者占同一个格子、同一枚 `data-note-action`,Note 的版式不因为它是 <a> 改变。 */+export function noteHtml(message,{variant='secondary',label='',className='',size='medium',filled=false,actionLabel='',actionHref='',details=null}={}){const kind=NOTE_VARIANTS.has(variant)?variant:'secondary';const symbol=kind==='secondary'?'info':kind==='success'?'check':'alert';const role=kind==='error'?' role="alert"':' role="note"';+ const action=!actionLabel?''+ :actionHref?`<a class="geist-button" href="${esc(actionHref)}" data-note-action>${esc(actionLabel)}</a>`+ :`<button type="button" class="geist-button primary" data-note-action>${esc(actionLabel)}</button>`;return `<div class="geist-note geist-note-${kind}${className?` ${esc(className)}`:''}${size==='small'?' geist-note-small':''}${filled?' geist-note-filled':''}"${role}>- ${icon(symbol)}<p>${label?`<b>${esc(label)}</b>`:''}<span>${esc(kind==='error'?requestErrorMessage(message):message)}</span></p>${actionLabel?`<button type="button" class="geist-button primary" data-note-action>${esc(actionLabel)}</button>`:''}${details?noteDetailsHtml(details):''}</div>`;+ ${icon(symbol)}<p>${label?`<b>${esc(label)}</b>`:''}<span>${esc(kind==='error'?requestErrorMessage(message):message)}</span></p>${action}${details?noteDetailsHtml(details):''}</div>`;}const PROJECT_BANNER_CLASSES={gray:'project-banner-gray',success:'project-banner-success',warning:'project-banner-warning',error:'project-banner-error'};