import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token,exp) {
  const expdays = convertSecondsToDays(exp)
  return Cookies.set(TokenKey, token, { expires: expdays })
}

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

//把秒转换成天
function convertSecondsToDays(seconds) {
  return seconds/(60*60*24); //1天=60秒*60分钟*24小时
}
