feat: 增加存储容量显示

This commit is contained in:
2026-09-01 09:20:46 +08:00
parent f85a6ded2a
commit bb5a9b3c0f
6 changed files with 28 additions and 14 deletions

View File

@@ -8,7 +8,7 @@
custom-style="border-radius: 32rpx 32rpx 0 0; padding: 40rpx 32rpx"
@close="handeClosePopup"
>
<view class="flex flex-col max-h-[85vh] overflow-y-auto">
<view class="flex flex-col max-h-[70vh] overflow-y-auto">
<view class="mb-5 text-center text-[30rpx] font-semibold text-[#333] shrink-0">
{{ appStore.currentTip.title }}
</view>

View File

@@ -10,7 +10,8 @@
</view>
<view class="flex flex-col items-center">
<wd-text :text="`${profileStore.storageTotal} / ${profileStore.storageMax}`"></wd-text>
<wd-text :text="`${profileStore.storageTotal} / ${profileStore.storageMax}`"></wd-text>
<wd-text :text="`共 ${profileStore.currentStorageSize} KB`"></wd-text>
<wd-progress
:percentage="Number((profileStore.storageTotal / profileStore.storageMax * 100).toFixed(2))"
:color="['#00c740', '#ffb300', '#e2231a']"/>
@@ -44,8 +45,7 @@ function clearMonth(month: string) {
success(res) {
if (res.confirm) {
deleteRecordByMonth(month)
profileStore.storageStats = countRecordsByMonth()
profileStore.storageTotal = getTotalCount()
profileStore.refreshStorage()
wx.showToast({ title: '已清除', icon: 'success' })
}
},

View File

@@ -69,6 +69,9 @@
</wd-card>
<wd-card title="🔥 今日资讯">
<wd-empty v-if="tipList.length === 0" icon="no-content"
:tip="errorMessage || '获取资讯失败,请检查网络连接或联系管理员'" />
<view
v-for="(item, index) in tipList"
:key="index"
@@ -137,6 +140,7 @@ const appStore = useAppStore()
const todayRecords = ref<IHealthRecord[]>([])
const tipList = ref<ITip[]>([])
const errorMessage = ref<string>("")
const hasSignedToday = ref(checkSignedToday())
const now = new Date()
@@ -171,7 +175,14 @@ const today = computed(() => {
onShow(() => {
todayRecords.value = getDayRecords(getDateStr(Date.now()))
hasSignedToday.value = checkSignedToday()
getTipList()
})
watch(() => recordStore.isRecord, () => {
todayRecords.value = getDayRecords(getDateStr(Date.now()))
})
function getTipList() {
wx.request({
url: 'https://cxx0822.s.3q.hair/health-api/agent/tip/latest',
method: 'GET',
@@ -181,13 +192,10 @@ onShow(() => {
},
fail: (err) => {
console.error('请求失败:', err);
errorMessage.value = err.errMsg
}
});
})
watch(() => recordStore.isRecord, () => {
todayRecords.value = getDayRecords(getDateStr(Date.now()))
})
}
const viewTipClick = (item: ITip) => {
appStore.currentTip = item

View File

@@ -132,9 +132,7 @@ function openStatsPopup() {
}
function openStoragePopup() {
profileStore.storageStats = countRecordsByMonth()
profileStore.storageTotal = getTotalCount()
profileStore.storageMax = getMaxRecord()
profileStore.refreshStorage()
profileStore.showStoragePopup = true
}

View File

@@ -3,7 +3,7 @@ import type { ITip } from "@/type";
export const useAppStore = defineStore('app', {
state: () => ({
version: '1.1.0',
version: '1.1.0.26090101',
viewRecordType: 'calendar',
points: 0,
recordCount: 0,

View File

@@ -1,6 +1,7 @@
import { defineStore } from 'pinia'
import type {IDefaultRecordValue, IProfile} from "@/type/profile";
import type {IStats} from "@/type";
import {countRecordsByMonth, getMaxRecord, getTotalCount} from "@/utils/record";
export const useProfileStore = defineStore('profile', {
state: () => ({
@@ -25,6 +26,7 @@ export const useProfileStore = defineStore('profile', {
bloodSugarValue: 5.4,
temperatureValue: 36.5,
} as IDefaultRecordValue,
currentStorageSize: 0,
storageStats: [] as IStats[],
storageTotal: 0,
storageMax: 1000,
@@ -35,6 +37,12 @@ export const useProfileStore = defineStore('profile', {
isRefresh: false,
}),
actions: {
refreshStorage() {
const storageInfo = wx.getStorageInfoSync()
this.currentStorageSize = storageInfo.currentSize
this.storageStats = countRecordsByMonth()
this.storageTotal = getTotalCount()
this.storageMax = getMaxRecord()
}
},
})