import Common from './Common';

// 获取图片路径
export function getImageSrc(className, imageName) {
  // var protocol = window.location.protocol;
  // console.log('protocol:' + protocol);
  // var host = window.location.host;
  // console.log('host:' + host);
  var localhostPath = Common.getHostPageBaseURL() + '/';
  var accountId = localStorage.getItem('#accountId') || 0;
  if (imageName == null) {
    return null;
  }
  if (imageName != null && imageName[0] == '/') {
    return localhostPath + 'Files/' + accountId + '/Images/' + className + imageName;
  } else {
    return localhostPath + 'Files/' + accountId + '/Images/' + className + '/' + imageName;
  }
}
  
  
// 获取略缩图图片路径
export function getThumbnailImageSrc(className, imageName) {
  // var protocol = window.location.protocol;
  // console.log('protocol:' + protocol);
  // var host = window.location.host;
  // console.log('host:' + host);
  // var localhostPath = protocol + '//' + host;
  var localhostPath = Common.getHostPageBaseURL() + '/';
  //测试用
  //var localhostPath = 'http://127.0.0.1:83';
  console.log('localhostPath:' + localhostPath);
  var accountId = localStorage.getItem('#accountId');
  if (imageName == null) {
    return null;
  }
  if (imageName != null && imageName[0] == '/') {
    return localhostPath + 'Files/' + accountId + '/Images/' + className + '/thumbnail' + imageName;
  } else {
    return localhostPath + 'Files/' + accountId + '/Images/' + className + '/thumbnail/' + imageName;
  }
}

export function getThumbnailSrc (className, imageName) {
  if (imageName == null) {
    return null;
  }
  const localhostPath = Common.getHostPageBaseURL() + '/';;
  return localhostPath + 'api/file/thumbnailImageDownload?className=' + className + '&fileName=' + imageName;
}