feat: 增加记录类型弹窗
This commit is contained in:
79
src/store/record.ts
Normal file
79
src/store/record.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useRecordStore = defineStore('record', {
|
||||
state: () => ({
|
||||
list: [] as any[],
|
||||
loading: false,
|
||||
showFab: true,
|
||||
showRecordPopup: false,
|
||||
showWeightPopup: false,
|
||||
weightForm: {
|
||||
value: 1,
|
||||
note: '',
|
||||
time: '' as number | string,
|
||||
},
|
||||
showSleepPopup: false,
|
||||
sleepForm: {
|
||||
startTime: '' as number | string,
|
||||
endTime: '' as number | string,
|
||||
note: '',
|
||||
time: '' as number | string,
|
||||
},
|
||||
showSportPopup: false,
|
||||
sportForm: {
|
||||
type: '',
|
||||
duration: 0,
|
||||
note: '',
|
||||
time: '' as number | string,
|
||||
},
|
||||
showBpPopup: false,
|
||||
bpForm: {
|
||||
systolic: 0,
|
||||
diastolic: 0,
|
||||
heartRate: 0,
|
||||
time: Date.now(),
|
||||
note: '',
|
||||
},
|
||||
showGlucosePopup: false,
|
||||
glucoseForm: {
|
||||
value: 0,
|
||||
period: '' as string,
|
||||
time: Date.now(),
|
||||
note: '',
|
||||
},
|
||||
showTempPopup: false,
|
||||
tempForm: {
|
||||
value: 36.5,
|
||||
location: '' as string,
|
||||
time: Date.now(),
|
||||
note: '',
|
||||
},
|
||||
}),
|
||||
actions: {
|
||||
setLoading(val: boolean) {
|
||||
this.loading = val
|
||||
},
|
||||
|
||||
async fetchList() {
|
||||
this.loading = true
|
||||
try {
|
||||
const res = await fetch('/api/record/list')
|
||||
this.list = await res.json()
|
||||
}
|
||||
finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
addRecord(item: any) {
|
||||
this.list.push(item)
|
||||
},
|
||||
|
||||
removeRecord(id: string) {
|
||||
this.list = this.list.filter(item => item.id !== id)
|
||||
},
|
||||
reset() {
|
||||
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user