/**
 * 登陆后存储临时登录信息
 * */
const TokenKey = 'Admin-Token'

const ExpiresInKey = 'Admin-Expires-In'

//本地缓存
export function setLocal(key,value) {
  if(typeof (key) != 'string') return;
  localStorage.setItem(key,JSON.stringify(value))
}
export function getLocal(key) {
  if(typeof (key) != 'string') return;
  return JSON.parse(localStorage.getItem(key));
}
export function removeLocal(key) {
  if(typeof (key) != 'string') return;
  localStorage.removeItem(key)
}

//临时缓存
export function setSession(key,value) {
  if(typeof (key) != 'string') return;
  sessionStorage.setItem(key,JSON.stringify(value))
}
export function getSession(key) {
  if(typeof (key) != 'string') return;
  return JSON.parse(sessionStorage.getItem(key));
}
export function removeSession(key) {
  if(typeof (key) != 'string') return;
  sessionStorage.removeItem(key)
}


//设置token
export function getToken() {
  return sessionStorage.getItem(TokenKey)
}

export function setToken(token) {
  return sessionStorage.setItem(TokenKey, token)
}

export function removeToken() {
  return sessionStorage.removeItem(TokenKey)
}

export function getExpiresIn() {
  return sessionStorage.getItem(ExpiresInKey) || -1
}

export function setExpiresIn(time) {
  return sessionStorage.setItem(ExpiresInKey, time)
}
export function removeExpiresIn() {
  return sessionStorage.removeItem(ExpiresInKey)
}

