quanyawei
2023-10-27 52d463e03c1f074099ed8e8a6b7c3ddde52d2708
utils/storage.js
@@ -1,30 +1,24 @@
export default {
  set(name, value) {
    uni.setStorageSync(name, value);
        uni.setStorageSync(name, value)
  },
  setJson(name, value) {
    uni.setStorageSync(name, JSON.stringify(value));
        uni.setStorageSync(name, JSON.stringify(value))
  },
  get(name) {
    return uni.getStorageSync(name);
        return uni.getStorageSync(name)
  },
  getJson(name) {
    const content = uni.getStorageSync(name);
        const content = uni.getStorageSync(name)
    if (!content) {
      return null;
            return null
    }
    return JSON.parse(content);
        return JSON.parse(content)
  },
  remove(name) {
    uni.removeStorageSync(name);
        uni.removeStorageSync(name)
  },
  clear() {
    uni.clearStorageSync();
        uni.clearStorageSync()
  },
};
}