From 338ba726a07dbf53fad9c9881748ed675fe07eaf Mon Sep 17 00:00:00 2001 From: Cxx0822 <1556464090@qq.com> Date: Fri, 28 Aug 2026 15:33:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/stats/index.vue | 164 +++++++++++++++++++++++--------------- src/pages/user/index.vue | 4 + src/store/app.ts | 1 + 3 files changed, 105 insertions(+), 64 deletions(-) diff --git a/src/pages/stats/index.vue b/src/pages/stats/index.vue index 1c4fa64..18da75c 100644 --- a/src/pages/stats/index.vue +++ b/src/pages/stats/index.vue @@ -82,22 +82,28 @@ import { getRecentRecords } from '@/utils/record' import { onShow } from "@dcloudio/uni-app"; const weightChartData = ref({ - categories: [] + categories: [] as string[], + series: [] as any[] }) const sleepChartData = ref({ - categories: [] + categories: [] as string[], + series: [] as any[] }) const sportChartData = ref({ - categories: [] + categories: [] as string[], + series: [] as any[] }) const bloodPressureChartData = ref({ - categories: [] + categories: [] as string[], + series: [] as any[] }) const bloodSugarChartData = ref({ - categories: [] + categories: [] as string[], + series: [] as any[] }) const temperatureChartData = ref({ - categories: [] + categories: [] as string[], + series: [] as any[] }) // 图表配置 @@ -115,101 +121,131 @@ const chartOpts = { function getWeightChartData() { const list = getRecentRecords('weight', 7) - if (!list.length) return { categories: [], series: [] } - const categories = list.map((_, index) => String(index + 1)) + if (list.length) { + const categories = list.map((_, index) => String(index + 1)) - weightChartData.value = { - categories, - series: [ - { - name: '体重(Kg)', - data: list.map((r) => r.value), - }, - ], + weightChartData.value = { + categories, + series: [ + { + name: '体重(Kg)', + data: list.map((r) => r.value), + }, + ], + } + } else { + weightChartData.value = { + categories: [], series: [] + } } } function getSleepChartData() { const list = getRecentRecords('sleep', 7) - if (!list.length) return { categories: [], series: [] } - const categories = list.map((_, index) => String(index + 1)) + if (list.length) { + const categories = list.map((_, index) => String(index + 1)) - sleepChartData.value = { - categories, - series: [ - { - name: '睡眠(小时)', - data: list.map((r) => r.duration), - }, - ], + sleepChartData.value = { + categories, + series: [ + { + name: '睡眠(小时)', + data: list.map((r) => r.duration), + }, + ], + } + } else { + sleepChartData.value = { + categories: [], series: [] + } } } function getSportChartData() { const list = getRecentRecords('sport', 7) - if (!list.length) return { categories: [], series: [] } - const categories = list.map((_, index) => String(index + 1)) + if (list.length) { + const categories = list.map((_, index) => String(index + 1)) - sportChartData.value = { - categories, - series: [ - { - name: '运动(分钟)', - data: list.map((r) => r.duration), - }, - ], + sportChartData.value = { + categories, + series: [ + { + name: '运动(分钟)', + data: list.map((r) => r.duration), + }, + ], + } + } else { + sportChartData.value = { + categories: [], series: [] + } } } function getBloodPressureChartData() { const list = getRecentRecords('bloodPressure', 7) - if (!list.length) return { categories: [], series: [] } - const categories = list.map((_, index) => String(index + 1)) + if (list.length) { + const categories = list.map((_, index) => String(index + 1)) - bloodPressureChartData.value = { - categories, - series: [ - { name: '收缩压(mmHg)', data: list.map((r) => r.systolic) }, - { name: '舒张压(mmHg)', data: list.map((r) => r.diastolic) }, - ], + bloodPressureChartData.value = { + categories, + series: [ + { name: '收缩压(mmHg)', data: list.map((r) => r.systolic) }, + { name: '舒张压(mmHg)', data: list.map((r) => r.diastolic) }, + ], + } + } else { + bloodPressureChartData.value = { + categories: [], series: [] + } } } function getBloodSugarChartData() { const list = getRecentRecords('bloodSugar', 7) - if (!list.length) return { categories: [], series: [] } - const categories = list.map((_, index) => String(index + 1)) + if (list.length) { + const categories = list.map((_, index) => String(index + 1)) - bloodSugarChartData.value = { - categories, - series: [ - { - name: '血糖(mmol/L)', - data: list.map((r) => r.value), - }, - ], + bloodSugarChartData.value = { + categories, + series: [ + { + name: '血糖(mmol/L)', + data: list.map((r) => r.value), + }, + ], + } + } else { + bloodSugarChartData.value = { + categories: [], series: [] + } } } function getTemperatureChartData() { const list = getRecentRecords('temperature', 7) - if (!list.length) return { categories: [], series: [] } - const categories = list.map((_, index) => String(index + 1)) + if (list.length) { + const categories = list.map((_, index) => String(index + 1)) - temperatureChartData.value = { - categories, - series: [ - { - name: '体温(℃)', - data: list.map((r) => r.value), - }, - ], + temperatureChartData.value = { + categories, + series: [ + { + name: '体温(℃)', + data: list.map((r) => r.value), + }, + ], + } + } else { + temperatureChartData.value = { + categories: [], series: [] + } } } diff --git a/src/pages/user/index.vue b/src/pages/user/index.vue index 8c5071c..4530f2a 100644 --- a/src/pages/user/index.vue +++ b/src/pages/user/index.vue @@ -26,6 +26,8 @@ + + @@ -44,10 +46,12 @@ import PlanPopup from "@/components/Profile/PlanPopup.vue"; import { computed, ref, watch } from 'vue' import { getOverview, getPlan, getProfile } from '@/utils/profile' import { useProfileStore } from '@/store/profile' +import { useAppStore } from "@/store/app"; import type { IProfile } from "@/type/profile"; import { countRecordsByMonth, getTotalCount } from "@/utils/record"; const profileStore = useProfileStore() +const appStore = useAppStore() const profile = ref(getProfile()) diff --git a/src/store/app.ts b/src/store/app.ts index c7f065c..75dc013 100644 --- a/src/store/app.ts +++ b/src/store/app.ts @@ -2,6 +2,7 @@ import { defineStore } from 'pinia' export const useAppStore = defineStore('app', { state: () => ({ + version: '1.0.1', viewRecordType: 'calendar', }), actions: {