Files
health-mp/src/store/profile.ts
2026-09-05 16:19:56 +08:00

62 lines
1.6 KiB
TypeScript

import { defineStore } from 'pinia'
import type { IDefaultRecordValue, IProfile, IUser } from "@/type/profile";
import type { IStats } from "@/type";
import { countRecordsByMonth, getMaxRecord, getTotalCount } from "@/utils/record";
export const useProfileStore = defineStore('profile', {
state: () => ({
showProfilePopup: false,
showStoragePopup: false,
showOverviewPopup: false,
showPlanPopup: false,
showStatsPopup: false,
showDefaultRecordValuePopup: false,
showPointPopup: false,
showThemePopup: false,
showAboutPopup: false,
profileForm: {
id: '',
gender: '',
height: 170,
birthYear: 1990,
occupation: '',
condition: [],
goal: '',
name: '',
} as IProfile,
user: {
id: '',
level: '普通用户',
expiry_date: '无'
} as IUser,
themeColor: 'purple',
defaultRecordValueForm: {
weightValue: 70,
sportDuration: 30,
bloodPressureSystolic: 120,
bloodPressureDiastolic: 70,
bloodPressureHeartRate: 80,
bloodSugarValue: 5.4,
temperatureValue: 36.5,
} as IDefaultRecordValue,
currentStorageSize: 0,
storageStats: [] as IStats[],
storageTotal: 0,
storageMax: 1000,
overviewList: [] as string[],
planList: [] as string[],
statsList: [] as string[],
defaultList: [],
isRefresh: false,
}),
actions: {
refreshStorage() {
const storageInfo = wx.getStorageInfoSync()
this.currentStorageSize = storageInfo.currentSize
this.storageStats = countRecordsByMonth()
this.storageTotal = getTotalCount()
this.storageMax = getMaxRecord()
}
},
})