dianzibao-admin-v2/admin/assets/update-DViT8bpS.js
2025-06-26 18:33:12 +08:00

2 lines
7.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{T as ne,E as se}from"./index.esm-5xVujSTG.js";import{f as ie,e as W,g as ue}from"./index-DFSQhMs6.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-wyO9_XA2.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.y,s.y);p.value={x1:i,y1:o,x2:m,y2:v},S.value={left:`${i}px`,top:`${o}px`,width:`${m-i}px`,height:`${v-o}px`},L(()=>{M(i,o,m,v)}),c.value=[]},M=(t,e,a,s)=>{_.value=`${t},${e},${a},${s}`;const i=document.getElementById("myCanvas");if(!i)return;const o=i.getContext("2d");o.clearRect(0,0,i.width,i.height),o.beginPath(),o.moveTo(t,e),o.lineTo(a,e),o.lineTo(a,s),o.lineTo(t,s),o.closePath(),o.lineWidth=3,o.strokeStyle="green",o.setLineDash([5,3]),o.stroke()},oe=t=>{p.value&&(w.value=!0,$.value=!1,b.value={x:t.clientX,y:t.clientY})},le=t=>{if(w.value){const e=t.clientX-b.value.x,a=t.clientY-b.value.y;p.value.x1+=e,p.value.y1+=a,p.value.x2+=e,p.value.y2+=a,f.value.xx1+=e,f.value.yy1+=a,f.value.xx2+=e,f.value.yy2+=a,g.value=`${f.value.xx1},${f.value.yy1},${f.value.xx2},${f.value.yy2}`,b.value={x:t.clientX,y:t.clientY},M(p.value.x1,p.value.y1,p.value.x2,p.value.y2)}},U=()=>{w.value=!1};return(t,e)=>{const a=x("el-card"),s=x("el-col"),i=x("el-input"),o=x("el-form-item"),m=x("el-button"),v=x("el-form"),y=x("el-row"),C=x("KoiCard");return B(W)?(ge(),ye("div",be,[n(C,null,{default:u(()=>[n(y,{gutter:20},{default:u(()=>[n(s,{span:8},{default:u(()=>[e[8]||(e[8]=I("div",{style:{padding:"0px 20px 20px 0px","font-weight":"600"}},"请在图片边框内选定区域",-1)),n(a,{"body-style":{padding:"0"},style:{padding:"0",position:"relative"}},{default:u(()=>[I("div",{onMousedown:oe,onMousemove:le,onMouseup:U,onMouseleave:U,style:{width:"100%"}},[I("img",{draggable:"false",id:"image-selector",src:V.value.bm_img,ref:"image",alt:"image",onClick:A,style:{cursor:"crosshair",position:"relative","user-select":"none",width:"100%",height:"auto"},onLoad:Z},null,40,Ce),I("canvas",{id:"myCanvas",ref:"canvas",width:z.value,height:N.value,style:{position:"absolute",top:"0",left:"0","pointer-events":"none"}},null,8,Ie)],32)]),_:1})]),_:1}),n(s,{span:16},{default:u(()=>[n(v,{model:l,"label-width":"auto"},{default:u(()=>[n(o,{label:"新闻标题",required:""},{default:u(()=>[n(i,{modelValue:l.new_name,"onUpdate:modelValue":e[0]||(e[0]=d=>l.new_name=d),placeholder:"请输入新闻标题",size:"large"},null,8,["modelValue"])]),_:1}),n(o,{label:"新闻副标题"},{default:u(()=>[n(i,{modelValue:l.subtitle,"onUpdate:modelValue":e[1]||(e[1]=d=>l.subtitle=d),placeholder:"请输入新闻副标题",size:"large"},null,8,["modelValue"])]),_:1}),n(o,{label:"新闻记者",required:""},{default:u(()=>[n(i,{modelValue:l.reporter,"onUpdate:modelValue":e[2]||(e[2]=d=>l.reporter=d),placeholder:"请输入新闻记者",size:"large"},null,8,["modelValue"])]),_:1}),n(o,{label:"新闻坐标",required:""},{default:u(()=>[n(i,{disabled:"",modelValue:g.value,"onUpdate:modelValue":e[3]||(e[3]=d=>g.value=d),placeholder:"请选择新闻坐标",size:"large"},null,8,["modelValue"]),n(m,{class:"mt-2",onClick:e[4]||(e[4]=d=>Q())},{default:u(()=>e[9]||(e[9]=[O("重新选择")])),_:1})]),_:1}),n(o,{label:"媒体链接"},{default:u(()=>[n(i,{modelValue:l.video,"onUpdate:modelValue":e[5]||(e[5]=d=>l.video=d),placeholder:"请输入媒体链接",size:"large"},null,8,["modelValue"])]),_:1}),n(o,{label:"跳转链接"},{default:u(()=>[n(i,{modelValue:l.jump_link,"onUpdate:modelValue":e[6]||(e[6]=d=>l.jump_link=d),placeholder:"请输入跳转链接",size:"large"},null,8,["modelValue"])]),_:1}),n(o,{label:"新闻详情",required:""},{default:u(()=>[n(a,{shadow:"hover"},{default:u(()=>[n(B(ne),{style:{"border-bottom":"1px solid #ccc"},editor:k.value,defaultConfig:K},null,8,["editor"]),n(B(se),{style:{height:"300px","overflow-y":"hidden"},modelValue:l.content,"onUpdate:modelValue":e[7]||(e[7]=d=>l.content=d),defaultConfig:G,onOnCreated:J},null,8,["modelValue"])]),_:1})]),_:1}),n(o,{label:" "},{default:u(()=>[n(m,{type:"primary",onClick:H,size:"large"},{default:u(()=>e[10]||(e[10]=[O("保存新闻")])),_:1})]),_:1})]),_:1},8,["model"])]),_:1})]),_:1})]),_:1})])):he("",!0)}}}),Ee=we(Ve,[["__scopeId","data-v-b31f7859"]]);export{Ee as default};