image-src.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // 获取图片路径
  2. export function getImageSrc(className, imageName) {
  3. var protocol = window.location.protocol;
  4. // console.log('protocol:' + protocol);
  5. var host = window.location.host;
  6. // console.log('host:' + host);
  7. var localhostPath = protocol + '//' + host;
  8. var accountId = localStorage.getItem('#accountId') || 0;
  9. if (imageName == null) {
  10. return null;
  11. }
  12. if (imageName != null && imageName[0] == '/') {
  13. return localhostPath + '/Files/' + accountId + '/Images/' + className + imageName;
  14. } else {
  15. return localhostPath + '/Files/' + accountId + '/Images/' + className + '/' + imageName;
  16. }
  17. }
  18. // 获取略缩图图片路径
  19. export function getThumbnailImageSrc(className, imageName) {
  20. var protocol = window.location.protocol;
  21. // console.log('protocol:' + protocol);
  22. var host = window.location.host;
  23. // console.log('host:' + host);
  24. var localhostPath = protocol + '//' + host;
  25. //测试用
  26. //var localhostPath = 'http://127.0.0.1:83';
  27. console.log('localhostPath:' + localhostPath);
  28. var accountId = localStorage.getItem('#accountId');
  29. if (imageName == null) {
  30. return null;
  31. }
  32. if (imageName != null && imageName[0] == '/') {
  33. return localhostPath + '/Files/' + accountId + '/Images/' + className + '/thumbnail' + imageName;
  34. } else {
  35. return localhostPath + '/Files/' + accountId + '/Images/' + className + '/thumbnail/' + imageName;
  36. }
  37. }