import{R as t,P as a,b as e,p as s,V as n,fO as o,n as r,$ as l,_ as i}from"./utils-lib.js?v=1761009159";import{r as c,p as u,c as m,q as p,H as d,v,x as f,z as y,I as h,y as w,e as x,Q as _,B as g,C as b,G as j,b1 as C}from"./base-lib.js?v=1761009159";import{aL as k}from"./validator.js?v=1761009159";import{setProxyConfig as S,recoverProxyConfig as V}from"./site.js?v=1761009159";import{u as F,S as H}from"./useStore4.js?v=1761009159";import{S as q}from"./useStore14.js?v=1761009159";import{B}from"./index115.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./index106.js?v=1761009159";import"./column.js?v=1761009159";import"./ace.js?v=1761009159";const I=e(),{siteInfo:O}=F(),{getFileEvent:E}=H();c("master"),c("server_block");c([{content:"保存前请检查输入的配置文件是否正确，错误的配置可能会导致网站访问异常"},{content:"如果您对此配置不熟悉，请勿添加自定义配置"},{isHtml:!0,content:'server块的nginx官方配置文档：<a class="text-primary cursor-pointer" href="https://nginx.org/en/docs/http/ngx_http_core_module.html#server" target="_blank" rel="noreferrer noopener">点击跳转</a>'}]),c("");const N=c(!1),U=async()=>{try{N.value=!0;const{data:a}=await E({path:"/www/server/panel/vhost/nginx/".concat(O.value.name,".conf")});z.value=a.data,t(a.historys)&&(D.value=a.historys),N.value=!1}catch(a){return{status:!1,msg:"获取配置文件失败"}}};u(()=>{I.error("主配置文件不允许修改，如需自定义配置请到上方自定义配置文件中操作")},3e3);const z=c(""),D=c(),G=c("");c(""),c(!1);const L=async()=>{try{a({loading:"正在保存，请稍后...",message:!0,request:S({site_name:O.value.name,conf_data:z.value}),success:U})}catch(t){}},P=async t=>{try{await s({title:"恢复历史文件",content:"是否恢复历史文件 ".concat(n(t))});const a=await V({filename:"/www/server/panel/vhost/nginx/".concat(O.value.name,".conf"),history:t,site_name:O.value.name});return I.request({status:a.status,msg:a.status?"恢复成功":"恢复失败"}),a.status&&U(),a.status}catch(a){}},Q={class:"w-full"},R={class:"my-[12px]"},T=i(m({__name:"index",props:{compData:{default:()=>({})}},setup(t,{expose:a}){const e=()=>{let t;const{BtTable:a}=o({request:()=>({data:D.value,total:D.value.length}),columns:[{label:"文件名",render:t=>n(Number(t))},{label:"操作",align:"right",render:a=>{let e=Number(a);return x("div",null,[x("span",{class:"cursor-pointer bt-link",onClick:()=>{s(a)}},[b("查看")]),x(C,{direction:"vertical"},null),x("span",{class:"cursor-pointer bt-link",onClick:async()=>{if(await P(e)){const a=await t;null==a||a.unmount()}}},[b("恢复")])])}}]});t=r({title:"配置文件历史版本",area:42,showFooter:!1,component:()=>x("div",{class:"p-[20px]"},[x(a,{"max-height":400},null)])})},s=async t=>{await(async t=>{try{const{viewFileHistoryEvent:a}=q(),e=await a({row:t,path:"/www/server/panel/vhost/nginx/".concat(O.value.name,".conf")});return G.value=e.status?e.data:"文件不存在",e}catch(a){return{status:!1,msg:"获取文件历史失败"}}})(t);const a=r({title:"查看文件历史版本",area:64,showFooter:!1,component:()=>x("div",{class:"p-[20px]"},[x(j,{type:"primary",onClick:async()=>{if(await P(t)){const t=await a;null==t||t.unmount()}}},{default:()=>[b("恢复文件")]}),x(B,{class:"!h-[50rem] !w-full my-[12px]",modelValue:G.value,"onUpdate:modelValue":t=>G.value=t,editorOption:k({readonly:!0})},null)])})};return p(()=>{U()}),a({init:U}),(t,a)=>{const s=l,n=d("bt-loading");return v(),f("div",null,[y("div",Q,[a[3]||(a[3]=y("span",{class:"my-[4px] text-secondary"},"提示：Ctrl+F 搜索关键字，Ctrl+S 保存，Ctrl+H 查找替换",-1)),y("div",R,[h(x(w(B),{class:"!h-[54rem] border border-base rounded-base",modelValue:w(z),"onUpdate:modelValue":a[0]||(a[0]=t=>_(z)?z.value=t:null),onSave:w(L),id:"configContent",editorOption:{mode:"ace/mode/nginx"}},null,8,["modelValue","onSave"]),[[n,w(N)]])]),y("div",null,[x(w(j),{type:"primary",onClick:w(L)},{default:g(()=>a[1]||(a[1]=[b("保存",-1)])),_:1,__:[1]},8,["onClick"]),x(w(j),{onClick:e,type:"default"},{default:g(()=>a[2]||(a[2]=[b("历史文件",-1)])),_:1,__:[2]})]),x(s,{options:[{content:"此处为站点主配置文件，若您不了解配置规则，请勿随意修改."}],"list-style":"disc",class:"ml-[20px] mt-[20px]"})])])}}}),[["__scopeId","data-v-cf5126d4"]]);export{T as default};
