Agriculture-front-end/dist/assets/userAvatar.e0a3ec0c.js

8 lines
32 KiB
JavaScript
Raw Normal View History

2023-07-24 18:07:54 +08:00
import{C as R,o as W,c as M,G as E,H as k,k as m,I,l as S,J as F,y as T,_ as V,b as j,r as $,D as q,d as H,f as y,e as C,w as x,j as G,m as A,F as Z,p as J,q as K,s as Q}from"./index.db81687b.js";import{u as _}from"./user.ed3db704.js";const B={};B.getData=t=>new Promise((e,i)=>{let s={};tt(t).then(o=>{s.arrayBuffer=o,s.orientation=ot(o),e(s)}).catch(o=>{i(o)})});function tt(t){let e=null;return new Promise((i,s)=>{if(t.src)if(/^data\:/i.test(t.src))e=it(t.src),i(e);else if(/^blob\:/i.test(t.src)){var o=new FileReader;o.onload=function(h){e=h.target.result,i(e)},et(t.src,function(h){o.readAsArrayBuffer(h)})}else{var r=new XMLHttpRequest;r.onload=function(){if(this.status==200||this.status===0)e=r.response,i(e);else throw"Could not load image";r=null},r.open("GET",t.src,!0),r.responseType="arraybuffer",r.send(null)}else s("img error")})}function et(t,e){var i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="blob",i.onload=function(s){(this.status==200||this.status===0)&&e(this.response)},i.send()}function it(t){t=t.replace(/^data\:([^\;]+)\;base64,/gmi,"");for(var e=atob(t),i=e.length,s=new ArrayBuffer(i),o=new Uint8Array(s),r=0;r<i;r++)o[r]=e.charCodeAt(r);return s}function st(t,e,i){var s="",o;for(o=e,i+=e;o<i;o++)s+=String.fromCharCode(t.getUint8(o));return s}function ot(t){var e=new DataView(t),i=e.byteLength,s,o,r,h,a,l,c,n,p,f;if(e.getUint8(0)===255&&e.getUint8(1)===216)for(p=2;p<i;){if(e.getUint8(p)===255&&e.getUint8(p+1)===225){c=p;break}p++}if(c&&(o=c+4,r=c+10,st(e,o,4)==="Exif"&&(l=e.getUint16(r),a=l===18761,(a||l===19789)&&e.getUint16(r+2,a)===42&&(h=e.getUint32(r+4,a),h>=8&&(n=r+h)))),n){for(i=e.getUint16(n,a),f=0;f<i;f++)if(p=n+f*12+2,e.getUint16(p,a)===274){p+=8,s=e.getUint16(p,a);break}}return s}var rt=(t,e)=>{const i=t.__vccOpts||t;for(const[s,o]of e)i[s]=o;return i};const ht=R({data:function(){return{w:0,h:0,scale:1,x:0,y:0,loading:!0,trueWidth:0,trueHeight:0,move:!0,moveX:0,moveY:0,crop:!1,cropping:!1,cropW:0,cropH:0,cropOldW:0,cropOldH:0,canChangeX:!1,canChangeY:!1,changeCropTypeX:1,changeCropTypeY:1,cropX:0,cropY:0,cropChangeX:0,cropChangeY:0,cropOffsertX:0,cropOffsertY:0,support:"",touches:[],touchNow:!1,rotate:0,isIos:!1,orientation:0,imgs:"",coe:.2,scaling:!1,scalingSet:"",coeStatus:"",isCanShow:!0}},props:{img:{type:[String,Blob,null,File],default:""},outputSize:{type:Number,default:1},outputType:{type:String,default:"jpeg"},info:{type:Boolean,default:!0},canScale:{type:Boolean,default:!0},autoCrop:{type:Boolean,default:!1},autoCropWidth:{type:[Number,String],default:0},autoCropHeight:{type:[Number,String],default:0},fixed:{type:Boolean,default:!1},fixedNumber:{type:Array,default:()=>[1,1]},fixedBox:{type:Boolean,default:!1},full:{type:Boolean,default:!1},canMove:{type:Boolean,default:!0},canMoveBox:{type:Boolean,default:!0},original:{type:Boolean,default:!1},centerBox:{type:Boolean,default:!1},high:{type:Boolean,default:!0},infoTrue:{type:Boolean,default:!1},maxImgSize:{type:[Number,String],default:2e3},enlarge:{type:[Number,String],default:1},preW:{type:[Number,String],default:0},mode:{type:String,default:"contain"},limitMinSize:{type:[Number,Array,String],default:()=>10}},computed:{cropInfo(){let t={};if(t.top=this.cropOffsertY>21?"-21px":"0px",t.width=this.cropW>0?this.cropW:0,t.height=this.cropH>0?this.cropH:0,this.infoTrue){let e=1;this.high&&!this.full&&(e=window.devicePixelRatio),this.enlarge!==1&!this.full&&(e=Math.abs(Number(this.enlarge))),t.width=t.width*e,t.height=t.height*e,this.full&&(t.width=t.width/this.scale,t.height=t.height/this.scale)}return t.width=t.width.toFixed(0),t.height=t.height.toFixed(0),t},isIE(){return!!window.ActiveXObject||"ActiveXObject"in window},passive(){return this.isIE?null:{passive:!1}}},watch:{img(){this.checkedImg()},imgs(t){t!==""&&this.reload()},cropW(){this.showPreview()},cropH(){this.showPreview()},cropOffsertX(){this.showPreview()},cropOffsertY(){this.showPreview()},scale(t,e){this.showPreview()},x(){this.showPreview()},y(){this.showPreview()},autoCrop(t){t&&this.goAutoCrop()},autoCropWidth(){this.autoCrop&&this.goAutoCrop()},autoCropHeight(){thi
<div class="show-preview" style="width: ${s.w}px; height: ${s.h}px,; overflow: hidden">
<div style="width: ${t}px; height: ${e}px">
<img src=${s.url} style="width: ${this.trueWidth}px; height: ${this.trueHeight}px; transform:
scale(${i})translate3d(${o}px, ${r}px, ${h}px)rotateZ(${this.rotate*90}deg)">
</div>
</div>`,this.$emit("realTime",s),this.$emit("real-time",s)},reload(){let t=new Image;t.onload=()=>{this.w=parseFloat(window.getComputedStyle(this.$refs.cropper).width),this.h=parseFloat(window.getComputedStyle(this.$refs.cropper).height),this.trueWidth=t.width,this.trueHeight=t.height,this.original?this.scale=1:this.scale=this.checkedMode(),this.$nextTick(()=>{this.x=-(this.trueWidth-this.trueWidth*this.scale)/2+(this.w-this.trueWidth*this.scale)/2,this.y=-(this.trueHeight-this.trueHeight*this.scale)/2+(this.h-this.trueHeight*this.scale)/2,this.loading=!1,this.autoCrop&&this.goAutoCrop(),this.$emit("img-load","success"),this.$emit("imgLoad","success"),setTimeout(()=>{this.showPreview()},20)})},t.onerror=()=>{this.$emit("imgLoad","error"),this.$emit("img-load","error")},t.src=this.imgs},checkedMode(){let t=1,e=this.trueWidth,i=this.trueHeight;const s=this.mode.split(" ");switch(s[0]){case"contain":this.trueWidth>this.w&&(t=this.w/this.trueWidth),this.trueHeight*t>this.h&&(t=this.h/this.trueHeight);break;case"cover":e=this.w,t=e/this.trueWidth,i=i*t,i<this.h&&(i=this.h,t=i/this.trueHeight);break;default:try{let o=s[0];if(o.search("px")!==-1){o=o.replace("px",""),e=parseFloat(o);const r=e/this.trueWidth;let h=1,a=s[1];a.search("px")!==-1&&(a=a.replace("px",""),i=parseFloat(a),h=i/this.trueHeight),t=Math.min(r,h)}if(o.search("%")!==-1&&(o=o.replace("%",""),e=parseFloat(o)/100*this.w,t=e/this.trueWidth),s.length===2&&o==="auto"){let r=s[1];r.search("px")!==-1&&(r=r.replace("px",""),i=parseFloat(r),t=i/this.trueHeight),r.search("%")!==-1&&(r=r.replace("%",""),i=parseFloat(r)/100*this.h,t=i/this.trueHeight)}}catch{t=1}}return t},goAutoCrop(t,e){if(this.imgs===""||this.imgs===null)return;this.clearCrop(),this.cropping=!0;let i=this.w,s=this.h;if(this.centerBox){const h=Math.abs(this.rotate)%2>0;let a=(h?this.trueHeight:this.trueWidth)*this.scale,l=(h?this.trueWidth:this.trueHeight)*this.scale;i=a<i?a:i,s=l<s?l:s}var o=t||parseFloat(this.autoCropWidth),r=e||parseFloat(this.autoCropHeight);(o===0||r===0)&&(o=i*.8,r=s*.8),o=o>i?i:o,r=r>s?s:r,this.fixed&&(r=o/this.fixedNumber[0]*this.fixedNumber[1]),r>this.h&&(r=this.h,o=r/this.fixedNumber[1]*this.fixedNumber[0]),this.changeCrop(o,r)},changeCrop(t,e){if(this.centerBox){let i=this.getImgAxis();t>i.x2-i.x1&&(t=i.x2-i.x1,e=t/this.fixedNumber[0]*this.fixedNumber[1]),e>i.y2-i.y1&&(e=i.y2-i.y1,t=e/this.fixedNumber[1]*this.fixedNumber[0])}this.cropW=t,this.cropH=e,this.checkCropLimitSize(),this.$nextTick(()=>{this.cropOffsertX=(this.w-this.cropW)/2,this.cropOffsertY=(this.h-this.cropH)/2,this.centerBox&&this.moveCrop(null,!0)})},refresh(){this.img,this.imgs="",this.scale=1,this.crop=!1,this.rotate=0,this.w=0,this.h=0,this.trueWidth=0,this.trueHeight=0,this.clearCrop(),this.$nextTick(()=>{this.checkedImg()})},rotateLeft(){this.rotate=this.rotate<=-3?0:this.rotate-1},rotateRight(){this.rotate=this.rotate>=3?0:this.rotate+1},rotateClear(){this.rotate=0},checkoutImgAxis(t,e,i){t=t||this.x,e=e||this.y,i=i||this.scale;let s=!0;if(this.centerBox){let o=this.getImgAxis(t,e,i),r=this.getCropAxis();o.x1>=r.x1&&(s=!1),o.x2<=r.x2&&(s=!1),o.y1>=r.y1&&(s=!1),o.y2<=r.y2&&(s=!1)}return s}},mounted(){this.support="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll";let t=this;var e=navigator.userAgent;this.isIOS=!!e.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(i,s,o){for(var r=atob(this.toDataURL(s,o).split(",")[1]),h=r.length,a=new Uint8Array(h),l=0;l<h;l++)a[l]=r.charCodeAt(l);i(new Blob([a],{type:t.type||"image/png"}))}}),this.showPreview(),this.checkedImg()},destroyed(){window.removeEventListener("mousemove",this.moveCrop),window.removeEventListener("mouseup",this.leaveCrop),window.removeEventListener("touchmove",this.moveCrop),window.removeEventListener("touchend",this.leaveCrop),this.cancelScale()}}),at={key:0,class:"cropper-box"},nt=["src"],lt={class:"cropper-view-box"},ct=["src"],pt={key:1};function ut(t,e,i,s,o,r){return W(),M("di