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 JSON.parse(localStorage.getItem('token'))||'6e0b0a00c35d0e1613d8f9ce2303067e46a0c2d9941c959848ccf7c91e7eb0fe14690f485ae6b5e932196267c2af8a6089bda35a715c44ad565de15114eb2c825ccda8f2ae965c417326c65d9a41a1f50848ca6ba9e3c64d8e2f653b280e5b33c7358af0d091c4dd8dfc8426eff3300f1191f37cf03928198a8def6a5bf0bfd353f9677a02848af9af6c5354e3d72bf355a8436fc374811396707367abfaaeab5c25146c96c4774170d8fe7d5e23a9828b6c15892025d7104d95f43c8dfc57a4739f47e24c5ab53344c2669af1a46d2555ad6f8c1d1c8ebe4bb426df65e8ee0be9a8566309c2b2ed72df60d5740da55ef2fe18e31f2fb35d71f62033bdeb3bf85e8913d0fe46afb87c5396e7e0f2a816fd87afc1ae6b36a4efbdaef76b3299c00f6f175eaa1be83fbce4812e9b83fc06ac3639c7eeda5cc62d126ddef6ab200a'
}

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

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