import{u as a,fO as t,V as s,n as e,p as l,M as o,aC as n,$ as r}from"./utils-lib.js?v=1761009159";import{c as u,g as i,q as c,H as p,v as m,x as d,y as v,N as f,Q as y,D as h,z as w,I as g,e as b,B as j,C,G as x,b1 as _}from"./base-lib.js?v=1761009159";import{aL as V}from"./validator.js?v=1761009159";import{d as k,c as F,t as S,a as q,b as H,e as B,h as E,g as N,f as U,j as I}from"./useController17.js?v=1761009159";import{B as O}from"./index115.js?v=1761009159";import{u as z,S as D}from"./useStore4.js?v=1761009159";import{S as G}from"./useStore14.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./index106.js?v=1761009159";import"./column.js?v=1761009159";import"./ace.js?v=1761009159";import"./site.js?v=1761009159";const L={class:"h-full"},M={class:"w-full"},Q={class:"my-[12px]"},T=u({__name:"file",setup(u){const{viewFileHistoryEvent:T,recoverFileEvent:$}=G(),{siteInfo:A}=z(),{plugin:J}=a(),{saveFileEvent:K}=D(),P=()=>{const{BtTable:a}=t({request:()=>({data:E.value,total:E.value.length}),columns:[{label:"文件名",render:a=>s(Number(a))},{label:"操作",align:"right",render:a=>{let t=Number(a);return b("div",null,[b("span",{class:"cursor-pointer bt-link",onClick:()=>{W(a)}},[C("查看")]),b(_,{direction:"vertical"},null),b("span",{class:"cursor-pointer bt-link",onClick:()=>{R(t)}},[C("恢复")])])}}]});e({title:"配置文件历史版本",area:42,showFooter:!0,component:()=>b("div",{class:"p-[20px]"},[b(a,null,null)])})},R=async a=>{try{await l({title:"恢复历史文件",content:"是否恢复历史文件 ".concat(s(a))});const t=await $({row:a,path:X.value});return o.request({status:t.status,msg:t.status?"恢复成功":"恢复失败"}),t.status&&N({path:X.value}),t.status}catch(t){}},W=async a=>{await(async a=>{try{const t=await T({row:a,path:X.value});return U.value=t.status?t.data:"文件不存在",t}catch(t){return{status:!1,msg:"获取文件历史失败"}}})(a),e({title:"查看文件历史版本",area:64,showFooter:!1,component:()=>b("div",{class:"p-[20px]"},[b(x,{type:"primary",onClick:()=>R(a)},{default:()=>[C("恢复文件")]}),b(O,{class:"!h-[54rem] !w-full my-[12px]",modelValue:U.value,"onUpdate:modelValue":a=>U.value=a,editorOption:V({readonly:!0})},null)])})},X=i(()=>{const a="/www/server/panel/vhost/".concat(J.value.webserver,"/").concat(A.value.name,".conf");return"config"===k.value?a.replace(/\/+/g,"/"):F.value}),Y=async(a={data:B.value,encoding:"utf-8",path:X.value})=>{try{(await K(a)).status&&N({path:a.path})}catch(t){return{status:!1,msg:"保存文件失败"}}};return c(async()=>{I(),await N({path:X.value})}),(a,t)=>{const s=n,e=r,l=p("bt-loading");return m(),d("div",L,[v(F)?(m(),f(s,{key:0,type:"card",modelValue:v(k),"onUpdate:modelValue":t[0]||(t[0]=a=>y(k)?k.value=a:null),options:v(S),onChange:v(q)},null,8,["modelValue","options","onChange"])):h("",!0),w("div",M,[t[6]||(t[6]=w("span",{class:"my-[4px] text-secondary"},"提示：Ctrl+F 搜索关键字，Ctrl+S 保存，Ctrl+H 查找替换",-1)),w("div",Q,[g(b(v(O),{class:"!h-[54rem] rounded-base",modelValue:v(B),"onUpdate:modelValue":t[1]||(t[1]=a=>y(B)?B.value=a:null),request:!1,onSave:t[2]||(t[2]=a=>Y()),id:"configContent"},null,8,["modelValue"]),[[l,v(H)]])]),w("div",null,[b(v(x),{type:"primary",onClick:t[3]||(t[3]=a=>Y())},{default:j(()=>t[4]||(t[4]=[C("保存",-1)])),_:1,__:[4]}),b(v(x),{onClick:P,type:"default"},{default:j(()=>t[5]||(t[5]=[C("历史文件",-1)])),_:1,__:[5]})]),b(e,{options:[{content:"此处为站点主配置文件，若您不了解配置规则，请勿随意修改."}],"list-style":"none",class:"ml-[20px] mt-[20px]"})])])}}});export{T as default};
