From 9f55e142faa60b37ef643bf4e48b94b210f40158 Mon Sep 17 00:00:00 2001 From: TongTongStudio Date: Thu, 3 Dec 2026 01:20:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(usage):=20=E9=A6=96=E9=A1=B5=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=97=B6=E9=95=BF=E5=BA=94=E7=94=A8=E8=A1=8C=E9=A1=B6?= =?UTF-8?q?=E9=83=A8=E5=AF=B9=E9=BD=90=E5=B9=B6=E5=9B=BA=E5=AE=9A=E4=B8=89?= =?UTF-8?q?=E8=A1=8C=E9=AB=98=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - usage-body 改 flex-start,应用行与左侧环形同高起排(单行不再居中) - 条列固定 3 行高度,不足 3 行补占位行,卡片高度与首行位置稳定 --- pages/home/index.ts | 13 ++++++++++++- pages/home/index.wxml | 2 ++ pages/home/index.wxss | 11 ++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/pages/home/index.ts b/pages/home/index.ts index d7df42f..36d4250 100644 --- a/pages/home/index.ts +++ b/pages/home/index.ts @@ -121,6 +121,7 @@ Page({ usageTotal: '—', usageRingPercent: 0, usageItems: [] as UsageItem[], + placeholderCount: [1, 2, 3] as number[], usageLoading: true, deviceOps: [ { key: 'screenshot', emoji: '📸', color: '#07C160', label: '屏幕截图' }, @@ -323,6 +324,7 @@ Page({ usageTotal: formatUsageDuration(cached.total), usageRingPercent: cached.items.length ? cached.items[0].percent : 0, usageItems: cached.items, + placeholderCount: placeholderRows(cached.items.length), usageLoading: false }) } @@ -351,15 +353,18 @@ Page({ usageTotal: formatUsageDuration(total), usageRingPercent: items.length ? items[0].percent : 0, usageItems: items, + placeholderCount: placeholderRows(items.length), usageLoading: false }) saveUsageTodayCache(sn, today, { total, items }) } catch { // 请求失败结束骨架,避免一直显示占位 + const items = cached ? this.data.usageItems : [] this.setData({ usageTotal: cached ? this.data.usageTotal : '0s', usageRingPercent: cached ? this.data.usageRingPercent : 0, - usageItems: cached ? this.data.usageItems : [], + usageItems: items, + placeholderCount: placeholderRows(items.length), usageLoading: false }) } @@ -578,3 +583,9 @@ function dayKey(time: Date): string { const pad = (n: number) => String(n).padStart(2, '0') return `${time.getFullYear()}-${pad(time.getMonth() + 1)}-${pad(time.getDate())}` } + +/** 补足到 3 行所需的占位行数量 */ +function placeholderRows(count: number): number[] { + const need = Math.max(0, 3 - count) + return Array.from({ length: need }, (_, i) => i) +} diff --git a/pages/home/index.wxml b/pages/home/index.wxml index 476beda..1ba7ac4 100644 --- a/pages/home/index.wxml +++ b/pages/home/index.wxml @@ -106,6 +106,8 @@ + + diff --git a/pages/home/index.wxss b/pages/home/index.wxss index c85e022..bb00274 100644 --- a/pages/home/index.wxss +++ b/pages/home/index.wxss @@ -174,7 +174,8 @@ /* 使用时长 */ .usage-body { display: flex; - align-items: center; + /* 顶部对齐:应用行与左侧环形同高起排,1 行时不垂直居中 */ + align-items: flex-start; } .usage-ring { @@ -219,6 +220,8 @@ .usage-bars { flex: 1; margin-left: var(--gutter); + /* 固定 3 行高度,应用数变化时卡片高度与首行位置不变 */ + height: 144rpx; } .usage-bar { @@ -233,6 +236,12 @@ margin-bottom: 0; } +/* 不足 3 行时的占位行,保持首行位置一致 */ +.usage-bar-placeholder { + height: 40rpx; + margin-bottom: 12rpx; +} + .usage-bar-label { flex-shrink: 0; width: 132rpx;