// 获取图片反显url
export function getImageUrl(path) {
  return `${sessionStorage.filePath}${path}`;
  // if (process.env.NODE_ENV === 'development') {
  //   return `http://192.168.3.51:18086/main/file/getFile?${TOKEN_HEADER_NAME}=${getToken()}&objectName=${path}`;
  // } else {
  //   return `${
  //     sessionStorage.filePath
  //   }${path}`;
  // }
}
// 从反显url上获取接口需要path
export function getImagePath(url) {
  if (!url) {
    return '';
  }

  const match = url.match(/&objectName=([\S\s]*)/);

  return (match && match[1].split('&')[0]) || '';
}

// 下载方法

export function download(data, name) {
  const a = document.createElement('a');
  const url = window.URL.createObjectURL(data);
  const filename = name;
  a.href = url;
  a.download = filename;
  a.click();
  window.URL.revokeObjectURL(url);
}
