export const storage = {
  set(key, value) {
    if (typeof value === 'object') {
      value = JSON.stringify(value)
    }
    uni.setStorageSync(key, value)
  },

  get(key) {
    const value = uni.getStorageSync(key)
    try {
      return JSON.parse(value)
    } catch (e) {
      return value
    }
  },

  remove(key) {
    uni.removeStorageSync(key)
  },

  clear() {
    uni.clearStorageSync()
  }
}
