mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-06-11 12:49:30 +08:00
feat: 新增投票功能
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user