// 同步取
function getItem(key: string) {
  try {
    const value = uni.getStorageSync(key);
    if (value) {
      return value;
    }
    return null;
  } catch (e) {
    // error
    return null;
  }
}
// 同步存
function setItem(key: string, data: string | boolean | number | Object) {
  uni.setStorageSync(key, data);
}
// 同步销毁
function removeItem(key: string) {
  try {
    uni.removeStorageSync(key);
  } catch (e) {
    console.log('移除数据出错', e);
  }
}
// 同步清理所有
function removeAll() {
  try {
    uni.clearStorageSync();
  } catch (e) {
    console.log('移除数据出错', e);
  }
}

export const useUniStore = () => {
  return {
    getItem,
    setItem,
    removeItem,
    removeAll
  }
}