2 lines
15 KiB
JavaScript
2 lines
15 KiB
JavaScript
import{E as Ee}from"./el-button.b86b6ea8.js";import{a9 as H,p as ve,M as ie,aa as ge,ab as fe,a as U,ac as pe,ad as Ie,ae as ze,af as ye,q as he,ag as Ce,r as m,ah as $e,ai as Ae,s as z,aj as ue,ak as we,b as be,o as C,c as ce,f as u,w as p,j as E,y as k,u as a,z as de,al as Se,k as S,E as j,am as Le,e as T,F as se,an as Ne,i as Oe,ao as xe,ap as Ve,A as Re,aq as Te,ar as Ze,G as je,a0 as De,a1 as Be,x as ae,as as Pe,at as Me,B as _e,au as F,av as Y,aw as Xe,C as ke,ax as Fe,ay as He,t as ne,az as Ye,aA as Ge,aB as qe,aC as Je,V as D,aD as We,D as me,h as oe,aE as Ue}from"./entry.539d3b49.js";import{t as le}from"./throttle.4fc9319f.js";import{u as Ke,g as Qe,E as et}from"./el-input.60ea0dae.js";import{E as tt,a as at,b as nt}from"./el-overlay.172e9766.js";const st=(e,n)=>{if(!H||!e||!n)return!1;const l=e.getBoundingClientRect();let r;return n instanceof Element?r=n.getBoundingClientRect():r={top:0,right:window.innerWidth,bottom:window.innerHeight,left:0},l.top<r.bottom&&l.bottom>r.top&&l.right>r.left&&l.left<r.right},rt=ve({urlList:{type:ie(Array),default:()=>ge([])},zIndex:{type:Number},initialIndex:{type:Number,default:0},infinite:{type:Boolean,default:!0},hideOnClickModal:{type:Boolean,default:!1},teleported:{type:Boolean,default:!1},closeOnPressEscape:{type:Boolean,default:!0},zoomRate:{type:Number,default:1.2}}),ot={close:()=>!0,switch:e=>fe(e)},lt=["src"],it=U({name:"ElImageViewer"}),ut=U({...it,props:rt,emits:ot,setup(e,{expose:n,emit:l}){const r=e,$={CONTAIN:{name:"contain",icon:pe(Ie)},ORIGINAL:{name:"original",icon:pe(ze)}},{t:g}=ye(),o=he("image-viewer"),{nextZIndex:B}=Ce(),y=m(),c=m([]),h=$e(),w=m(!0),b=m(r.initialIndex),_=Ae($.CONTAIN),d=m({scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1}),f=z(()=>{const{urlList:t}=r;return t.length<=1}),v=z(()=>b.value===0),L=z(()=>b.value===r.urlList.length-1),N=z(()=>r.urlList[b.value]),P=z(()=>{const{scale:t,deg:s,offsetX:i,offsetY:I,enableTransition:V}=d.value;let A=i/t,R=I/t;switch(s%360){case 90:case-270:[A,R]=[R,-A];break;case 180:case-180:[A,R]=[-A,-R];break;case 270:case-90:[A,R]=[-R,A];break}const X={transform:`scale(${t}) rotate(${s}deg) translate(${A}px, ${R}px)`,transition:V?"transform .3s":""};return _.value.name===$.CONTAIN.name&&(X.maxWidth=X.maxHeight="100%"),X}),G=z(()=>fe(r.zIndex)?r.zIndex:B());function Z(){O(),l("close")}function M(){const t=le(i=>{switch(i.code){case F.esc:r.closeOnPressEscape&&Z();break;case F.space:J();break;case F.left:ee();break;case F.up:x("zoomIn");break;case F.right:te();break;case F.down:x("zoomOut");break}}),s=le(i=>{const I=i.deltaY||i.deltaX;x(I<0?"zoomIn":"zoomOut",{zoomRate:r.zoomRate,enableTransition:!1})});h.run(()=>{Y(document,"keydown",t),Y(document,"wheel",s)})}function O(){h.stop()}function re(){w.value=!1}function K(t){w.value=!1,t.target.alt=g("el.image.error")}function Q(t){if(w.value||t.button!==0||!y.value)return;d.value.enableTransition=!1;const{offsetX:s,offsetY:i}=d.value,I=t.pageX,V=t.pageY,A=le(X=>{d.value={...d.value,offsetX:s+X.pageX-I,offsetY:i+X.pageY-V}}),R=Y(document,"mousemove",A);Y(document,"mouseup",()=>{R()}),t.preventDefault()}function q(){d.value={scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1}}function J(){if(w.value)return;const t=Xe($),s=Object.values($),i=_.value.name,V=(s.findIndex(A=>A.name===i)+1)%t.length;_.value=$[t[V]],q()}function W(t){const s=r.urlList.length;b.value=(t+s)%s}function ee(){v.value&&!r.infinite||W(b.value-1)}function te(){L.value&&!r.infinite||W(b.value+1)}function x(t,s={}){if(w.value)return;const{zoomRate:i,rotateDeg:I,enableTransition:V}={zoomRate:r.zoomRate,rotateDeg:90,enableTransition:!0,...s};switch(t){case"zoomOut":d.value.scale>.2&&(d.value.scale=Number.parseFloat((d.value.scale/i).toFixed(3)));break;case"zoomIn":d.value.scale<7&&(d.value.scale=Number.parseFloat((d.value.scale*i).toFixed(3)));break;case"clockwise":d.value.deg+=I;break;case"anticlockwise":d.value.deg-=I;break}d.value.enableTransition=V}return ue(N,()=>{we(()=>{const t=c.value[0];t!=null&&t.complete||(w.value=!0)})}),ue(b,t=>{q(),l("switch",t)}),be(()=>{var t,s;M(),(s=(t=y.value)==null?void 0:t.focus)==null||s.call(t)}),n({setActiveItem:W}),(t,s)=>(C(),ce(Me,{to:"body",disabled:!t.teleported},[u(Pe,{name:"viewer-fade",appear:""},{default:p(()=>[E("div",{ref_key:"wrapper",ref:y,tabindex:-1,class:k(a(o).e("wrapper")),style:de({zIndex:a(G)})},[E("div",{class:k(a(o).e("mask")),onClick:s[0]||(s[0]=Se(i=>t.hideOnClickModal&&Z(),["self"]))},null,2),S(" CLOSE "),E("span",{class:k([a(o).e("btn"),a(o).e("close")]),onClick:Z},[u(a(j),null,{default:p(()=>[u(a(Le))]),_:1})],2),S(" ARROW "),a(f)?S("v-if",!0):(C(),T(se,{key:0},[E("span",{class:k([a(o).e("btn"),a(o).e("prev"),a(o).is("disabled",!t.infinite&&a(v))]),onClick:ee},[u(a(j),null,{default:p(()=>[u(a(Ne))]),_:1})],2),E("span",{class:k([a(o).e("btn"),a(o).e("next"),a(o).is("disabled",!t.infinite&&a(L))]),onClick:te},[u(a(j),null,{default:p(()=>[u(a(Oe))]),_:1})],2)],64)),S(" ACTIONS "),E("div",{class:k([a(o).e("btn"),a(o).e("actions")])},[E("div",{class:k(a(o).e("actions__inner"))},[u(a(j),{onClick:s[1]||(s[1]=i=>x("zoomOut"))},{default:p(()=>[u(a(xe))]),_:1}),u(a(j),{onClick:s[2]||(s[2]=i=>x("zoomIn"))},{default:p(()=>[u(a(Ve))]),_:1}),E("i",{class:k(a(o).e("actions__divider"))},null,2),u(a(j),{onClick:J},{default:p(()=>[(C(),ce(Re(a(_).icon)))]),_:1}),E("i",{class:k(a(o).e("actions__divider"))},null,2),u(a(j),{onClick:s[3]||(s[3]=i=>x("anticlockwise"))},{default:p(()=>[u(a(Te))]),_:1}),u(a(j),{onClick:s[4]||(s[4]=i=>x("clockwise"))},{default:p(()=>[u(a(Ze))]),_:1})],2)],2),S(" CANVAS "),E("div",{class:k(a(o).e("canvas"))},[(C(!0),T(se,null,je(t.urlList,(i,I)=>De((C(),T("img",{ref_for:!0,ref:V=>c.value[I]=V,key:i,src:i,style:de(a(P)),class:k(a(o).e("img")),onLoad:re,onError:K,onMousedown:Q},null,46,lt)),[[Be,I===b.value]])),128))],2),ae(t.$slots,"default")],6)]),_:3})],8,["disabled"]))}});var ct=_e(ut,[["__file","/home/runner/work/element-plus/element-plus/packages/components/image-viewer/src/image-viewer.vue"]]);const dt=ke(ct),ft=ve({hideOnClickModal:{type:Boolean,default:!1},src:{type:String,default:""},fit:{type:String,values:["","contain","cover","fill","none","scale-down"],default:""},loading:{type:String,values:["eager","lazy"]},lazy:{type:Boolean,default:!1},scrollContainer:{type:ie([String,Object])},previewSrcList:{type:ie(Array),default:()=>ge([])},previewTeleported:{type:Boolean,default:!1},zIndex:{type:Number},initialIndex:{type:Number,default:0},infinite:{type:Boolean,default:!0},closeOnPressEscape:{type:Boolean,default:!0},zoomRate:{type:Number,default:1.2}}),pt={load:e=>e instanceof Event,error:e=>e instanceof Event,switch:e=>fe(e),close:()=>!0,show:()=>!0},mt=["src","loading"],vt={key:0},gt=U({name:"ElImage",inheritAttrs:!1}),yt=U({...gt,props:ft,emits:pt,setup(e,{emit:n}){const l=e;let r="";const{t:$}=ye(),g=he("image"),o=Fe(),B=Ke(),y=m(),c=m(!1),h=m(!0),w=m(!1),b=m(),_=m(),d=H&&"loading"in HTMLImageElement.prototype;let f,v;const L=z(()=>o.style),N=z(()=>{const{fit:t}=l;return H&&t?{objectFit:t}:{}}),P=z(()=>{const{previewSrcList:t}=l;return Array.isArray(t)&&t.length>0}),G=z(()=>{const{previewSrcList:t,initialIndex:s}=l;let i=s;return s>t.length-1&&(i=0),i}),Z=z(()=>l.loading==="eager"?!1:!d&&l.loading==="lazy"||l.lazy),M=()=>{H&&(h.value=!0,c.value=!1,y.value=l.src)};function O(t){h.value=!1,c.value=!1,n("load",t)}function re(t){h.value=!1,c.value=!0,n("error",t)}function K(){st(b.value,_.value)&&(M(),J())}const Q=qe(K,200);async function q(){var t;if(!H)return;await we();const{scrollContainer:s}=l;Ye(s)?_.value=s:Ge(s)&&s!==""?_.value=(t=document.querySelector(s))!=null?t:void 0:b.value&&(_.value=Qe(b.value)),_.value&&(f=Y(_,"scroll",Q),setTimeout(()=>K(),100))}function J(){!H||!_.value||!Q||(f==null||f(),_.value=void 0)}function W(t){if(t.ctrlKey){if(t.deltaY<0)return t.preventDefault(),!1;if(t.deltaY>0)return t.preventDefault(),!1}}function ee(){P.value&&(v=Y("wheel",W,{passive:!1}),r=document.body.style.overflow,document.body.style.overflow="hidden",w.value=!0,n("show"))}function te(){v==null||v(),document.body.style.overflow=r,w.value=!1,n("close")}function x(t){n("switch",t)}return ue(()=>l.src,()=>{Z.value?(h.value=!0,c.value=!1,J(),q()):M()}),be(()=>{Z.value?q():M()}),(t,s)=>(C(),T("div",{ref_key:"container",ref:b,class:k([a(g).b(),t.$attrs.class]),style:de(a(L))},[y.value!==void 0&&!c.value?(C(),T("img",He({key:0},a(B),{src:y.value,loading:t.loading,style:a(N),class:[a(g).e("inner"),a(P)&&a(g).e("preview"),h.value&&a(g).is("loading")],onClick:ee,onLoad:O,onError:re}),null,16,mt)):S("v-if",!0),h.value||c.value?(C(),T("div",{key:1,class:k(a(g).e("wrapper"))},[h.value?ae(t.$slots,"placeholder",{key:0},()=>[E("div",{class:k(a(g).e("placeholder"))},null,2)]):c.value?ae(t.$slots,"error",{key:1},()=>[E("div",{class:k(a(g).e("error"))},ne(a($)("el.image.error")),3)]):S("v-if",!0)],2)):S("v-if",!0),a(P)?(C(),T(se,{key:2},[w.value?(C(),ce(a(dt),{key:0,"z-index":t.zIndex,"initial-index":a(G),infinite:t.infinite,"zoom-rate":t.zoomRate,"url-list":t.previewSrcList,"hide-on-click-modal":t.hideOnClickModal,teleported:t.previewTeleported,"close-on-press-escape":t.closeOnPressEscape,onClose:te,onSwitch:x},{default:p(()=>[t.$slots.viewer?(C(),T("div",vt,[ae(t.$slots,"viewer")])):S("v-if",!0)]),_:3},8,["z-index","initial-index","infinite","zoom-rate","url-list","hide-on-click-modal","teleported","close-on-press-escape"])):S("v-if",!0)],64)):S("v-if",!0)],6))}});var ht=_e(yt,[["__file","/home/runner/work/element-plus/element-plus/packages/components/image/src/image.vue"]]);const wt=ke(ht);function bt(e){const n=m("");return{image:n,refresh:async()=>{try{await Je().then(r=>{r.code==1&&(e.captcha_key=r.data.captcha_key,e.captcha_code="",n.value=r.data.img.replace(/\r\n/g,""))})}catch{}}}}function _t(){const e=m(!0),n=m(D("getSmsCode")),l=m(90);let r;const $=async B=>{if(!e.value)return;e.value=!1;let y=!1;return await We(B).then(c=>{c.code==1?(g(),y=c.data.key):(o(),y=!1)}).catch(()=>{y=!1,o()}),y},g=()=>{r=setInterval(()=>{l.value>0?(l.value-=1,n.value=`${l.value}${D("smsCodeChangeText")}`):o()},1e3)},o=()=>{clearInterval(r),l.value=90,e.value=!0,n.value=D("getSmsCode")};return{send:$,text:n,canGetCode:e}}const kt={class:"h-[30px]"},Et={class:"py-[5px] leading-none"},It={class:"dialog-footer"},Lt=U({__name:"index",props:{mobile:String,type:{type:String,default:""},modelValue:{type:String,default:""}},emits:["update:modelValue","click"],setup(e,{expose:n,emit:l}){const r=e,$=z({get(){return r.modelValue},set(f){l("update:modelValue",f)}}),g=m(!1),o=me({mobile:"",captcha_code:"",captcha_key:"",type:r.type}),B=me({captcha_code:{required:!0,message:D("captchaPlaceholder"),trigger:["blur","change"]}}),y=m(null),c=m(!1),h=bt(o);h.refresh();const w=_t(),b=()=>{o.mobile=r.mobile,w.canGetCode.value&&(c.value=!0)},_=async()=>{var f;await((f=y.value)==null?void 0:f.validate(async(v,L)=>{if(v){g.value=!0;const N=await w.send(o);N?($.value=N,c.value=!1,g.value=!1):N===!1&&(h.refresh(),g.value=!1)}}))},d=()=>{l("click")};return n({send:b}),(f,v)=>{const L=Ee,N=wt,P=et,G=tt,Z=at,M=nt;return C(),T(se,null,[E("div",kt,[u(L,{type:"primary",link:"",disabled:!a(w).canGetCode.value,onClick:d},{default:p(()=>[oe(ne(a(w).text.value),1)]),_:1},8,["disabled"])]),u(M,{modelValue:a(c),"onUpdate:modelValue":v[3]||(v[3]=O=>Ue(c)?c.value=O:null),title:("t"in f?f.t:a(D))("captchaTitle"),width:"350px","append-to-body":!0,"align-center":!0},{footer:p(()=>[E("span",It,[u(L,{onClick:v[2]||(v[2]=O=>c.value=!1)},{default:p(()=>[oe(ne(("t"in f?f.t:a(D))("cancel")),1)]),_:1}),u(L,{type:"primary",loading:a(g),onClick:_},{default:p(()=>[oe(ne(("t"in f?f.t:a(D))("confirm")),1)]),_:1},8,["loading"])])]),default:p(()=>[u(Z,{model:a(o),ref_key:"formRef",ref:y,rules:a(B)},{default:p(()=>[u(G,{prop:"captcha_code",style:{"margin-bottom":"0"}},{default:p(()=>[u(P,{modelValue:a(o).captcha_code,"onUpdate:modelValue":v[1]||(v[1]=O=>a(o).captcha_code=O),placeholder:("t"in f?f.t:a(D))("captchaPlaceholder")},{suffix:p(()=>[E("div",Et,[u(N,{src:a(h).image.value,class:"h-[30px] cursor-pointer",onClick:v[0]||(v[0]=O=>a(h).refresh())},null,8,["src"])])]),_:1},8,["modelValue","placeholder"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])],64)}}}),Nt={email(e){return/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(e)},mobile(e){return/^1[23456789]\d{9}$/.test(e)},url(e){return/^((https|http|ftp|rtsp|mms):\/\/)(([0-9a-zA-Z_!~*'().&=+$%-]+: )?[0-9a-zA-Z_!~*'().&=+$%-]+@)?(([0-9]{1,3}.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z].[a-zA-Z]{2,6})(:[0-9]{1,4})?((\/?)|(\/[0-9a-zA-Z_!~*'().;?:@&=+$,%#-]+)+\/?)$/.test(e)},date(e){return e?(this.number(e)&&(e=+e),!/Invalid|NaN/.test(new Date(e).toString())):!1},dateISO(e){return/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(e)},number(e){return/^[\+-]?(\d+\.?\d*|\.\d+|\d\.\d+e\+\d+)$/.test(e)},string(e){return typeof e=="string"},digits(e){return/^\d+$/.test(e)},idCard(e){return/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(e)},carNo(e){const n=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/,l=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;return e.length===7?l.test(e):e.length===8?n.test(e):!1},amount(e){return/^[1-9]\d*(,\d{3})*(\.\d{1,2})?$|^0\.\d{1,2}$/.test(e)},chinese(e){return/^[\u4e00-\u9fa5]+$/gi.test(e)},letter(e){return/^[a-zA-Z]*$/.test(e)},enOrNum(e){return/^[0-9a-zA-Z]*$/g.test(e)},contains(e,n){return e.indexOf(n)>=0},range(e,n){return e>=n[0]&&e<=n[1]},rangeLength(e,n){return e.length>=n[0]&&e.length<=n[1]},landline(e){return/^\d{3,4}-\d{7,8}(-\d{3,4})?$/.test(e)},empty(e){switch(typeof e){case"undefined":return!0;case"string":if(e.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g,"").length==0)return!0;break;case"boolean":if(!e)return!0;break;case"number":if(e===0||isNaN(e))return!0;break;case"object":if(e===null||e.length===0)return!0;for(const n in e)return!1;return!0}return!1},jsonString(e){if(typeof e=="string")try{const n=JSON.parse(e);return!!(typeof n=="object"&&n)}catch{return!1}return!1},array(e){return typeof Array.isArray=="function"?Array.isArray(e):Object.prototype.toString.call(e)==="[object Array]"},object(e){return Object.prototype.toString.call(e)==="[object Object]"},code(e,n=6){return new RegExp(`^\\d{${n}}$`).test(e)},func(e){return typeof e=="function"},promise(e){return this.object(e)&&this.func(e.then)&&this.func(e.catch)},image(e){const n=e.split("?")[0];return/\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i.test(n)},video(e){return/\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv|m3u8)/i.test(e)},regExp(e){return e&&Object.prototype.toString.call(e)==="[object RegExp]"}};export{wt as E,Lt as _,Nt as t,bt as u};
|