Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 完善管理页骨架与容量显示

longmeidao312323c3ef29
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index f94e3271f..107a4b54e 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -2211,7 +2211,6 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageLacks("skeleton-pulse", "呼吸已经换成扫光,不留死引用")
# 框体(数据管理的操作条、关注管理的头部条)不是待填内容,不参与微光。
self.assertPageContains(
- ".cleanup-skeleton .skeletoncard em::after,\n"
".followmanage-skeleton .skeletoncard i::after{content:none}")
def test_index_skeletons_share_final_geometry_and_keep_the_header(self):
@@ -5438,8 +5437,6 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageLacks("loadingDotsHtml('正在读取数据管理状态…')")
self.assertPageLacks(".cleanuploading")
# 数据管理是一列 fieldset,骨架不能是三列海报网格。
- self.assertPageContains(".cleanup-skeleton>div{grid-template-columns:minmax(0,1fr);gap:16px}")
- self.assertPageContains(".cleanup-skeleton .skeletoncard em{width:100%;height:var(--fieldset-bar-h)")
def test_follow_manage_skeleton_matches_its_single_column_sections(self):
"""关注管理的骨架是三个大区,不是六张 16:9 卡片。
@@ -6050,10 +6047,9 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("const props={receipt:message=>actionReceipt(message)};")
self.assertPageContains(
"document.body.classList.toggle('configuration-layout',current==='configuration');")
- # 骨架照最终结构:两块同宽的卡,和数据管理那套单列卡片一个轮廓。
- self.assertPageContains(
- "'/configuration':()=>`<div class=\"configpage\">${pageSkeletonHtml('正在读取配置',")
- self.assertPageContains("{cards:true,count:2,fill:false,className:'cleanup-skeleton'})}</div>`,")
+ self.assertPageContains("'/configuration':()=>configurationSkeletonHtml()")
+ self.assertPageContains('stats-lede-skeleton')
+ self.assertPageContains("['网络与访问',2]")
def test_review_page_is_a_separate_management_layer(self):
self.assertPageContains("route('/review')")
diff --git a/web/app.js b/web/app.js
index bfbbd2c4b..626c126a8 100644
--- a/web/app.js
+++ b/web/app.js
@@ -13,7 +13,7 @@ import {
fillSkeletonTier, fitSkeleton, iconSwitchHtml, indexSkeletonHtml, loadingDotsHtml,
mediaViewButtonsHtml, noteHtml, progressHtml, gaugeHtml, scrollerHtml, searchInputHtml, selectFieldHtml,
setActionBusy, skeletonHtml, spinnerHtml, wireAnchoredMenu, wireBusyActions, wireCollapse,
- wireIconSwitch, wireOverlayScrollbars, wireScrollers, wireSelectField, wireContextCard,
+ wireIconSwitch, wireOverlayScrollbars, wireScrollers, wireSelectField, wireContextCard, configurationSkeletonHtml,
} from './js/ui-components.js';
initMiddleTruncate(document);
@@ -240,7 +240,7 @@ function renderCatalogLoading(label='正在读取作品'){
加载态(数据管理那张还是 Loading Dots)。取同一份,键就相同,
showManagementBody 认出是同一张后不再重画。 */
const MANAGEMENT_PLACEHOLDERS={
- '/stats':()=>`<div class="insightpage">${pageSkeletonHtml('正在读取统计',{variant:'dashboard'})}</div>`,
+ '/stats':()=>`<div class="insightpage"><div class="insighttoolbar" aria-hidden="true"><span class="skeleton stats-lede-skeleton"></span></div>${pageSkeletonHtml('正在读取统计',{variant:'dashboard'})}</div>`,
// 口味页与统计页同一套版式:指标带、一块主详情、下面同层的数据面板。
'/taste':()=>`<div class="tastepage">${pageSkeletonHtml('正在读取口味分析',{variant:'dashboard'})}</div>`,
'/data-cleanup':()=>cleanupSkeletonHtml(),
@@ -254,9 +254,7 @@ const MANAGEMENT_PLACEHOLDERS={
// 骨架照 .fsec 的轮廓画三块,六张 16:9 占位说的是另一个页面的结构。
'/follow-manage':()=>`<div class="follow">${pageSkeletonHtml('正在读取关注管理',
{cards:true,count:3,fill:false,className:'followmanage-skeleton'})}</div>`,
- // 配置页是两块同宽的卡(表单、运行信息),骨架照数据管理那套单列卡片的轮廓画两块。
- '/configuration':()=>`<div class="configpage">${pageSkeletonHtml('正在读取配置',
- {cards:true,count:2,fill:false,className:'cleanup-skeleton'})}</div>`,
+ '/configuration':()=>configurationSkeletonHtml(),
};
const managementPlaceholder=path=>
(MANAGEMENT_PLACEHOLDERS[path]||(()=>pageSkeletonHtml('正在读取页面')))();
@@ -2945,7 +2943,7 @@ async function openStats(push=true){
`<div class="insightempty">${emptyStateHtml('tags','还没有标签来源','刮削或手动打标之后,这里会显示每个来源覆盖了多少视频。')}</div>`);
const storageTable=(d.storage_volumes||[]).length?`<table class="insightdatatable"><thead><tr><th>位置</th><th>已用</th><th>可用</th><th>使用率</th></tr></thead><tbody>${(d.storage_volumes||[]).map(row=>{
const measured=row.total!=null, usedPct=measured?pct(row.used,row.total):0;
- return `<tr><th scope="row"><span>${esc(row.label)}</span><small>${row.root?esc(row.root):'未映射'}</small></th><td>${measured?gb(row.used):'—'}</td><td>${measured?gb(row.free):'—'}</td><td>${measured?gaugeHtml(`${row.label}空间使用率`,row.used,row.total,{usage:true})+usedPct+'%':(row.online?'容量未取得':'离线')}</td></tr>`}).join('')}</tbody></table>`
+ return `<tr><th scope="row"><span>${esc(row.label)}</span><small>${row.root?esc(row.root):'未映射'}</small></th><td>${measured?gb(row.used):'—'}</td><td>${measured?gb(row.free):'—'}</td><td>${measured?gaugeHtml(`${row.label}空间使用率`,row.used,row.total,{usage:true,compact:true})+usedPct+'%':(row.online?'容量未取得':'离线')}</td></tr>`}).join('')}</tbody></table>`
:emptyStateHtml('hard-drive','还没有存储来源','添加媒体文件夹后,这里会显示存储空间。');
$('#stats').innerHTML=`
<div class="insightpage statsdashboard" data-stats-dashboard>
@@ -3292,8 +3290,8 @@ function renderTaste(d){
<label><input type="radio" name="taste-evidence" value="browser"${tasteEvidence==='browser'?' checked':''}><span>浏览器记录</span></label>
<label><input type="radio" name="taste-evidence" value="peach"${tasteEvidence==='peach'?' checked':''}><span>Peach 内部</span></label></div>
<div class="tasteactions">${selectFieldHtml(TASTE_WINDOWS,d.window||tasteWindow,{label:'分析范围',attr:'data-taste-window'})}
- <button data-taste-refresh>${icon('refresh-cw')}读取 Peach 主机</button>
- <button data-taste-import>${icon('upload')}导入历史</button><input data-taste-file type="file" hidden></div></header>
+ <button data-taste-refresh title="读取运行 Peach 的这台电脑上的浏览记录">${icon('refresh-cw')}读取浏览器历史</button>
+ <button data-taste-import>${icon('upload')}导入历史文件</button><input data-taste-file type="file" hidden></div></header>
${tasteHistoryGuideHtml(new URLSearchParams(location.search).get('onboarding')==='1',Boolean(s.history_sources||d.updated_at),localStorage.getItem(TASTE_GUIDE_KEY)==='1')}
<div class="tastestate" data-taste-state role="status" aria-live="polite"></div>
<div class="tastesummaries" data-taste-summary="browser"${tasteEvidence==='browser'?'':' hidden'}>
@@ -4725,7 +4723,7 @@ function wireTasteProgress(){
if(!button)return;
return wireOperationProgress({host:$('#stats').querySelector('[data-taste-state]'),
path:'/api/taste/refresh',key:'peach-taste-job',title:'正在读取浏览记录并更新口味分析…',
- busy:running=>{setActionBusy(button,running);button.innerHTML=`${icon('refresh-cw')}读取 Peach 主机`},
+ busy:running=>{setActionBusy(button,running);button.innerHTML=`${icon('refresh-cw')}读取浏览器历史`},
complete:()=>{tasteCache.clear();void openTaste(false);actionReceipt('已更新口味分析')}});
}
function wireResolveProgress(){
diff --git a/web/css/09-skeleton.css b/web/css/09-skeleton.css
index c289437d7..089851e1a 100644
--- a/web/css/09-skeleton.css
+++ b/web/css/09-skeleton.css
@@ -54,16 +54,6 @@
卡内间距。 */
.follow-content-skeleton .skeletoncard em{height:21px}
.follow-content-skeleton .skeletoncard{padding-bottom:8px}
-/* 数据管理是一列 fieldset,不是海报网格:骨架照 fieldset 的轮廓排,
- 否则整页刷新先看到三列 16:9 占位,加载完又整个换成一列长条。
- 底部那条是操作条的位置,不参与微光——它是框体,不是待填的内容。 */
-.cleanup-skeleton>div{grid-template-columns:minmax(0,1fr);gap:16px}
-.cleanup-skeleton .skeletoncard{gap:0;overflow:hidden;border:1px solid var(--line-soft);
- border-radius:var(--floating-radius);background:var(--ground)}
-.cleanup-skeleton .skeletoncard i{aspect-ratio:auto;width:38%;height:20px;margin:20px 20px 0}
-.cleanup-skeleton .skeletoncard b{width:26%;height:16px;margin:12px 20px 20px}
-.cleanup-skeleton .skeletoncard em{width:100%;height:var(--fieldset-bar-h);margin:0;
- border-radius:0;border-top:1px solid var(--border-10);background:var(--overlay-5)}
/* 关注管理是一列三块(添加关注、关注列表、凭据)的行政界面:骨架照 .fsec 的轮廓画,
一块对一块、宽度跟着 .followmanage 一起限到 812px。头部条是框体不是待填内容,
跟 .fsechead 同高同底色,不参与微光。 */
@@ -134,9 +124,9 @@ body.refreshing #tiers .brandpill::after{content:'';position:absolute;inset:0;ri
background-size:50% 100%;
animation:skeleton-sweep 1.5s ease-in-out infinite reverse}
/* 框体不是待填的内容,本来就不参与呼吸,也不参与微光。 */
-.cleanup-skeleton .skeletoncard em::after,
.followmanage-skeleton .skeletoncard i::after{content:none}
+
/* 计数骨架的宽高定死:跟着真实文本走的话,数字回来那一刻整行会横向弹一下。
14px 远低于筛选条按钮的 32px,而 `.count` 有 min-height 兜底,所以换成真数字
不改变行高。`视频 · N` 用的是同一枚。 */
@@ -172,3 +162,7 @@ body.refreshing #tiers .av .ring,body.refreshing #tiers .av .nm,
body.refreshing #tiers .brandpill{visibility:hidden;background:var(--hover)}
body.refreshing #tiers .av .nm{width:52px;margin:0 auto;border-radius:var(--control-radius)}
body.refreshing #tiers .brandpill{border-color:transparent}
+
+.stats-lede-skeleton{display:block;width:min(380px,75%);height:22px;margin-bottom:16px}
+.config-skeleton-card{border:1px solid var(--line);border-radius:var(--surface-radius);margin-bottom:16px;overflow:hidden}
+.config-skeleton-card>div{padding:24px;display:grid;gap:16px}.config-skeleton-card .skeleton{display:block;height:20px;width:60%}.config-skeleton-card .skeleton:first-child{height:24px;width:35%}.config-skeleton-card .skeleton:last-child{height:38px;width:100%}.config-skeleton-card footer{border-top:1px solid var(--line);padding:12px 24px;display:flex;justify-content:flex-end}.config-skeleton-card footer .skeleton:last-child{width:100px;height:38px}
diff --git a/web/css/23-configuration.css b/web/css/23-configuration.css
index dc211364d..9d1beb34d 100644
--- a/web/css/23-configuration.css
+++ b/web/css/23-configuration.css
@@ -86,3 +86,5 @@
.configfacts dt .gselectmark{vertical-align:-3px;margin-inline-end:8px}
@media(max-width:560px){.configfacts{grid-template-columns:minmax(0,1fr)}.configfacts dd{margin-top:-6px}}
@media(max-width:560px){.configpage{--control-h:44px}.configfieldset>.geist-fieldset-footer{flex-wrap:wrap}.configsource .geist-input{font-size:var(--fs-lg)}}
+
+.configrm.geist-button:not(:disabled){color:#fff;background:var(--drop);border-color:var(--drop)}
diff --git a/web/js/ui-components.js b/web/js/ui-components.js
index 5f562a48a..e10696e5a 100644
--- a/web/js/ui-components.js
+++ b/web/js/ui-components.js
@@ -18,13 +18,18 @@ export function projectBannerHtml(message,{variant='gray',href,label,value,max}=
return `<aside class="project-banner ${PROJECT_BANNER_CLASSES[kind]}" role="${kind==='error'?'alert':'status'}"><div>${Number(max)>0?gaugeHtml('任务完成率',value,max):icon(kind==='error'||kind==='warning'?'alert':'info')}<p>${esc(message)}</p></div><a href="${esc(href)}">${esc(label)}</a></aside>`;
}
-export function gaugeHtml(label,value,max=100,{usage=false}={}){
+export function gaugeHtml(label,value,max=100,{usage=false,compact=false}={}){
const ceiling=Number(max), current=Number(value);
if(!Number.isFinite(ceiling)||ceiling<=0||!Number.isFinite(current))return `<span>${esc(label)}:未取得</span>`;
const percent=Math.max(0,Math.min(100,current/ceiling*100));
const level=usage?(percent>=95?'error':percent>=80?'warning':'normal'):'normal';
const status=usage?(level==='error'?'空间即将用满':level==='warning'?'空间使用偏高':'空间充足'):'';
- return `<span class="geist-gauge" data-level="${level}" role="progressbar" aria-label="${esc(label+(status?':'+status:''))}" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${percent}"><svg viewBox="0 0 32 32" aria-hidden="true"><circle cx="16" cy="16" r="13"/><circle cx="16" cy="16" r="13" pathLength="100" stroke-dasharray="${percent} 100"/></svg></span>${status?`<span class="gauge-status">${status}</span>`:''}`;
+ return `<span class="geist-gauge" data-level="${level}" role="progressbar" aria-label="${esc(label+(status?':'+status:''))}" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${percent}"><svg viewBox="0 0 32 32" aria-hidden="true"><circle cx="16" cy="16" r="13"/><circle cx="16" cy="16" r="13" pathLength="100" stroke-dasharray="${percent} 100"/></svg></span>${status&&!compact?`<span class="gauge-status">${status}</span>`:''}`;
+}
+
+export function configurationSkeletonHtml(){
+ const groups=[['通用',1],['媒体',2],['网络与访问',2],['更新与维护',3]];
+ return `<div class="configpage" data-skeleton="configuration" role="status" aria-label="正在读取配置"><span class="sr-only">正在读取配置</span><div aria-hidden="true">${groups.map(([label,count])=>`<h2 class="configgroup">${label}</h2>${Array.from({length:count},()=>`<div class="config-skeleton-card"><div><span class="skeleton"></span><span class="skeleton"></span><span class="skeleton"></span></div><footer><span class="skeleton"></span></footer></div>`).join('')}`).join('')}</div></div>`;
}
/**