From 973b2c0705e077d18bced06d530f1db87b4b54f9 Mon Sep 17 00:00:00 2001
From: Cxx0822 <1556464090@qq.com>
Date: Tue, 1 Sep 2026 16:19:47 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=A1=80=E7=B3=96?=
=?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=9B=BE=E7=B1=BB=E5=88=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/pages/stats/index.vue | 241 ++++++++++++++++++++------------------
src/utils/record.ts | 20 +++-
2 files changed, 145 insertions(+), 116 deletions(-)
diff --git a/src/pages/stats/index.vue b/src/pages/stats/index.vue
index 9217785..43bb6b9 100644
--- a/src/pages/stats/index.vue
+++ b/src/pages/stats/index.vue
@@ -1,115 +1,122 @@
-
-
-
-
- 最近7次趋势
-
+
+
+
+
+
+ 最近7次趋势
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/src/utils/record.ts b/src/utils/record.ts
index 170dd4b..46d9b99 100644
--- a/src/utils/record.ts
+++ b/src/utils/record.ts
@@ -84,7 +84,13 @@ function addRecord(type: string, data: Record, timestamp: number) {
* @param limit
*/
function appendRecentRecord(type: string, record: any, limit = 7) {
- const key = `recent_${type}`
+ let key = ''
+ if (type === 'bloodSugar') {
+ key = `recent_${type}_${record.period}`
+ } else {
+ key = `recent_${type}`
+ }
+
const recent = wx.getStorageSync(key) || []
// 正序:timestamp 小的在前
@@ -105,10 +111,16 @@ function appendRecentRecord(type: string, record: any, limit = 7) {
/**
* 删除最近记录的数据
* @param type 类型
+ * @param record 记录
* @param id id
*/
-function removeFromRecentIndex(type: string, id: string) {
- const key = `recent_${type}`
+function removeFromRecentIndex(type: string, record: any, id: string) {
+ let key = ''
+ if (type === 'bloodSugar') {
+ key = `recent_${type}_${record.period}`
+ } else {
+ key = `recent_${type}`
+ }
const recent = wx.getStorageSync(key) || []
const idx = recent.findIndex((item: any) => item.id === id)
@@ -159,7 +171,7 @@ export function deleteRecordByDate(date: string, id: string) {
wx.setStorageSync(key, all)
}
- removeFromRecentIndex(type, id)
+ removeFromRecentIndex(type, record, id)
}
/**