import{P as a,p as e,M as t,k as s,e as l,$ as i}from"./utils-lib.js?v=1761009159";import{c as n,o as r,r as d,q as o,H as m,I as c,y as u,v as p,x as _,e as f,B as y,z as g,C as w,an as I,ab as b,G as x,a9 as h}from"./base-lib.js?v=1761009159";import{r as P,af as k}from"./config.js?v=1761009159";import{g as v}from"./useStore.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";const V={class:"p-[2rem]"},j={class:"w-[32rem]"},A={class:"w-[32rem]"},q={class:"text-secondary h-[2.4rem]"},C=n({__name:"api-config",setup(n){const{refs:{panelConfig:C}}=v(),z=r({token:"",limit_addr:""}),H=d(!1),S=d("正在获取API配置，请稍候..."),U=async()=>{await a({loading:H,request:P({t_type:2}),message:!0})},R=async()=>{try{await e({icon:"warning-filled",title:"重置密钥",isHtml:!0,content:'\n\t\t\t<p>您确定要重置当前密钥吗？</p>\n\t\t\t<p class="text-danger">\t重置密钥后，已关联密钥产品，将失效，请重新添加新密钥至产品。</p>'}),S.value="正在重置密钥，请稍候...",await a({loading:H,request:P({t_type:1}),message:!1,success:a=>{a.status?z.token=a.msg:t.error(a.msg)}})}catch(s){}},B=async()=>{S.value="正在设置API配置，请稍候...",await a({loading:H,request:P({t_type:3,limit_addr:z.limit_addr}),message:!0})};return o(()=>{(async()=>{const e=await a({loading:H,request:k(),data:{limit_addr:String,token:String}});z.token=e.token,z.limit_addr=e.limit_addr})()}),(a,e)=>{const t=I,n=b,r=x,d=s,o=h,P=l,k=i,v=m("bt-loading");return c((p(),_("div",V,[f(o,null,{default:y(()=>[f(n,{label:"API接口"},{default:y(()=>[f(t,{modelValue:u(C).apiInterface,"onUpdate:modelValue":e[0]||(e[0]=a=>u(C).apiInterface=a),onChange:U},null,8,["modelValue"])]),_:1}),f(n,{label:"接口密钥"},{default:y(()=>[g("div",j,[f(d,{modelValue:u(z).token,"onUpdate:modelValue":e[1]||(e[1]=a=>u(z).token=a),type:"text",readonly:""},{suffix:y(()=>[f(r,{type:"primary",size:"small",onClick:R},{default:y(()=>e[3]||(e[3]=[w(" 重置 ",-1)])),_:1,__:[3]})]),_:1},8,["modelValue"])])]),_:1}),f(n,null,{label:y(()=>e[4]||(e[4]=[g("div",{class:"py-8px leading-[1.4]"},[g("div",{class:"pr-6px"},"IP白名单"),g("div",null,"(每行一个)")],-1)])),default:y(()=>[g("div",A,[f(d,{modelValue:u(z).limit_addr,"onUpdate:modelValue":e[2]||(e[2]=a=>u(z).limit_addr=a),type:"textarea",resize:"none",autosize:{minRows:4,maxRows:4}},null,8,["modelValue"])])]),_:1}),f(n,{label:" "},{default:y(()=>[f(r,{type:"primary",onClick:B},{default:y(()=>e[5]||(e[5]=[w("保存",-1)])),_:1,__:[5]})]),_:1})]),_:1}),f(k,{class:"my-20px"},{default:y(()=>[e[8]||(e[8]=g("li",{class:"text-secondary h-[2.4rem]"},"IP白名单支持格式：",-1)),e[9]||(e[9]=g("li",{class:"text-secondary h-[2.4rem]"},"单IP：（192.168.1.1），IP段：（192.168.1.1-192.168.1.255），所有IP：（*）",-1)),e[10]||(e[10]=g("li",{class:"text-secondary h-[2.4rem]"},"开启API后，必需在IP白名单列表中的IP才能访问面板API接口",-1)),e[11]||(e[11]=g("li",{class:"text-danger h-[2.4rem]"},"请不要在生产环境开启，这可能增加服务器安全风险；",-1)),g("li",q,[e[7]||(e[7]=w(" API接口文档在这里： ",-1)),f(P,{href:"https://www.bt.cn/bbs/thread-20376-1-1.html"},{default:y(()=>e[6]||(e[6]=[w(" https://www.bt.cn/bbs/thread-20376-1-1.html ",-1)])),_:1,__:[6]})])]),_:1,__:[8,9,10,11]})])),[[v,u(H)],[v,u(S),"title"]])}}});export{C as default};
