import { STORAGE_KEYS } from '@/constants/storage-keys'

/** 保存 token */
export const setTokenData = v => {
  return uni.setStorageSync(STORAGE_KEYS.TOKEN, v)
}

/** 获取 token */
export const getToken = () => {
  return uni.getStorageSync(STORAGE_KEYS.TOKEN) || ''
}

/** 清楚 token */
export const removeToken = () => {
  return uni.removeStorageSync(STORAGE_KEYS.TOKEN)
}

/** 保存用户信息 */
export const setUserInfoData = v => {
  return uni.setStorageSync(STORAGE_KEYS.USER, JSON.stringify(v))
}

/** 获取用户信息 */
export const getUserInfoData = () => {
  return uni.getStorageSync(STORAGE_KEYS.USER) || ''
}

/** 删除用户信息 */
export const removeUserInfoData = () => {
  return uni.removeStorageSync(STORAGE_KEYS.USER)
}

/** 保存腾讯 IM */
export const setSig = v => {
  return uni.setStorageSync(
    STORAGE_KEYS.TENCENT_USER_SIG,
    JSON.stringify(v)
  )
}

/** 获取腾讯 IM */
export const getSig = () => {
  return uni.getStorageSync(STORAGE_KEYS.TENCENT_USER_SIG) || ''
}

/** 删除腾讯 IM */
export const removeSig = () => {
  return uni.removeStorageSync(STORAGE_KEYS.TENCENT_USER_SIG)
}

/** 保存字体大小 */
export const setFontSize = v => {
  return uni.setStorageSync(STORAGE_KEYS.FONT_SIZE, v)
}

/** 获取字体大小 */
export const getFontSize = () => {
  return uni.getStorageSync(STORAGE_KEYS.FONT_SIZE) || 26
}

/** 删除字体大小 */
export const removeFontSize = () => {
  return uni.removeStorageSync(STORAGE_KEYS.FONT_SIZE)
}
