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 as c,k as i,h as n,W as v,j as p,Q as m,e as h,ae as f,v as g,m as b,S as y,a5 as _}from"./index.1696777084030.js";import{u as k}from"./appSide.1696777084030.js";const w={class:"customBox"},x={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"],z={class:"w-1/2 pl-20"},E={__name:"custom",props:{data:{type:Object}},setup(E){var O;const S=E,U=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==(O=S.data)?void 0:O.id)&&(q.value=S.data);l(q.value,(a=>{}));const D=async()=>{P.value=!0;try{const a=await y({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 y({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)):_.error("获取网站数据失败,请手动设置")}catch(a){console.error("Error fetching data:",a),_.error("获取网站数据失败,请手动设置")}P.value=!1},F=a=>{1===a.code?q.value.src=a.data.url:_.error(a.msg)},G=async()=>{if(""===q.value.name||""===q.value.url)return _.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 y({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=k(),Q.state.link.push(q.value),Q.commit("updateLink")):Q.commit("setLink",q.value),P.value=!1,t.emit("closePlugin"),U.value=!1};return t.on("linkEdit",((a=!1)=>{q.value=Object.assign({},W),a&&(q.value=a),U.value=!0})),s((()=>{t.off("linkEdit".open)})),(a,e)=>{const l=u("el-button"),t=u("el-input"),s=u("el-form-item"),y=u("el-upload"),_=u("el-icon"),k=u("el-form"),E=o("loading");return r(),d("div",w,[c((r(),d("div",x,[i(k,{"label-position":"right","label-width":"80px",class:"w-2/3"},{default:n((()=>[i(s,{label:"标签网址"},{default:n((()=>[i(t,{modelValue:q.value.url,"onUpdate:modelValue":e[0]||(e[0]=a=>q.value.url=a),placeholder:"请输入带http开头的网址"},{append:n((()=>[i(l,{type:"primary",onClick:D},{default:n((()=>[v("获取图标")])),_:1})])),_:1},8,["modelValue"])])),_:1}),i(s,{label:"标签名称"},{default:n((()=>[i(t,{modelValue:q.value.name,"onUpdate:modelValue":e[1]||(e[1]=a=>q.value.name=a),placeholder:"标签名称"},null,8,["modelValue"])])),_:1}),i(s,{label:"标签Logo"},{default:n((()=>[i(t,{modelValue:q.value.src,"onUpdate:modelValue":e[2]||(e[2]=a=>q.value.src=a),placeholder:"请上传或粘贴标签图标地址"},{append:n((()=>[i(y,{class:"upload-demo","show-file-list":!1,"on-success":F,action:p(m)+p(Q).state.site.upload},{default:n((()=>[i(l,{type:"primary"},{default:n((()=>[v("上传")])),_:1})])),_:1},8,["action"])])),_:1},8,["modelValue"])])),_:1}),i(s,{label:"选择Logo"},{default:n((()=>[h("div",V,[q.value.src?(r(),d("div",{key:0,class:"relative",onClick:e[3]||(e[3]=a=>B(1))},[c(h("div",j,[i(_,null,{default:n((()=>[i(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)])):b("",!0),q.value.name?(r(),d("div",{key:1,class:"relative",onClick:e[4]||(e[4]=a=>B(2))},[c(h("div",I,[i(_,null,{default:n((()=>[i(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)])):b("",!0)])])),_:1})])),_:1}),h("div",z,[i(l,{type:"primary",class:"w-40",onClick:G},{default:n((()=>[v("保存")])),_:1})])])),[[E,P.value]])])}}};export{E as default};
