import{aP as s,P as r,iO as e,iP as a,p as t,cz as i,K as o}from"./utils-lib.js?v=1761009159";import{r as l,c as u,aA as n,g as c,e as d,C as m,c1 as p,q as _,v as g,N as v,y}from"./base-lib.js?v=1761009159";import{h as f,f as b}from"./form-item.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./index106.js?v=1761009159";const{refs:{settingData:h},getSet:w}=s(),x=l([]),U=["不使用加速",h.value.bad_registry_path],j=(s,r)=>{r(x.value)},L=u({__name:"index",props:{compData:{default:()=>({})}},setup(s,{expose:l}){const u=s,L=n("popupClose",()=>{}),{BtForm:R,submit:O,param:k}=o({data:()=>(s=>h.value.bad_registry?{registry_mirrors_address:h.value.bad_registry_path}:{registry_mirrors_address:""===s.compData.url||"未设置加速URL"===s.compData.url?"不使用加速":JSON.parse(JSON.stringify(s.compData.url))})(u),options:s=>c(()=>[f("加速URL",()=>d(p,{modelValue:s.value.registry_mirrors_address,"onUpdate:modelValue":r=>s.value.registry_mirrors_address=r,"fetch-suggestions":j,"popper-class":"my-urlautocomplete",placeholder:"请选择或输入加速URL"},{default:({item:t})=>{return d("div",{class:t.value===s.value.registry_mirrors_address?"flex items-center justify-between px-[2rem] bg-light":"flex items-center justify-between px-[2rem]"},[d("div",{class:t.value===s.value.registry_mirrors_address?"w-[38rem] truncate bt-link":"w-[38rem] truncate"},[t.label]),(i=t.value,!U.includes(i)&&d("span",{class:"bt-danger",onClick:s=>{s.stopPropagation(),(async s=>{try{await r({loading:"正在删除加速URL，请稍候...",request:e({data:JSON.stringify({registry_mirrors_address:s})}),message:!0,success:async s=>{if(s.status){const s=await a(),r=[];Object.entries(s.data.com_reg_mirrors).forEach(s=>{r.push({label:"".concat(s[0],"(").concat(s[1],")"),value:s[0]})}),x.value=r}}})}catch(t){}})(t.value)}},[m("删除")]))]);var i},suffix:()=>d("span",{class:"svgtofont-el-arrow-down"},null)}),"registry_mirrors_address",{rules:[{validator:(s,r,e)=>{r&&"不使用加速"!==r&&-1===r.indexOf("http")?e(new Error("请输入正确的加速URL,如https://docker.1ms.run")):e()},trigger:["blur","change"]}]}),b("",[{content:"可选择或手动输入加速URL"},{content:"优先使用加速URL执行操作，请求超时将跳过使用默认加速方式"},{content:"设置加速后需要手动重启docker"}])]),submit:async(s,e,a)=>{(async(s,e)=>{try{await t({title:"设置加速URL",content:"设置后需要重启docker，请确保可以重启docker再操作！"}),await r({loading:"正在设置加速URL，请稍候...",request:i({registry_mirrors_address:"不使用加速"===s.value.registry_mirrors_address?"":s.value.registry_mirrors_address}),message:!0,success:s=>{s.status&&(w(),e())}})}catch(a){}})(s,L)}});return _(()=>{x.value=[...h.value.options,{label:"不使用加速",value:"不使用加速"}],h.value.bad_registry&&x.value.unshift({label:"".concat(h.value.bad_registry_path,"(推荐)"),value:JSON.parse(JSON.stringify(h.value.bad_registry_path))})}),l({onConfirm:O}),(s,r)=>(g(),v(y(R),{class:"p-[1.6rem]"}))}});export{L as default};
