import { Base64 } from 'js-base64';
import { STORAGE_TOKEN_KEY } from '@/store/mutation-type';
export const REQUEST_TOKEN_KEY = 'Authorization';
export function setCommonHeaders() {
  let savedToken = localStorage.getItem(STORAGE_TOKEN_KEY);
  savedToken = savedToken.substring(1); //删除第一个字符
  savedToken = savedToken.substring(0, savedToken.length - 1); //删除最后一字符
  let setHeader = {};
  if (savedToken) {
    setHeader = {
      'Access-Control-Allow-Origin': '*',
      'Content-Type': 'application/json;charset=UTF-8',
      Authorization: 'Bearer ' + savedToken,
      // Authorization: 'Basic ' + Base64.encode('saber:saber_secret'),
      'Blade-Auth': 'bearer ' + savedToken,
    };
  } else {
    setHeader = {
      'Access-control-Allow-Origin': '*',
      'Content-Type': 'application/json;charset=UTF-8',
      Authorization: 'Basic ' + Base64.encode('saber:saber_secret'),
    };
  }
  return setHeader;
}
