acdr-ui/dist/build/mp-weixin/sheep/components/s-uploader/utils.js

2 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";const e=require("../../../common/vendor.js"),t=e=>{const t=e.lastIndexOf("."),i=e.length;return{name:e.substring(0,t),ext:e.substring(t+1,i)}};exports.get_extname=e=>{if(Array.isArray(e))return e;return e.replace(/(\[|\])/g,"").split(",")},exports.get_file_data=(i,n="image")=>{return a=exports,s=null,r=function*(){const a=t(i.name).ext.toLowerCase(),s={name:i.name,uuid:i.uuid,extname:a||"",cloudPath:i.cloudPath,fileType:i.fileType,url:i.path||i.path,size:i.size,image:{},path:i.path,video:{}};if("image"===n){const t=yield(r=i.path,new Promise(((t,i)=>{e.index.getImageInfo({src:r,success(e){t(e)},fail(e){i(e)}})})));delete s.video,s.image.width=t.width,s.image.height=t.height,s.image.location=t.path}else delete s.image;var r;return s},new Promise(((e,t)=>{var i=e=>{try{l(r.next(e))}catch(i){t(i)}},n=e=>{try{l(r.throw(e))}catch(i){t(i)}},l=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,n);l((r=r.apply(a,s)).next())}));var a,s,r},exports.get_files_and_is_max=(i,n)=>{const a=[],s=[];return n&&0!==n.length?(i.tempFiles.forEach((e=>{const i=t(e.name).ext.toLowerCase();-1!==n.indexOf(i)&&(s.push(e),a.push(e.path))})),s.length!==i.tempFiles.length&&e.index.showToast({title:`当前选择了${i.tempFiles.length}个文件 ${i.tempFiles.length-s.length} 个文件格式不正确`,icon:"none",duration:5e3}),{filePaths:a,files:s}):{filePaths:a,files:s}};