storage

storage:get,set,remove,clear

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/503785/1428734/storage.js

  1. const storage = {
  2. //封装操作localstorage本地存储的方法
  3. //存储
  4. set(key, value) {
  5. localStorage.setItem(key, JSON.stringify(value))
  6. },
  7. //取出数据
  8. get(key) {
  9. const value = localStorage.getItem(key)
  10. if(value == null || value == '""' || value == undefined) {
  11. return null
  12. } else {
  13. return JSON.parse(value)
  14. }
  15. },
  16. // 删除数据
  17. remove(key) {
  18. localStorage.removeItem(key)
  19. },
  20. //清除所有存储
  21. clear() {
  22. localStorage.clear()
  23. },
  24. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址