import{r as e,u as a,B as l,a as s,b as n,c as t,d as i,F as c,f as r,g as d,h as u,j as o,q as m,x as g,k as p,b1 as v,T as x,i as h,E as f,v as E,I as y,J as b,L as w}from"./index.51eb0e02.1749480002384.js";const k={class:"searchEngineUserManager"},F={class:"grid gap-4 mxs:grid-cols-4 grid-cols-8 items-center justify-center mt-4 myEngine"},_={class:"flex flex-col items-center relative engBox"},j=["title","src","alt"],C=["title"],S=["onClick"],U={class:"grid gap-4 mxs:grid-cols-4 grid-cols-8 items-center justify-center mt-6"},I={class:"flex relative flex-col items-center engBox"},B=["title","src","alt"],z=["title"],L=["onClick"],O={class:"flex gap-4 px-4 pt-3 items-center flex-wrap"},V={__name:"addSearchEngine",setup(V){const q=e({name:"",icon:"/static/searchEngine/net.svg",url:""}),J=a(),M=e(Object.assign([],J.state.searchEngine)),N=e([]);l({url:"/searchEngine/index"}).then((e=>{1===e.code&&(N.value=e.data)}));const R=e=>-1===M.value.findIndex((a=>a.name===e.name)),T=e=>{if(M.value.length>=20)return void w.warning("最大可以添加20个搜索引擎");M.value.findIndex((a=>a.name===e.name))>=0?w.warning("您已添加过该搜索引擎"):(M.value.push(e),D())},A=()=>{q.value.name.trim()&&q.value.url.trim()&&(T(Object.assign({},q.value)),q.value.name="",q.value.url="")},D=()=>{J.state.searchEngine=M.value,J.commit("updateSearchEngine")};return(e,a)=>{const l=s("el-icon"),V=s("el-button");return n(),t("div",k,[a[3]||(a[3]=i("div",{class:"mySearchEngine mt-4 ml-4 text-gray-800"}," 我的搜索引擎 ",-1)),i("div",F,[(n(!0),t(c,null,r(M.value,((e,a)=>(n(),d(x,null,{default:u((()=>[i("div",_,[i("img",{title:e.tips,style:{width:"50px",height:"50px","background-color":"#F3F3F3","border-radius":"6px",padding:"8px"},src:o(m)(e.icon),alt:e.name},null,8,j),i("span",{class:"mt-2 text-xs whitespace-nowrap",title:e.tips},g(e.name),9,C),i("div",{class:"search-del-ico",onClick:a=>(e=>{const a=M.value.findIndex((a=>a.name===e.name));M.value.splice(a,1),0===M.value.length&&w.warning("至少需要保留一个搜索引擎"),D()})(e)},[p(l,{color:"#fff",size:"16px"},{default:u((()=>[p(o(v))])),_:1})],8,S)])])),_:2},1024)))),256))]),a[4]||(a[4]=i("div",{class:"mySearchEngine mt-4 ml-4 text-gray-800"}," 未添加的搜索引擎 ",-1)),i("div",U,[(n(!0),t(c,null,r(N.value,((e,a)=>(n(),d(x,null,{default:u((()=>[h(i("div",I,[i("img",{title:e.tips,style:{width:"50px",height:"50px","background-color":"#F3F3F3","border-radius":"6px",padding:"8px"},src:o(m)(e.icon),alt:e.name},null,8,B),i("span",{class:"mt-2 text-xs whitespace-nowrap",title:e.tips},g(e.name),9,z),i("div",{class:"search-add-ico",onClick:a=>T(e)},[p(l,{color:"#fff",size:"16px"},{default:u((()=>[p(o(f))])),_:1})],8,L)],512),[[E,R(e)]])])),_:2},1024)))),256))]),a[5]||(a[5]=i("div",{class:"mySearchEngine mt-4 ml-4 text-gray-800"}," 自定义搜索引擎 ",-1)),i("div",O,[h(i("input",{class:"customEngineName",placeholder:"请输入引擎名称","onUpdate:modelValue":a[0]||(a[0]=e=>q.value.name=e)},null,512),[[y,q.value.name]]),h(i("input",{"onUpdate:modelValue":a[1]||(a[1]=e=>q.value.url=e),class:"customEngineUrl",placeholder:"自定义引擎URL，搜索词参数部分用{1}代替"},null,512),[[y,q.value.url]]),p(V,{onClick:A,class:"addCustom"},{default:u((()=>a[2]||(a[2]=[b("添加")]))),_:1})])])}}};export{V as default};
