import{r as a,u as e,w as l,p as t,o as s,b as u,A as o,c as r,d,i,k as c,h as n,W as v,j as p,Q as m,e as h,af as f,v as g,m as w,S as b,a5 as y}from"./index.1699270951405.js";import{u as x}from"./appSide.1699270951405.js";const _={class:"customBox"},k={class:""},V={class:"col-span-2 h-16 flex"},j={class:"iconsel absolute z-10"},C=["src"],I={class:"iconsel absolute z-10"},L=["src"],U={class:"w-1/2 pl-20"},z={__name:"custom",props:{data:{type:Object}},setup(z){var E;const O=z,S=a(!1),A=a(1),B=a=>{A.value=a},P=a(!1),Q=e(),W={id:"",name:"",src:"",url:"",size:"1x1",type:"icon",sort:99999,app:0},q=a(Object.assign({},W));(null==(E=O.data)?void 0:E.id)&&(q.value=O.data);l(q.value,(a=>{}));const D=async()=>{P.value=!0;try{const a=await b({url:"/linkStore/getIcon",method:"post",data:{url:q.value.url}});if(1===a.code)return q.value.src=a.data.src,q.value.name=a.data.name,void(P.value=!1)}catch(a){}try{const a=await b({url:"api/getIcon",method:"post",data:{url:q.value.url}});1===a.code?(q.value.src=a.data.src,q.value.name=a.data.name.substring(0,20)):y.error("获取网站数据失败,请手动设置")}catch(a){console.error("Error fetching data:",a),y.error("获取网站数据失败,请手动设置")}P.value=!1},F=a=>{1===a.code?q.value.src=a.data.url:y.error(a.msg)},G=async()=>{if(""===q.value.name||""===q.value.url)return y.warning("请设置标签信息");if(P.value=!0,"tab"===q.value.url.slice(0,3)||"http"!==q.value.url.slice(0,4)&&(q.value.url="http://"+q.value.url),2===A.value)try{const a=await b({url:"api/getIcon",method:"post",data:{avatar:q.value.name}});1===a.code&&(q.value.src=a.data.src)}catch(a){}""===q.value.id?(q.value.id=x(),Q.state.link.push(q.value),Q.commit("updateLink")):Q.commit("setLink",q.value),P.value=!1,t.emit("closePlugin"),S.value=!1};return t.on("linkEdit",((a=!1)=>{q.value=Object.assign({},W),a&&(q.value=a),S.value=!0})),s((()=>{t.off("linkEdit".open)})),(a,e)=>{const l=u("el-button"),t=u("el-input"),s=u("el-form-item"),b=u("el-upload"),y=u("el-icon"),x=u("el-form"),z=o("loading");return r(),d("div",_,[i((r(),d("div",k,[c(x,{"label-position":"right","label-width":"80px",class:"w-full pr-4 mt-4"},{default:n((()=>[c(s,{label:"标签网址"},{default:n((()=>[c(t,{modelValue:q.value.url,"onUpdate:modelValue":e[0]||(e[0]=a=>q.value.url=a),"show-word-limit":"",maxlength:"255",placeholder:"请输入带http开头的网址"},{append:n((()=>[c(l,{type:"primary",onClick:D},{default:n((()=>[v("获取图标")])),_:1})])),_:1},8,["modelValue"])])),_:1}),c(s,{label:"标签名称"},{default:n((()=>[c(t,{maxlength:"100","show-word-limit":"",modelValue:q.value.name,"onUpdate:modelValue":e[1]||(e[1]=a=>q.value.name=a),placeholder:"标签名称"},null,8,["modelValue"])])),_:1}),c(s,{label:"标签简介"},{default:n((()=>[c(t,{maxlength:"200","show-word-limit":"",type:"textarea",rows:"4",modelValue:q.value.tips,"onUpdate:modelValue":e[2]||(e[2]=a=>q.value.tips=a),placeholder:"简单介绍标签（非必填）"},null,8,["modelValue"])])),_:1}),c(s,{label:"标签Logo"},{default:n((()=>[c(t,{modelValue:q.value.src,"onUpdate:modelValue":e[3]||(e[3]=a=>q.value.src=a),placeholder:"请上传或粘贴标签图标地址"},{append:n((()=>[c(b,{class:"upload-demo","show-file-list":!1,"on-success":F,action:p(m)+p(Q).state.site.upload},{default:n((()=>[c(l,{type:"primary"},{default:n((()=>[v("上传")])),_:1})])),_:1},8,["action"])])),_:1},8,["modelValue"])])),_:1}),c(s,{label:"选择Logo"},{default:n((()=>[h("div",V,[q.value.src?(r(),d("div",{key:0,class:"relative",onClick:e[4]||(e[4]=a=>B(1))},[i(h("div",j,[c(y,null,{default:n((()=>[c(p(f))])),_:1})],512),[[g,1===A.value]]),h("img",{src:q.value.src,class:"rounded-2xl mr-3 bg-slate-100",style:{width:"60px",height:"60px"},alt:""},null,8,C)])):w("",!0),q.value.name?(r(),d("div",{key:1,class:"relative",onClick:e[5]||(e[5]=a=>B(2))},[i(h("div",I,[c(y,null,{default:n((()=>[c(p(f))])),_:1})],512),[[g,2===A.value]]),h("img",{src:p(m)+"/api/renderIco?seed="+q.value.name,class:"rounded-2xl mr-3 bg-slate-100",style:{width:"60px",height:"60px"},alt:""},null,8,L)])):w("",!0)])])),_:1})])),_:1}),h("div",U,[c(l,{type:"primary",class:"w-40",onClick:G},{default:n((()=>[v("保存")])),_:1})])])),[[z,P.value]])])}}};export{z as default};
