utils.js 658 B

123456789101112131415161718192021222324
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var IMAGE_EXT = ['jpeg', 'jpg', 'gif', 'png', 'svg'];
  4. function isImageUrl(url) {
  5. return IMAGE_EXT.some(function (ext) { return url.indexOf("." + ext) !== -1; });
  6. }
  7. exports.isImageUrl = isImageUrl;
  8. function isImageFile(item) {
  9. if (item.type) {
  10. return item.type.indexOf('image') === 0;
  11. }
  12. if (item.path) {
  13. return isImageUrl(item.path);
  14. }
  15. if (item.url) {
  16. return isImageUrl(item.url);
  17. }
  18. return false;
  19. }
  20. exports.isImageFile = isImageFile;
  21. function isVideo(res, accept) {
  22. return accept === 'video';
  23. }
  24. exports.isVideo = isVideo;