You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
4.1 KiB
2 lines
4.1 KiB
|
4 months ago
|
import{s as B,r as i,d as F,ax as W,w as H,G as I,Q as P,a as Y,f as X,q as w,O as R,h as m,H as D,t as V,R as A,Y as E,Z as z,a0 as N,p as U,m as $,_ as q}from"./index-e450010e.js";function k(v,t,f=100,d,o=24,l=60){const e=t.getContext("2d"),p=f*.01;let r=Math.ceil(10/p);r<8&&(r=8);const g=Math.ceil(d+l/r);if(v=="top"){t.width=d+l,t.height=o,e.clearRect(0,0,d,o),e.beginPath(),e.strokeStyle="rgb(161, 174, 179)",e.font="10px Arial",e.lineWidth=.5,e.moveTo(l,0),e.lineTo(l,o),e.fillText("0",l+2,13);for(let n=1;n<=g;n++){const s=l+Math.round(n*r*p);if(n%10===0){e.moveTo(s,0),e.lineTo(s,o);const a=n*r+"";e.fillText(a,s+2,13)}else if(n%5===0){e.moveTo(s,15),e.lineTo(s,o);const a=n*r+"";e.fillText(a,s+2,13)}else e.moveTo(s,o-2),e.lineTo(s,o)}e.stroke()}else{t.width=o,t.height=d+l,e.clearRect(0,0,o,d+l),e.beginPath(),e.strokeStyle="rgb(161, 174, 179)",e.font="10px Arial",e.lineWidth=.5,e.moveTo(0,l),e.lineTo(o,l),e.fillText("0",2,l-2);for(let n=1;n<=g;n++){const s=l+Math.round(n*r*p);if(n%10===0){e.moveTo(0,s),e.lineTo(o,s);const a=r*n+"";e.fillText(a,2,s-2)}else if(n%5===0){e.moveTo(15,s),e.lineTo(o,s);const a=r*n+"";e.fillText(a,2,s-2)}else e.moveTo(o-2,s),e.lineTo(o,s)}e.stroke()}}const G=B("printPageConfigStore",()=>{const v=i(!1),t=i(!0),f=i(1e3),d=i(800),o=i(100),l=i(0),h=i(0),e=i(1920),p=i(1080),r=i("#FFFFFF"),g=i(""),n=()=>o.value,s=()=>o.value*.01,a=()=>o.value>100?10/o.value:.1,S=()=>f.value,T=()=>d.value,M=()=>l.value,c=()=>h.value,b=()=>e.value,x=()=>p.value,C=()=>b()*(n()<100?1:s())+400,y=()=>x()*(n()<100?1:s())+400;return{isMoveCanvas:v,isThumbnail:t,viewWidth:f,viewHeight:d,scale:o,scrollTop:l,scrollLeft:h,screenWidth:e,screenHeight:p,backgroundColor:r,backgroundImage:g,scaleSub:n,percent:s,thumbnailSize:a,viewWidthSub:S,viewHeightSub:T,scrollTopSub:M,scrollLeftSub:c,screenWidthSub:b,screenHeightSub:x,showWidth:C,showHeight:y,isMoveCanvasSub:()=>v.value,canvasConfig:()=>({thumbnailWidth:Math.ceil(b()*a()*s()),thumbnailHeight:Math.ceil(x()*a()*s()),thumbnailWrapWidth:Math.ceil(C()*a()),thumbnailWrapHeight:Math.ceil(y()*a())}),setViewBox:u=>{f.value=u.width,d.value=u.height},setScroll:({left:u,top:_})=>{u<0?u=0:u>C()-S()-60&&(u=C()-S()-60),_<0?_=0:_>y()-T()-60&&(_=y()-T()-60),h.value=Math.round(u),l.value=Math.round(_)},setMoveCanvas:u=>{v.value=u},setScale:u=>{o.value=u},setThumbnail:u=>{t.value=u}}}),O=v=>(U("data-v-c0d96fed"),v=v(),$(),v),Q={class:"dashboard-canvas",id:"dashboard"},Z=O(()=>w("i",{class:"canvas-ruler-cross fa fa-eye"},null,-1)),j=F({__name:"CanvasBg",setup(v){const t=G(),f=i(null),d=i(null),o=i(t.scrollLeftSub()-24),l=i(t.scrollLeftSub()-24),h=i(t.isMoveCanvasSub());let e={startX:0,startY:0};const p=W({width:t.showWidth()+"px",height:t.showHeight()+"px"}),r=W({left:-o.value+"px",top:-l.value+"px",width:t.screenWidth+"px",height:t.screenHeight+"px",transform:`scale(${t.scale*.01})`}),g=W({left:-o.value+"px"}),n=W({top:-l.value+"px"});let s=!1;const a=()=>{s||(s=!0,N(()=>{k("top",f.value,t.scale,t.showWidth(),24,60),k("left",d.value,t.scale,t.showHeight(),24,60),s=!1}))};H(()=>t.screenWidth,()=>{a()},{deep:!0}),H(()=>t.screenHeight,()=>{a()},{deep:!0}),H(()=>t.scale,c=>{console.log("标尺刻度值---111--》",c),r.scale=c*.01,a()},{deep:!0});const S=c=>{c.wheelDelta>0?t.setScale(t.scale+1):t.setScale(t.scale-1)};I(()=>{window.addEventListener("wheel",S),a()}),P(()=>{window.removeEventListener("wheel",S)});const T=c=>{c.stopPropagation(),console.log("鼠标",t.scale),e={startX:c.clientX,startY:c.clientY}},M=c=>{c.stopPropagation();let b=o.value-(c.clientX-e.startX),x=l.value-(c.clientY-e.startY);t.setScroll({left:b,top:x})};return(c,b)=>(Y(),X("div",Q,[w("div",{class:"canvas-bg",style:R(m(p))},[w("div",{style:R(m(r)),class:"canvas-panel-wrap",onMousedown:T,onMouseup:M},[D(V(m(r))+" ",1),A(c.$slots,"default",{},void 0,!0)],36),w("canvas",{ref_key:"topRulerRef",ref:f,class:"canvas-ruler top",style:R(m(g))},null,4),w("canvas",{ref_key:"leftRulerRef",ref:d,class:"canvas-ruler left",style:R(m(n))},null,4),Z,E(w("div",{class:"canvas-move",onMousedown:T,onMouseup:M}," 1212312312 ",544),[[z,m(h)]])],4)]))}
|