import{r as a,u as e,w as l,p as t,o as u,b as s,A as o,c as r,d,i,k as c,h as n,X as v,j as p,Q as m,e as h,ag as f,v as g,m as w,S as b,a6 as x}from"./index.1701946211972.js";import{u as y}from"./appSide.1701946211972.js";const _={class:"customBox"},V={class:""},k=h("span",{class:"ml-6 text-xs text-red-500"},"开启后会以程序内窗口形式打开，可能存在第三方禁止此方式访问",-1),j={class:"col-span-2 h-16 flex"},U={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 P=E,S=a(!1),A=a(1),B=a=>{A.value=a},Q=a(!1),X=e(),q={id:"",name:"",src:"",url:"",size:"1x1",type:"icon",sort:99999,app:0},D=a(Object.assign({},q));(null==(O=P.data)?void 0:O.id)&&(D.value=P.data);l(D.value,(a=>{}));const F=async()=>{Q.value=!0;try{const a=await b({url:"/linkStore/getIcon",method:"post",data:{url:D.value.url}});if(1===a.code)return D.value.src=a.data.src,D.value.name=a.data.name,void(Q.value=!1)}catch(a){}try{const a=await b({url:"/api/getIcon",method:"post",data:{url:D.value.url}});1===a.code?(D.value.src=a.data.src,D.value.name=a.data.name.substring(0,20)):x.error("获取网站数据失败,请手动设置")}catch(a){console.error("Error fetching data:",a),x.error("获取网站数据失败,请手动设置")}Q.value=!1},G=a=>{1===a.code?D.value.src=a.data.url:x.error(a.msg)},H=async()=>{if(""===D.value.name||""===D.value.url)return x.warning("请设置标签信息");if(Q.value=!0,"tab"===D.value.url.slice(0,3)||1===D.value.app||"http"!==D.value.url.slice(0,4)&&(D.value.url="http://"+D.value.url),2===A.value)try{const a=await b({url:"api/getIcon",method:"post",data:{avatar:D.value.name}});1===a.code&&(D.value.src=a.data.src)}catch(a){}""===D.value.id?(D.value.id=y(),X.state.link.push(D.value),X.commit("updateLink")):X.commit("setLink",D.value),Q.value=!1,t.emit("closePlugin"),S.value=!1};return t.on("linkEdit",((a=!1)=>{D.value=Object.assign({},q),a&&(D.value=a),S.value=!0})),u((()=>{t.off("linkEdit".open)})),(a,e)=>{const l=s("el-button"),t=s("el-input"),u=s("el-form-item"),b=s("el-switch"),x=s("el-upload"),y=s("el-icon"),E=s("el-form"),O=o("loading");return r(),d("div",_,[i((r(),d("div",V,[c(E,{"label-position":"right","label-width":"80px",class:"w-full pr-4 mt-4"},{default:n((()=>[c(u,{label:"标签网址"},{default:n((()=>[c(t,{modelValue:D.value.url,"onUpdate:modelValue":e[0]||(e[0]=a=>D.value.url=a),"show-word-limit":"",maxlength:"255",placeholder:"请输入带http开头的网址"},{append:n((()=>[c(l,{type:"primary",onClick:F},{default:n((()=>[v("获取图标")])),_:1})])),_:1},8,["modelValue"])])),_:1}),c(u,{label:"标签名称"},{default:n((()=>[c(t,{maxlength:"100","show-word-limit":"",modelValue:D.value.name,"onUpdate:modelValue":e[1]||(e[1]=a=>D.value.name=a),placeholder:"标签名称"},null,8,["modelValue"])])),_:1}),c(u,{label:"标签简介"},{default:n((()=>[c(t,{maxlength:"200","show-word-limit":"",type:"textarea",rows:"4",modelValue:D.value.tips,"onUpdate:modelValue":e[2]||(e[2]=a=>D.value.tips=a),placeholder:"简单介绍标签（非必填）"},null,8,["modelValue"])])),_:1}),c(u,{label:"网页APP"},{default:n((()=>[c(b,{"active-value":1,"inactive-value":0,modelValue:D.value.app,"onUpdate:modelValue":e[3]||(e[3]=a=>D.value.app=a)},null,8,["modelValue"]),k])),_:1}),c(u,{label:"标签Logo"},{default:n((()=>[c(t,{modelValue:D.value.src,"onUpdate:modelValue":e[4]||(e[4]=a=>D.value.src=a),placeholder:"请上传或粘贴标签图标地址"},{append:n((()=>[c(x,{class:"upload-demo","show-file-list":!1,"on-success":G,action:p(m)+p(X).state.site.upload},{default:n((()=>[c(l,{type:"primary"},{default:n((()=>[v("上传")])),_:1})])),_:1},8,["action"])])),_:1},8,["modelValue"])])),_:1}),c(u,{label:"选择Logo"},{default:n((()=>[h("div",j,[D.value.src?(r(),d("div",{key:0,class:"relative",onClick:e[5]||(e[5]=a=>B(1))},[i(h("div",U,[c(y,null,{default:n((()=>[c(p(f))])),_:1})],512),[[g,1===A.value]]),h("img",{src:D.value.src,class:"rounded-2xl mr-3 bg-slate-100",style:{width:"60px",height:"60px"},alt:""},null,8,C)])):w("",!0),D.value.name?(r(),d("div",{key:1,class:"relative",onClick:e[6]||(e[6]=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="+D.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",z,[c(l,{type:"primary",class:"w-40",onClick:H},{default:n((()=>[v("保存")])),_:1})])])),[[O,Q.value]])])}}};export{E as default};
