import Cookies from 'js-cookie'

const TokenKey = 'xunjian-token'

export function getToken() {
  let s = Cookies.get(TokenKey)
  if (s == null || '' === s) {
    s = localStorage.getItem(TokenKey)
  }
  return s
}

export function setToken(token) {
  localStorage.setItem(TokenKey, token)
  return Cookies.set(TokenKey, token, { expires: 7 })
}

export function removeToken() {
  localStorage.removeItem(TokenKey)
  return Cookies.remove(TokenKey)
}
