upvote.js 418 B

12345678910111213141516171819
  1. export const upvote = {
  2. get(key) {
  3. const data = uni.getStorageSync(`upvote.${key}.halo.run`)
  4. if (data) {
  5. return JSON.parse(data)
  6. } else {
  7. return []
  8. }
  9. },
  10. has(key, name) {
  11. const list = this.get(key)
  12. if (list.length == 0) return false;
  13. return list.includes(name)
  14. },
  15. set(key, name) {
  16. const list = this.get(key)
  17. uni.setStorageSync(`upvote.${key}.halo.run`, JSON.stringify([...list, name]))
  18. }
  19. }