2 lines
7.8 KiB
JavaScript
2 lines
7.8 KiB
JavaScript
|
import{T as ne,E as se}from"./index.esm-CNG9ag4U.js";import{f as ie,e as W,g as ue}from"./index-5uX73ANp.js";import{d as de,J as re,p as ce,f as me,r,O as pe,o as ve,R as h,a4 as L,P as fe,Q as xe,G as x,u as B,a as ge,c as ye,x as n,y as u,i as I,C as O,W as he,S as _e,_ as we}from"./index-BRRhBORR.js";const be={key:0,class:"koi-flex"},Ce=["src"],Ie=["width","height"],Ve=de({__name:"update",setup(ke){const X=re(),Y=ce(),l=me({new_name:"",coordinate:"",coordinate_show:"",subtitle:"",reporter:"",content:"",video:"",jump_link:""}),g=r(),_=r(),V=r({}),E=pe(),T=r();ve(()=>{T.value=E.params.id,j()});const j=async()=>{try{const t=await ie({id:T.value});l.new_name=t.data.new_name,l.subtitle=t.data.subtitle,l.reporter=t.data.reporter,l.content=t.data.content,l.id=t.data.id,l.bm_id=t.data.bm_id,l.coordinate=t.data.coordinate,l.coordinate_show=t.data.coordinate_show,l.video=t.data.video,l.jump_link=t.data.jump_link,g.value=t.data.coordinate,_.value=t.data.coordinate_show,await q(t.data.bm_id)}catch{h("数据查询失败,请刷新重试🌻")}},q=async t=>{try{const D=await W({id:t});V.value=D.data;var e=_.value.split(","),a=g.value.split(","),s=parseInt(a[0]),i=parseInt(a[1]),o=parseInt(a[2]),m=parseInt(a[3]);f.value={xx1:s,yy1:i,xx2:o,yy2:m};var v=parseInt(e[0]),y=parseInt(e[1]),C=parseInt(e[2]),d=parseInt(e[3]);F(v,y,C,d)}catch{h("数据查询失败,请刷新重试")}},F=(t,e,a,s)=>{p.value={x1:t,y1:e,x2:a,y2:s},S.value={left:`${t}px`,top:`${e}px`,width:`${a-t}px`,height:`${s-e}px`},L(()=>{setTimeout(()=>{M(t,e,a,s)},500)}),c.value=[]},H=async()=>{l.coordinate=g.value,l.coordinate_show=_.value;try{const t=await ue(l);V.value=t.data,_e("修改成功!"),Y.removeTab(E.fullPath),X.push("/paper/list")}catch{h("数据添加失败,请刷新重试🌻")}},K={showLinkImg:!1,uploadImgShowBase64:!0,excludeKeys:["insertImage","insertLink","insertTable","codeBlock"]},G={placeholder:"",readOnly:!1,autoFocus:!0,MENU_CONF:{uploadImage:{maxFileSize:1*1024*1024,server:"/api/common/upload",fieldName:"file",meta:{association_id:0},customInsert(t,e){e(t.data.fullurl,"","")},onError:(t,e,a)=>{e.message.indexOf("exceeds maximum allowed size")!==-1&&h("图片限制为1M,请调整好再上传!")}},uploadVideo:{maxFileSize:50*1024*1024,server:"/api/common/upload",fieldName:"file",meta:{association_id:0},customInsert(t,e){e(t.data.fullurl,"","")},onError:(t,e,a)=>{e.message.indexOf("exceeds maximum allowed size")!==-1&&h("视频限制为50M,请调整好再上传!")}}}};fe(()=>{const t=k.value;t!=null&&t.destroy()});const J=t=>{k.value=t},c=r([]),f=r(),k=xe(),R=r([]),p=r(null),S=r(null),z=r(0),N=r(0),P=r(!1),w=r(!1),b=r({x:0,y:0}),$=r(!0),Q=()=>{c.value=[],$.value=!0,w.value=!1,p.value=null;const t=document.getElementById("myCanvas");t.getContext("2d").clearRect(0,0,t.width,t.height)},Z=()=>{const t=document.getElementById("image-selector");z.value=t.offsetWidth,N.value=t.offsetHeight,P.value=!0},A=t=>{if(!P.value||!$.value)return;const e=document.getElementById("image-selector"),a=e.getBoundingClientRect(),s=e.naturalWidth/e.offsetWidth,i=e.naturalHeight/e.offsetHeight,o=parseInt((t.clientX-a.left)*s),m=parseInt((t.clientY-a.top)*i),v=t.clientX-a.left,y=t.clientY-a.top;c.value.push({x:v,y}),R.value.push({xx:o,yy:m}),document.getElementById("myCanvas")&&ee(),c.value.length===4&&(ae(),te())},ee=()=>{const t=document.getElementById("myCanvas");if(!t)return;const e=t.getContext("2d");if(e.clearRect(0,0,t.width,t.height),c.value.forEach(a=>{e.beginPath(),e.arc(a.x,a.y,5,0,Math.PI*2),e.fillStyle="red",e.fill()}),c.value.length>1){e.beginPath(),e.moveTo(c.value[0].x,c.value[0].y);for(let a=1;a<c.value.length;a++)e.lineTo(c.value[a].x,c.value[a].y);e.strokeStyle="blue",e.lineWidth=2,e.stroke()}},te=()=>{const[t,e,a,s]=R.value,i=Math.min(t.xx,e.xx,a.xx,s.xx),o=Math.min(t.yy,e.yy,a.yy,s.yy),m=Math.max(t.xx,e.xx,a.xx,s.xx),v=Math.max(t.yy,e.yy,a.yy,s.yy);f.value={xx1:i,yy1:o,xx2:m,yy2:v},g.value=`${i},${o},${m},${v}`},ae=()=>{const[t,e,a,s]=c.value,i=Math.min(t.x,e.x,a.x,s.x),o=Math.min(t.y,e.y,a.y,s.y),m=Math.max(t.x,e.x,a.x,s.x),v=Math.max(t.y,e.y,a
|