custom.1711290598880.js 5.8 KB

1
  1. import{r as l,u as a,E as e,o as t,b as u,c as o,d as s,e as r,k as i,h as d,C as n,j as c,a3 as v,i as p,v as m,aw as x,p as g,m as b,F as f,f as h,U as w,J as y}from"./index.1711290598880.js";const k={class:"customBox pb-6"},_={class:"flex gap-4 w-full"},V={class:"flex gap-4 w-full"},C={class:"col-span-2 h-16 flex"},U={class:"iconsel absolute z-10"},j=["src"],z={class:"iconsel absolute z-10"},E=["src"],G={class:"bgColorPicker"},I=["onClick"],L={key:0,class:"touming"},O={key:0,style:{"font-size":"20px",color:"#ff0000",inset:"-5px 3px",position:"relative"}},R={key:0,style:{"font-size":"20px",color:"#d9d9d9",inset:"-5px 3px",position:"relative"}},P=r("span",{class:"ml-6 text-xs text-red-500"},"内嵌窗口形式打开,存在第三方兼容问题",-1),S={class:"w-full xs:pl-20 mt-10 flex"},B={__name:"custom",props:{data:{type:Object}},setup(B){var F;const J=B,M=window.innerWidth,W=["rgba(0,0,0,0)","#fff","rgb(22, 129, 255)","rgb(251, 190, 35)","rgb(252, 69, 72)","rgb(75, 60, 54)","rgb(125, 172, 104)","rgb(2, 51, 115)","rgb(200, 172, 112)","rgb(55, 33, 40)","rgb(5, 64, 146)"],q=l(!1),A=l(1),D=l=>{A.value=l},H=l(!1),K=a(),N={id:"",name:"",src:"",url:"",size:"1x1",type:"icon",sort:99999,app:0,bgColor:null,pageGroup:""},Q=l(Object.assign({},N));(null==(F=J.data)?void 0:F.id)&&(Q.value=J.data);const T=async()=>{var l;H.value=!0;try{const l=await w({url:"/LinkStore/getIcon",method:"post",data:{url:Q.value.url}});if(1===l.code)return Q.value.src=l.data.src,Q.value.name=l.data.name,void(H.value=!1)}catch(a){}try{const a=await w({url:"/api/getIcon",method:"post",data:{url:Q.value.url}});1===a.code?(Q.value.src=a.data.src,a.data.name&&(Q.value.name=null==(l=a.data)?void 0:l.name.substring(0,20))):y.error(a.msg)}catch(a){console.error("Error fetching data:",a),y.error("获取网站数据失败,请手动设置")}H.value=!1},X=l=>{1===l.code?Q.value.src=l.data.url:y.error(l.msg)},Y=async()=>{if(""===Q.value.name||""===Q.value.url)return y.warning("请设置标签信息");if(H.value=!0,"tab"===Q.value.url.slice(0,3)||1===Q.value.app||"http"!==Q.value.url.slice(0,4)&&(Q.value.url="http://"+Q.value.url),2===A.value)try{const l=await w({url:"/api/getIcon",method:"post",data:{avatar:Q.value.name}});1===l.code&&(Q.value.src=l.data.src)}catch(l){}""===Q.value.id?(Q.value.id="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(l){var a=16*Math.random()|0;return("x"==l?a:3&a|8).toString(16)})),Q.value.pageGroup=K.state.pageGroup,K.state.link.push(Q.value),K.commit("updateLink")):(K.commit("setLink",Q.value),e.emit("refreshGroup")),H.value=!1,e.emit("closePlugin"),q.value=!1};return e.on("linkEdit",((l={})=>{l&&(Q.value=Object.assign({},N)),q.value=!0})),t((()=>{e.off("linkEdit".open)})),(l,a)=>{const e=u("el-input"),t=u("el-button"),w=u("el-form-item"),y=u("el-upload"),B=u("el-icon"),F=u("el-color-picker"),J=u("el-switch"),q=u("el-form");return o(),s("div",k,[r("div",null,[i(q,{"label-position":c(M)<500?"top":"right","label-width":"80px",class:"w-full mt-4"},{default:d((()=>[i(w,{label:"标签网址"},{default:d((()=>[r("div",_,[i(e,{class:"input_div w-full",modelValue:Q.value.url,"onUpdate:modelValue":a[0]||(a[0]=l=>Q.value.url=l),"show-word-limit":"",maxlength:"255",placeholder:"请输入带http开头的网址"},null,8,["modelValue"]),i(t,{type:"primary",onClick:T,loading:H.value},{default:d((()=>[n("获取图标")])),_:1},8,["loading"])])])),_:1}),i(w,{label:"标签名称"},{default:d((()=>[i(e,{maxlength:"100",class:"input_div","show-word-limit":"",modelValue:Q.value.name,"onUpdate:modelValue":a[1]||(a[1]=l=>Q.value.name=l),placeholder:"标签名称"},null,8,["modelValue"])])),_:1}),i(w,{label:"标签简介"},{default:d((()=>[i(e,{class:"input_div",maxlength:"200","show-word-limit":"",type:"textarea",rows:"2",modelValue:Q.value.tips,"onUpdate:modelValue":a[2]||(a[2]=l=>Q.value.tips=l),placeholder:"简单介绍标签(非必填)"},null,8,["modelValue"])])),_:1}),i(w,{label:"标签图标"},{default:d((()=>[r("div",V,[i(e,{class:"input_div",modelValue:Q.value.src,"onUpdate:modelValue":a[3]||(a[3]=l=>Q.value.src=l),placeholder:"请上传或粘贴标签图标地址,支持png,jpg,ico,svg,webp格式"},null,8,["modelValue"]),i(y,{class:"upload-demo","show-file-list":!1,"on-success":X,action:c(v)+c(K).state.site.upload},{default:d((()=>[i(t,{type:"danger"},{default:d((()=>[n("手动上传")])),_:1})])),_:1},8,["action"])])])),_:1}),i(w,{label:"选择图标"},{default:d((()=>[r("div",C,[Q.value.src?(o(),s("div",{key:0,class:"relative",onClick:a[4]||(a[4]=l=>D(1))},[p(r("div",U,[i(B,null,{default:d((()=>[i(c(x))])),_:1})],512),[[m,1===A.value]]),r("img",{src:Q.value.src,class:"mr-3",style:g({width:"60px",height:"60px",backgroundColor:Q.value.bgColor,borderRadius:"var(--iconRadius)"})},null,12,j)])):b("",!0),r("div",{class:"relative",onClick:a[5]||(a[5]=l=>D(2))},[p(r("div",z,[i(B,null,{default:d((()=>[i(c(x))])),_:1})],512),[[m,2===A.value]]),r("img",{src:c(v)+"/api/renderIco?seed="+Q.value.name,class:"mr-3 bg-slate-100",style:{width:"60px",height:"60px","border-radius":"var(--iconRadius)"}},null,8,E)])])])),_:1}),i(w,{label:"背景颜色"},{default:d((()=>[r("ul",G,[(o(),s(f,null,h(W,(l=>r("li",{onClick:a=>{return e=l,void(Q.value.bgColor=e);var e}},["rgba(0,0,0,0)"===l?(o(),s("div",L,[l===Q.value.bgColor?(o(),s("b",O,"√")):b("",!0)])):(o(),s("div",{key:1,style:g({backgroundColor:l})},[l===Q.value.bgColor?(o(),s("b",R,"√")):b("",!0)],4))],8,I))),64)),i(F,{"show-alpha":"",modelValue:Q.value.bgColor,"onUpdate:modelValue":a[6]||(a[6]=l=>Q.value.bgColor=l)},null,8,["modelValue"])])])),_:1}),i(w,{label:"内嵌窗口"},{default:d((()=>[i(J,{"active-value":1,"inactive-value":0,modelValue:Q.value.app,"onUpdate:modelValue":a[7]||(a[7]=l=>Q.value.app=l)},null,8,["modelValue"]),P])),_:1})])),_:1},8,["label-position"]),r("div",S,[i(t,{type:"primary",size:"large",class:"w-full",onClick:Y},{default:d((()=>[n("保存")])),_:1})])])])}}};export{B as default};