feat: 增加各个模块
This commit is contained in:
25
src/utils/profile.ts
Normal file
25
src/utils/profile.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
export interface IProfile {
|
||||
name: string
|
||||
gender: 'male' | 'female' | ''
|
||||
height: number | null
|
||||
weight: number | null
|
||||
}
|
||||
|
||||
const PROFILE_KEY = 'user_profile'
|
||||
|
||||
function getEmptyProfile(): IProfile {
|
||||
return {
|
||||
gender: '',
|
||||
height: null,
|
||||
name: '',
|
||||
weight: null,
|
||||
}
|
||||
}
|
||||
|
||||
export function getProfile(): IProfile {
|
||||
return wx.getStorageSync(PROFILE_KEY) || getEmptyProfile()
|
||||
}
|
||||
|
||||
export function saveProfile(data: IProfile) {
|
||||
wx.setStorageSync(PROFILE_KEY, data)
|
||||
}
|
||||
Reference in New Issue
Block a user