feat(usage): 首页使用时长加载态占位骨架

This commit is contained in:
tongtong committed 2026-12-02 22:53:54 +08:00
1 parent 6eb7dcbdd6
commit 3a1056db07
3 files changed
+29 -8

No files matched your search

+7 -3
View File
@@ -121,6 +121,7 @@ Page({
usageTotal: '—',
usageRingPercent: 0,
usageItems: [] as UsageItem[],
usageLoading: true,
deviceOps: [
{ key: 'screenshot', emoji: '📸', color: '#07C160', label: '屏幕截图' },
{ key: 'camera', emoji: '📷', color: '#0EA5E9', label: '远程相机' },
@@ -247,7 +248,8 @@ Page({
screenshots: [],
usageTotal: '—',
usageRingPercent: 0,
usageItems: []
usageItems: [],
usageLoading: false
})
return
}
@@ -320,7 +322,8 @@ Page({
this.setData({
usageTotal: formatUsageDuration(cached.total),
usageRingPercent: cached.items.length ? cached.items[0].percent : 0,
usageItems: cached.items
usageItems: cached.items,
usageLoading: false
})
}
try {
@@ -336,7 +339,8 @@ Page({
this.setData({
usageTotal: formatUsageDuration(total),
usageRingPercent: items.length ? items[0].percent : 0,
usageItems: items
usageItems: items,
usageLoading: false
})
saveUsageTodayCache(sn, today, { total, items })
} catch {
+14 -5
View File
@@ -92,12 +92,21 @@
</view>
</view>
<view class="usage-bars">
<view class="usage-bar" wx:for="{{usageItems}}" wx:key="key">
<text class="usage-bar-label">{{item.label}}</text>
<view class="usage-bar-track">
<view class="usage-bar-fill" style="width: {{item.percent}}%; background: {{item.color}};"></view>
<!-- 加载中占位:三条灰色骨架条 -->
<block wx:if="{{usageLoading}}">
<view class="usage-bar" wx:for="{{[1,2,3]}}" wx:key="*this">
<view class="usage-skeleton-label"></view>
<view class="usage-bar-track"></view>
</view>
</view>
</block>
<block wx:else>
<view class="usage-bar" wx:for="{{usageItems}}" wx:key="key">
<text class="usage-bar-label">{{item.label}}</text>
<view class="usage-bar-track">
<view class="usage-bar-fill" style="width: {{item.percent}}%; background: {{item.color}};"></view>
</view>
</view>
</block>
</view>
</view>
</view>
+8
View File
@@ -318,3 +318,11 @@
width: 25%;
padding: 0 0 24rpx;
}
.usage-skeleton-label {
width: 132rpx;
height: 20rpx;
flex-shrink: 0;
border-radius: 6rpx;
background: var(--track);
}