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,e as r,f as d,g as u,i as o,p as m,t as g,j as p,b9 as v,T as x,h as f,H as h,v as E,K as y,L as w,N as b}from"./index.8821dc9f.1766672520393.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"},B={class:"flex relative flex-col items-center engBox"},I=["title","src","alt"],z=["title"],L=["onClick"],N={class:"flex gap-4 px-4 pt-3 items-center flex-wrap"},O={__name:"addSearchEngine",setup(O){const V=e({name:"",icon:"/static/searchEngine/net.svg",url:""}),H=a(),K=e(Object.assign([],H.state.searchEngine)),M=e([]);l({url:"/searchEngine/index"}).then((e=>{1===e.code&&(M.value=e.data)}));const R=e=>-1===K.value.findIndex((a=>a.name===e.name)),T=e=>{if(K.value.length>=20)return void b.warning("最大可以添加20个搜索引擎");K.value.findIndex((a=>a.name===e.name))>=0?b.warning("您已添加过该搜索引擎"):(K.value.push(e),A())},q=()=>{V.value.name.trim()&&V.value.url.trim()&&(T(Object.assign({},V.value)),V.value.name="",V.value.url="")},A=()=>{H.state.searchEngine=K.value,H.commit("updateSearchEngine")};return(e,a)=>{const l=s("el-icon"),O=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(K.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=K.value.findIndex((a=>a.name===e.name));K.value.splice(a,1),0===K.value.length&&b.warning("至少需要保留一个搜索引擎"),A()})(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(M.value,((e,a)=>(n(),d(x,null,{default:u((()=>[f(i("div",B,[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,I),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(h))])),_: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",N,[f(i("input",{class:"customEngineName",placeholder:"请输入引擎名称","onUpdate:modelValue":a[0]||(a[0]=e=>V.value.name=e)},null,512),[[y,V.value.name]]),f(i("input",{"onUpdate:modelValue":a[1]||(a[1]=e=>V.value.url=e),class:"customEngineUrl",placeholder:"自定义引擎URL，搜索词参数部分用{1}代替"},null,512),[[y,V.value.url]]),p(O,{onClick:q,class:"addCustom"},{default:u((()=>a[2]||(a[2]=[w("添加")]))),_:1})])])}}};export{O as default};
