12345 |
- <<<<<<<< HEAD:dist/assets/index.329d98a9.js
- import{t as q,a2 as L,M as K,d as D,z as Q,av as W,c as i,a5 as F,L as X,bx as V,a1 as $,aN as H,N as x,w as U,u as P,v as I,aw as J,R as Y,ab as Z,W as ee,b1 as ae,ac as te,aQ as le,K as ne,al as k,E as ie,r as re,D as oe}from"./index.ffe80dbe.js";import"./index.9bed9ddc.js";import{I as se}from"./index.7e972106.js";import{s as ce}from"./function-call.4b573eb9.js";const[ue,r,de]=q("uploader");function A(e,t){return new Promise(o=>{if(t==="file"){o();return}const c=new FileReader;c.onload=v=>{o(v.target.result)},t==="dataUrl"?c.readAsDataURL(e):t==="text"&&c.readAsText(e)})}function O(e,t){return L(e).some(o=>o.file?K(t)?t(o.file):o.file.size>t:!1)}function fe(e,t){const o=[],c=[];return e.forEach(v=>{O(v,t)?c.push(v):o.push(v)}),{valid:o,invalid:c}}const ve=/\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i,me=e=>ve.test(e);function N(e){return e.isImage?!0:e.file&&e.file.type?e.file.type.indexOf("image")===0:e.url?me(e.url):typeof e.content=="string"?e.content.indexOf("data:image")===0:!1}var ge=D({props:{name:Q,item:W(Object),index:Number,imageFit:String,lazyLoad:Boolean,deletable:Boolean,previewSize:[Number,String,Array],beforeDelete:Function},emits:["delete","preview"],setup(e,{emit:t,slots:o}){const c=()=>{const{status:l,message:u}=e.item;if(l==="uploading"||l==="failed"){const w=l==="failed"?i(F,{name:"close",class:r("mask-icon")},null):i(X,{class:r("loading")},null),f=$(u)&&u!=="";return i("div",{class:r("mask")},[w,f&&i("div",{class:r("mask-message")},[u])])}},v=l=>{const{name:u,item:w,index:f,beforeDelete:z}=e;l.stopPropagation(),H(z,{args:[w,{name:u,index:f}],done:()=>t("delete")})},m=()=>t("preview"),b=()=>{if(e.deletable&&e.item.status!=="uploading"){const l=o["preview-delete"];return i("div",{role:"button",class:r("preview-delete",{shadow:!l}),tabindex:0,"aria-label":de("delete"),onClick:v},[l?l():i(F,{name:"cross",class:r("preview-delete-icon")},null)])}},h=()=>{if(o["preview-cover"]){const{index:l,item:u}=e;return i("div",{class:r("preview-cover")},[o["preview-cover"](x({index:l},u))])}},y=()=>{const{item:l,lazyLoad:u,imageFit:w,previewSize:f}=e;return N(l)?i(se,{fit:w,src:l.content||l.url,class:r("preview-image"),width:Array.isArray(f)?f[0]:f,height:Array.isArray(f)?f[1]:f,lazyLoad:u,onClick:m},{default:h}):i("div",{class:r("file"),style:V(e.previewSize)},[i(F,{class:r("file-icon"),name:"description"},null),i("div",{class:[r("file-name"),"van-ellipsis"]},[l.file?l.file.name:l.url]),h()])};return()=>i("div",{class:r("preview")},[y(),c(),b()])}});const we={name:U(""),accept:P("image/*"),capture:String,multiple:Boolean,disabled:Boolean,readonly:Boolean,lazyLoad:Boolean,maxCount:U(1/0),imageFit:P("cover"),resultType:P("dataUrl"),uploadIcon:P("photograph"),uploadText:String,deletable:I,afterRead:Function,showUpload:I,modelValue:J(),beforeRead:Function,beforeDelete:Function,previewSize:[Number,String,Array],previewImage:I,previewOptions:Object,previewFullImage:I,maxSize:{type:[Number,String,Function],default:1/0}};var pe=D({name:ue,props:we,emits:["delete","oversize","clickUpload","closePreview","clickPreview","update:modelValue"],setup(e,{emit:t,slots:o}){const c=Y(),v=[],m=(a=e.modelValue.length)=>({name:e.name,index:a}),b=()=>{c.value&&(c.value.value="")},h=a=>{if(b(),O(a,e.maxSize))if(Array.isArray(a)){const n=fe(a,e.maxSize);if(a=n.valid,t("oversize",n.invalid,m()),!a.length)return}else{t("oversize",a,m());return}a=re(a),t("update:modelValue",[...e.modelValue,...L(a)]),e.afterRead&&e.afterRead(a,m())},y=a=>{const{maxCount:n,modelValue:d,resultType:s}=e;if(Array.isArray(a)){const g=+n-d.length;a.length>g&&(a=a.slice(0,g)),Promise.all(a.map(p=>A(p,s))).then(p=>{const _=a.map((G,R)=>{const S={file:G,status:"",message:""};return p[R]&&(S.content=p[R]),S});h(_)})}else A(a,s).then(g=>{const p={file:a,status:"",message:""};g&&(p.content=g),h(p)})},l=a=>{const{files:n}=a.target;if(e.disabled||!n||!n.length)return;const d=n.length===1?n[0]:[].slice.call(n);if(e.beforeRead){const s=e.beforeRead(d,m());if(!s){b();return}if(ne(s)){s.then(g=>{y(g||d)}).catch(b);return}}y(d)};let u;const w=()=>t("closePreview"),f=a=>{if(e.previewFullImage){const n=e.modelValue.filter(N),d=n.map(s=>(s.file&&!s.url&&s.status!=="failed"&&(s.url=URL.createObjectURL(s.file),v.push(s.url)),s.url)).filter(Boolean);u=ce(x({images:d,startPosition:n.indexOf(a),onClose:w},e.previewOptions))}},z=()=>{u&&u.close()},B=(a,n)=>{const d=e.modelValue.slice(0);d.splice(n,1),t("update:modelValue",d),t("delete",a,m(n))},j=(a,n)=>{const d=["imageFit","deletable","previewSize","beforeDelete"],s=x(k(e,d),k(a,d,!0));return i(ge,ie({item:a,index:n,onClick:()=>t("clickPreview",a,m(n)),onDelete:()=>B(a,n),onPreview:()=>f(a)},k(e,["name","lazyLoad"]),s),k(o,["preview-cover","preview-delete"]))},E=()=>{if(e.previewImage)return e.modelValue.map(j)},C=a=>t("clickUpload",a),M=()=>{if(e.modelValue.length>=e.maxCount)return;const a=e.readonly?null:i("input",{ref:c,type:"file",class:r("input"),accept:e.accept,capture:e.capture,multiple:e.multiple,disabled:e.disabled,onChange:l},null);return o.default?i("div",{class:r("input-wrapper"),onClick:C},[o.default(),a]):te(i("div",{class:r("upload",{readonly:e.readonly}),style:V(e.previewSize),onClick:C},[i(F,{name:e.uploadIcon,class:r("upload-icon")},null),e.uploadText&&i("span",{class:r("upload-text")},[e.uploadText]),a]),[[le,e.showUpload]])},T=()=>{c.value&&!e.disabled&&c.value.click()};return Z(()=>{v.forEach(a=>URL.revokeObjectURL(a))}),ee({chooseFile:T,closeImagePreview:z}),ae(()=>e.modelValue),()=>i("div",{class:r()},[i("div",{class:r("wrapper",{disabled:e.disabled})},[E(),M()])])}});const Ie=oe(pe);export{Ie as U};
- ========
- import{t as q,a2 as L,M as K,d as D,z as W,aB as X,c as i,a5 as F,L as $,bB as V,a1 as H,aR as J,N as C,w as U,u as P,v as I,av as Q,R as Y,ab as Z,W as ee,b4 as ae,ac as te,ay as le,K as ne,am as k,E as ie,r as re,D as oe}from"./index.1c621181.js";import"./index.de594f37.js";import{I as se}from"./index.4c221cbe.js";import{s as ce}from"./function-call.db8bb852.js";const[ue,r,de]=q("uploader");function A(e,t){return new Promise(o=>{if(t==="file"){o();return}const c=new FileReader;c.onload=v=>{o(v.target.result)},t==="dataUrl"?c.readAsDataURL(e):t==="text"&&c.readAsText(e)})}function B(e,t){return L(e).some(o=>o.file?K(t)?t(o.file):o.file.size>t:!1)}function fe(e,t){const o=[],c=[];return e.forEach(v=>{B(v,t)?c.push(v):o.push(v)}),{valid:o,invalid:c}}const ve=/\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i,me=e=>ve.test(e);function O(e){return e.isImage?!0:e.file&&e.file.type?e.file.type.indexOf("image")===0:e.url?me(e.url):typeof e.content=="string"?e.content.indexOf("data:image")===0:!1}var ge=D({props:{name:W,item:X(Object),index:Number,imageFit:String,lazyLoad:Boolean,deletable:Boolean,previewSize:[Number,String,Array],beforeDelete:Function},emits:["delete","preview"],setup(e,{emit:t,slots:o}){const c=()=>{const{status:l,message:u}=e.item;if(l==="uploading"||l==="failed"){const w=l==="failed"?i(F,{name:"close",class:r("mask-icon")},null):i($,{class:r("loading")},null),f=H(u)&&u!=="";return i("div",{class:r("mask")},[w,f&&i("div",{class:r("mask-message")},[u])])}},v=l=>{const{name:u,item:w,index:f,beforeDelete:z}=e;l.stopPropagation(),J(z,{args:[w,{name:u,index:f}],done:()=>t("delete")})},m=()=>t("preview"),b=()=>{if(e.deletable&&e.item.status!=="uploading"){const l=o["preview-delete"];return i("div",{role:"button",class:r("preview-delete",{shadow:!l}),tabindex:0,"aria-label":de("delete"),onClick:v},[l?l():i(F,{name:"cross",class:r("preview-delete-icon")},null)])}},h=()=>{if(o["preview-cover"]){const{index:l,item:u}=e;return i("div",{class:r("preview-cover")},[o["preview-cover"](C({index:l},u))])}},y=()=>{const{item:l,lazyLoad:u,imageFit:w,previewSize:f}=e;return O(l)?i(se,{fit:w,src:l.content||l.url,class:r("preview-image"),width:Array.isArray(f)?f[0]:f,height:Array.isArray(f)?f[1]:f,lazyLoad:u,onClick:m},{default:h}):i("div",{class:r("file"),style:V(e.previewSize)},[i(F,{class:r("file-icon"),name:"description"},null),i("div",{class:[r("file-name"),"van-ellipsis"]},[l.file?l.file.name:l.url]),h()])};return()=>i("div",{class:r("preview")},[y(),c(),b()])}});const we={name:U(""),accept:P("image/*"),capture:String,multiple:Boolean,disabled:Boolean,readonly:Boolean,lazyLoad:Boolean,maxCount:U(1/0),imageFit:P("cover"),resultType:P("dataUrl"),uploadIcon:P("photograph"),uploadText:String,deletable:I,afterRead:Function,showUpload:I,modelValue:Q(),beforeRead:Function,beforeDelete:Function,previewSize:[Number,String,Array],previewImage:I,previewOptions:Object,previewFullImage:I,maxSize:{type:[Number,String,Function],default:1/0}};var pe=D({name:ue,props:we,emits:["delete","oversize","clickUpload","closePreview","clickPreview","update:modelValue"],setup(e,{emit:t,slots:o}){const c=Y(),v=[],m=(a=e.modelValue.length)=>({name:e.name,index:a}),b=()=>{c.value&&(c.value.value="")},h=a=>{if(b(),B(a,e.maxSize))if(Array.isArray(a)){const n=fe(a,e.maxSize);if(a=n.valid,t("oversize",n.invalid,m()),!a.length)return}else{t("oversize",a,m());return}a=re(a),t("update:modelValue",[...e.modelValue,...L(a)]),e.afterRead&&e.afterRead(a,m())},y=a=>{const{maxCount:n,modelValue:d,resultType:s}=e;if(Array.isArray(a)){const g=+n-d.length;a.length>g&&(a=a.slice(0,g)),Promise.all(a.map(p=>A(p,s))).then(p=>{const _=a.map((G,x)=>{const S={file:G,status:"",message:""};return p[x]&&(S.content=p[x]),S});h(_)})}else A(a,s).then(g=>{const p={file:a,status:"",message:""};g&&(p.content=g),h(p)})},l=a=>{const{files:n}=a.target;if(e.disabled||!n||!n.length)return;const d=n.length===1?n[0]:[].slice.call(n);if(e.beforeRead){const s=e.beforeRead(d,m());if(!s){b();return}if(ne(s)){s.then(g=>{y(g||d)}).catch(b);return}}y(d)};let u;const w=()=>t("closePreview"),f=a=>{if(e.previewFullImage){const n=e.modelValue.filter(O),d=n.map(s=>(s.file&&!s.url&&s.status!=="failed"&&(s.url=URL.createObjectURL(s.file),v.push(s.url)),s.url)).filter(Boolean);u=ce(C({images:d,startPosition:n.indexOf(a),onClose:w},e.previewOptions))}},z=()=>{u&&u.close()},N=(a,n)=>{const d=e.modelValue.slice(0);d.splice(n,1),t("update:modelValue",d),t("delete",a,m(n))},j=(a,n)=>{const d=["imageFit","deletable","previewSize","beforeDelete"],s=C(k(e,d),k(a,d,!0));return i(ge,ie({item:a,index:n,onClick:()=>t("clickPreview",a,m(n)),onDelete:()=>N(a,n),onPreview:()=>f(a)},k(e,["name","lazyLoad"]),s),k(o,["preview-cover","preview-delete"]))},E=()=>{if(e.previewImage)return e.modelValue.map(j)},R=a=>t("clickUpload",a),M=()=>{if(e.modelValue.length>=e.maxCount)return;const a=e.readonly?null:i("input",{ref:c,type:"file",class:r("input"),accept:e.accept,capture:e.capture,multiple:e.multiple,disabled:e.disabled,onChange:l},null);return o.default?i("div",{class:r("input-wrapper"),onClick:R},[o.default(),a]):te(i("div",{class:r("upload",{readonly:e.readonly}),style:V(e.previewSize),onClick:R},[i(F,{name:e.uploadIcon,class:r("upload-icon")},null),e.uploadText&&i("span",{class:r("upload-text")},[e.uploadText]),a]),[[le,e.showUpload]])},T=()=>{c.value&&!e.disabled&&c.value.click()};return Z(()=>{v.forEach(a=>URL.revokeObjectURL(a))}),ee({chooseFile:T,closeImagePreview:z}),ae(()=>e.modelValue),()=>i("div",{class:r()},[i("div",{class:r("wrapper",{disabled:e.disabled})},[E(),M()])])}});const Ie=oe(pe);export{Ie as U};
- >>>>>>>> online:dist/assets/index.6999cc47.js
|