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;