/**
 * 本地缓存（与 xuexiaole-web 一致的 key 规则，已去掉原生壳 API）
 */
const prefixKey = (key: string) => `X_${key.toUpperCase()}`

export const setCache = (key: string, value: string) => {
  if (!key) return
  localStorage.setItem(prefixKey(key), value)
}

export const getCache = (key: string): string => {
  if (!key) return ''
  return localStorage.getItem(prefixKey(key)) || ''
}

export const delCache = (key: string) => {
  if (!key) return
  localStorage.removeItem(prefixKey(key))
}
