1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-06-10 20:29:28 +08:00
Files
uni-halo/utils/vote.js
T
2025-08-20 21:56:34 +08:00

34 lines
602 B
JavaScript

const UnihaloVoteUid = "unihalo_vote_uid"
export const voteCacheUtil = {
getAll() {
const data = uni.getStorageSync(UnihaloVoteUid)
if (!data) {
return null
}
return JSON.parse(data)
},
get(name) {
const data = this.getAll()
if (!data) {
return null
}
return data[name]
},
has(name) {
const data = this.getAll()
if (!data) return false
return data[name] != undefined
},
set(name, value) {
let data = this.getAll()
if (!data) {
data = {
[name]: value
}
} else {
data[name] = value
}
uni.setStorageSync(UnihaloVoteUid, JSON.stringify(data))
}
}