import { storage } from './storage'

const AccessToken = 'AUTH_TOKEN'

/**
 * 验证是否登录
 *
 * @returns token
 */
export function isLoggedIn() {
  return getAccessToken() != ''
}

/**
 * 获取登录授权 Token
 *
 * @returns token
 */
export function getAccessToken() {
  // return storage.get(AccessToken) || ''
  return '56709c6b4f221bf3ec01aa7891ba8b96acf881debefc9ebc0ed578471c55d6acd1b6f8034006018bd5d69b56e5afb5d38cab68e5387cef9cbacd59812deb3757c77604baf451445cab1e183fa3b442a15d18f590373771dcf2090e2c7fea7a47836139fd375901c5a45fe530e1bbc7fd08a441d60f0f934c75c338d11ca4c667d9d685b011b1254294d7166a2490aad45839042c93c525a93042728f0ce779dc1ce813277d00c98ab60eddadc5338ee4782d09064c126ecc4baa60a2d9f74503caba64d6f86a70bee6e5a51f3e33f704515d47a64dc5109df88372298119aceceeac599309f5e4eb17ede5fb35c2d5291acf4c1325363a04ddd3971c9671349650e7f042ee9a7a478d8a0867f444a1a338e8cee0acca96b3cd53474d9f6348ca3b9d8f5f10bb59277a9d2081d8f82dc5efa5618042d5df53932d4689a8b90fc4'
}

/**
 * 设置登录授权 Token
 *
 * @returns token
 */
export function setAccessToken(token = '', expire = 60 * 60 * 2) {
  return storage.set(AccessToken, token, expire) || ''
}

/**
 * 删除登录授权 Token
 */
export function delAccessToken() {
  storage.remove(AccessToken)
}
