From bb5a9b3c0f80da6feb545693bdd9de10c7894949 Mon Sep 17 00:00:00 2001 From: Cxx0822 <1556464090@qq.com> Date: Tue, 1 Sep 2026 09:20:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E5=AE=B9=E9=87=8F=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Home/TipPopup.vue | 2 +- src/components/Profile/StoragePopup.vue | 6 +++--- src/pages/index/index.vue | 18 +++++++++++++----- src/pages/user/index.vue | 4 +--- src/store/app.ts | 2 +- src/store/profile.ts | 10 +++++++++- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/components/Home/TipPopup.vue b/src/components/Home/TipPopup.vue index 8e5476d..ab3bc53 100644 --- a/src/components/Home/TipPopup.vue +++ b/src/components/Home/TipPopup.vue @@ -8,7 +8,7 @@ custom-style="border-radius: 32rpx 32rpx 0 0; padding: 40rpx 32rpx" @close="handeClosePopup" > - + {{ appStore.currentTip.title }} diff --git a/src/components/Profile/StoragePopup.vue b/src/components/Profile/StoragePopup.vue index 30375be..c9a1b2a 100644 --- a/src/components/Profile/StoragePopup.vue +++ b/src/components/Profile/StoragePopup.vue @@ -10,7 +10,8 @@ - + + @@ -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' }) } }, diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index a337077..3d75d92 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -69,6 +69,9 @@ + + ([]) const tipList = ref([]) +const errorMessage = ref("") 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 diff --git a/src/pages/user/index.vue b/src/pages/user/index.vue index d38bdb2..5703e97 100644 --- a/src/pages/user/index.vue +++ b/src/pages/user/index.vue @@ -132,9 +132,7 @@ function openStatsPopup() { } function openStoragePopup() { - profileStore.storageStats = countRecordsByMonth() - profileStore.storageTotal = getTotalCount() - profileStore.storageMax = getMaxRecord() + profileStore.refreshStorage() profileStore.showStoragePopup = true } diff --git a/src/store/app.ts b/src/store/app.ts index 44accc2..b94d655 100644 --- a/src/store/app.ts +++ b/src/store/app.ts @@ -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, diff --git a/src/store/profile.ts b/src/store/profile.ts index 4e4dc84..269c0e2 100644 --- a/src/store/profile.ts +++ b/src/store/profile.ts @@ -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() + } }, })