import Cookies from 'js-cookie';
import { TOKEN_COOKIE } from '@/constants/token-constants';
import { localRemove, localSet } from '@/utils/cache-local-utils';
import { CACHE_LOCAL_LOCK } from '@/constants/cache-keys-constants';

/**获取cookis中Token字符串 */
export function getToken(): string {
  return Cookies.get(TOKEN_COOKIE) || '';
}

/**设置cookis中Token字符串 */
export function setToken(token: string): void {
  Cookies.set(TOKEN_COOKIE, token);
  localSet(CACHE_LOCAL_LOCK, 'none');
}

/**移除cookis中Token字符串,localStorage中锁屏字符串 */
export function removeToken(): void {
  Cookies.remove(TOKEN_COOKIE);
  localRemove(CACHE_LOCAL_LOCK);
}
