2 lines
7.3 KiB
JavaScript
2 lines
7.3 KiB
JavaScript
|
import{T as ee,E as te}from"./index.esm-CNG9ag4U.js";import{e as P,n as le}from"./index-5uX73ANp.js";import{d as oe,J as ae,p as ne,f as se,r as c,O as ie,o as ue,R as x,P as re,Q as de,G as y,u as $,a as ce,c as me,x as a,y as u,i as b,C as U,W as fe,S as ve,a4 as pe,_ as xe}from"./index-BRRhBORR.js";const ye={key:0,class:"koi-flex"},ge=["src"],he=["width","height"],_e=oe({__name:"index",setup(be){const W=ae(),D=ne(),n=se({new_name:"",coordinate:"",subtitle:"",reporter:"",content:"",coordinate_show:"",video:"",jump_link:""}),g=c(),w=c({}),M=ie(),C=c();ue(()=>{C.value=M.params.id,L()});const L=async()=>{try{const t=await P({id:C.value});w.value=t.data}catch{x("数据查询失败,请刷新重试🌻")}},O=async()=>{if(n.coordinate=g.value,n.bm_id=C.value,n.new_name==""){x("新闻标题不能为空!");return}if(n.reporter==""){x("新闻记者不能为空!");return}if(n.coordinate==""||typeof n.coordinate>"u"){x("新闻坐标不能为空!");return}if(n.content==""){x("新闻内容不能为空!");return}n.coordinate_show=`${r.value.x1},${r.value.y1},${r.value.x2},${r.value.y2}`;try{const t=await le(n);w.value=t.data,ve("添加成功!"),D.removeTab(M.fullPath),W.push("/paper/list")}catch{x("数据添加失败,请刷新重试🌻")}},X={showLinkImg:!1,uploadImgShowBase64:!0,excludeKeys:["insertImage","insertLink","insertTable","codeBlock"]},Y={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,l)=>{e.message.indexOf("exceeds maximum allowed size")!==-1&&x("图片限制为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,l)=>{e.message.indexOf("exceeds maximum allowed size")!==-1&&x("视频限制为50M,请调整好再上传!")}}}};re(()=>{const t=V.value;t!=null&&t.destroy()});const q=t=>{V.value=t},m=c([]),p=c(),V=de(),B=c([]),r=c(null),F=c(null),E=c(0),T=c(0),R=c(!1),h=c(!1),_=c({x:0,y:0}),k=c(!0),H=()=>{m.value=[],k.value=!0,h.value=!1,r.value=null;const t=document.getElementById("myCanvas");t.getContext("2d").clearRect(0,0,t.width,t.height)},j=()=>{const t=document.getElementById("image-selector");E.value=t.offsetWidth,T.value=t.offsetHeight,R.value=!0},K=t=>{if(!R.value||!k.value)return;const e=document.getElementById("image-selector"),l=e.getBoundingClientRect(),i=e.naturalWidth/e.offsetWidth,s=e.naturalHeight/e.offsetHeight,o=parseInt((t.clientX-l.left)*i),f=parseInt((t.clientY-l.top)*s),v=t.clientX-l.left,I=t.clientY-l.top;m.value.push({x:v,y:I}),B.value.push({xx:o,yy:f}),document.getElementById("myCanvas")&&A(),m.value.length===4&&(J(),G())},A=()=>{const t=document.getElementById("myCanvas");if(!t)return;const e=t.getContext("2d");if(e.clearRect(0,0,t.width,t.height),m.value.forEach(l=>{e.beginPath(),e.arc(l.x,l.y,5,0,Math.PI*2),e.fillStyle="red",e.fill()}),m.value.length>1){e.beginPath(),e.moveTo(m.value[0].x,m.value[0].y);for(let l=1;l<m.value.length;l++)e.lineTo(m.value[l].x,m.value[l].y);e.strokeStyle="blue",e.lineWidth=2,e.stroke()}},G=()=>{const[t,e,l,i]=B.value,s=Math.min(t.xx,e.xx,l.xx,i.xx),o=Math.min(t.yy,e.yy,l.yy,i.yy),f=Math.max(t.xx,e.xx,l.xx,i.xx),v=Math.max(t.yy,e.yy,l.yy,i.yy);p.value={x1:s,y1:o,x2:f,y2:v},g.value=`${s},${o},${f},${v}`},J=()=>{const[t,e,l,i]=m.value,s=Math.min(t.x,e.x,l.x,i.x),o=Math.min(t.y,e.y,l.y,i.y),f=Math.max(t.x,e.x,l.x,i.x),v=Math.max(t.y,e.y,l.y,i.y);r.value={x1:s,y1:o,x2:f,y2:v},F.value={left:`${s}px`,top:`${o}px`,width:`${f-s}px`,height:`${v-o}px`},pe(()=>{S(s,o,f,v)}),m.value=[]},S=(t,e,l,i)=>{const s=document.getElementById("myCanvas");if(!s)return;const o=s.getContext("2d");o.clearRect(0,0,s.width,s.height),o.beginPath(),o.moveTo(t,e),o.lineTo(l,e),o.lineTo(l,i),o.lineTo(t,i),o.closePath(),o.lineWidth=3,o.strokeStyle="green",o.setLineDash([5,3]),o.stroke()},Q=t=>{r.value&&(h.value=!0,k.value=!1,_.value={x:t.clientX,y:t.clientY})},Z=t=>{if(h.value){cons
|