← Back
Editing: index8.js
import{p as e,K as a,M as t,n as s,L as l,N as n,a3 as o,a4 as i,a5 as r,u,a6 as p,w as c,a7 as m,a8 as d,j as _,W as f}from"./utils-lib.js?v=VERSION_NUMBER";import{k as b,r as k,e as h,T as v,c as y,g as w,B as g,p as x,q as T,v as j,A as C,y as z,x as E,H as P,I as q,P as O,D as V,b0 as A,b3 as D,M as F}from"./base-lib.js?v=VERSION_NUMBER";import{_ as I}from"./index103.js?v=VERSION_NUMBER";import{a as S,d as H,u as B,o as L,c as M}from"./column.js?v=VERSION_NUMBER";import{i as R,d as N}from"./useMethod2.js?v=VERSION_NUMBER";import{Y as J,Z as U,_ as K,$ as W}from"./config.js?v=VERSION_NUMBER";import{p as Y,o as Z,d as $}from"./useMethod3.js?v=VERSION_NUMBER";import{restorePhpSiteData as G,restorePhpSiteDataLog as Q}from"./site.js?v=VERSION_NUMBER";import{_ as X}from"./index116.js?v=VERSION_NUMBER";const ee=async()=>{try{const{data:e}=await J();return{data:e.data,total:e.data.length,other:{}}}catch(e){}},ae=async e=>{window.open("/download?filename=".concat(e.backup_file),"_blank","noopener,noreferrer")},te=async t=>{try{await e({title:"删除备份",content:"是否删除备份文件?",type:"calc"}),await a({loading:"正在删除备份,请稍后...",request:U({timestamp:t.timestamp}),message:!0}),R.value=!0}catch(s){}},se=async(a,n)=>{if("confirm"===n){const l=k(!1);let n=0;await e({title:"还原备份",content:()=>h("div",null,[h("div",null,["网站【".concat(a.name,"】数据即将被覆盖,是否继续?")]),h("div",null,[h(v,{modelValue:l.value,"onUpdate:modelValue":e=>l.value=e,label:"还原网站配置文件"},null)])]),type:"calc"});try{G({id:a.id,reconf:l.value?"True":"False"});const e=y({setup(){const e=k("获取中..."),s=async()=>{clearTimeout(n);const l=await Q({pid:a.pid});e.value=l.log,l.restore_status?t.request(l):n=setTimeout((()=>{s()}),1500)};return s(),()=>h("div",{class:"flex-wrap"},[h(X,{class:"h-[40rem] !rounded-none",content:e.value},null)])}});s({title:"还原日志",component:()=>h(e,null,null),area:55})}catch(o){}}else{if(N.value={operateType:"restore",...a},"backup-running"===a.status)return void t.error("备份正在运行,请稍后再试");"restore-running"===a.status&&(Y.value=Z()),s({title:"还原备份",component:()=>l((()=>import("./index114.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),area:84,btn:["确定还原","取消"],showFooter:!0})}},le=async e=>{N.value={operateType:"detail",...e},s({title:"【".concat(e.backup_name,"】备份还原详情"),component:()=>l((()=>import("./detail-back.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),area:78})},ne=e=>{s({title:"上传文件",area:"72",component:()=>l((()=>import("./index115.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),compData:{path:"/www/backup/backup_restore"},onOpen:()=>{var e;const a=document.querySelector(".upload-files-tips");if(a){const t=document.createElement("ul");t.className="text-[#777] mt-[2px] leading-[2rem] text-[12px] ml-[20px] list-disc";const s=document.createElement("li");s.textContent="只有在此处备份的文件,才会在备份列表中显示",t.appendChild(s),null==(e=a.parentNode)||e.insertBefore(t,a.nextSibling)}},onCancel:()=>{e()}})},oe=async e=>{N.value={operateType:"log",...e},s({title:"备份日志",component:()=>l((()=>import("./log-back.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),area:60})},ie=b({backup_time:"",file_size:"",time_count:"",size:"",path:"","SHA-256":""}),re=async e=>{try{await K({timestamp:e.timestamp});Y.value=Z()}catch(a){}},ue=k(),pe=k(!1),ce=async()=>{try{$.value=!0;const e={timestamp:N.value.timestamp,type:be.value},{data:{data:a}}=await W(e);ie.time_count=a.total_time,ie.size=a.backup_file_size,ie["SHA-256"]=a.backup_file_sha256,ie.path=a.backup_file,ie.backup_time=a.done_time,ue.value=a.data_status;const t=me(a.data_status);return{data:t,total:t.length,other:{}}}catch(e){}finally{$.value=!1}},me=e=>{const a={ssh_list:"防火墙",crontab_list:"计划任务",term_list:"终端",database_list:"数据库",site_list:"网站",ftp_list:"FTP",plugin_list:"插件",env_list:"运行环境"},t=Object.keys(e);let s=[];return t.forEach((t=>{if(n(e[t])&&e[t].length>0){let a=e[t].filter((e=>e.status&&3===e.status));a.length>0&&a.forEach((e=>{s.push({name:e.name,msg:e.err_msg||"未知错误"})}))}else o(e[t])&&3===e[t].status&&s.push({name:a[t],msg:e[t].err_msg||"未知错误"})})),s};k(!1),k([]),k([]),k([]),k([]),k([]),k([]);const de=k(!1),_e=k(0),fe=async e=>{try{let a=new FormData;a.append("blob",e.file),a.append("f_size",e.data.f_size),a.append("f_path",e.data.f_path),a.append("f_name",e.data.f_name),a.append("f_start",e.data.f_start);let s={headers:{"Content-Type":"multipart/form-data","x-http-token":window.vite_public_request_token}};const l=await i.post("/files?action=upload",a,s);r(l.data)?(de.value||(de.value=!0),_e.value=Math.floor(l.data/e.data.f_size*100),fe(e)):(de.value=!1,t.request(l.data))}catch(a){t.error("导入失败"),de.value=!1,R.value=!0}},be=k("backup"),ke=async()=>{N.value={operateType:"add"},s({title:"创建备份",area:84,showFooter:!0,component:()=>l((()=>import("./index114.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),btn:["备份","取消"]})},he={database:"数据库",site:"网站",ftp:"FTP",crontab:"计划任务",term:"终端",firewall:"防火墙",plugin:"插件",other:"其他",runtime:"运行环境"};k(Object.keys(he).reduce(((e,a)=>(e[a]={name:he[a],list:[]},e)),{}));const ve={class:"flex items-center"},ye={class:"p-[20px]"},we=y({__name:"index",setup(e){const{panel:a}=u(),s=d([{label:"删除",value:"delete",event:async(e,a,t,s,l,n)=>{const o=async(e,a)=>await U({timestamp:e.timestamp});await e({title:"删除备份",column:[{label:"备份名称",prop:"backup_name"},M()],content:"删除后不可恢复,确定删除吗?",onConfirm:async()=>(await a(o),R.value=!0,!1)})}}]),{BtTable:l,BtBatch:n,BtRefresh:o}=p({request:ee,columns:w((()=>[S({key:"timestamp"}),{label:"备份名称",prop:"backup_name"},{label:"状态",render:e=>{const a=1===e.backup_status||1===e.restore_status,t=0===e.backup_status,s=1===e.restore_status,l=h("div",null,[h("span",null,[g("成功("),e.backup_count.success||0,g(")")]),h("span",{class:"!ml-[4px]"},[g("失败("),e.backup_count.failed||0,g(")")])]),n=a||t;return h("div",{class:"inline-flex items-center"},[h("span",{style:"background:".concat(e.backup_count.failed?"#ef0808":"#20a53a"),class:"rounded-full w-[6px] h-[6px] mr-[4px] ".concat(n?"!hidden":"")},null),a&&h("span",{class:"ml-2px text-[#f1951d] cursor-pointer",onClick:()=>{N.value.operateType=s?"restore":"backup",Y.value=Z()}},[s?"还原中":"备份中"]),t&&h("span",{class:"ml-2px text-[#999]"},[g("等待备份")]),!a&&!t&&l])}},H({prop:"backup_path",label:"备份文件"}),{label:"备份大小",prop:"backup_file_size",sortable:!0,render:e=>h("span",null,[c(Number(e.backup_file_size))])},{label:"备份时间",prop:"backup_time",sortable:!0},{label:"创建时间",prop:"create_time",sortable:!0},B([{title:"立即备份",width:70,onClick:re,isHide:e=>0!==e.backup_status&&1!==e.backup_status},{title:"下载",onClick:ae,isHide:e=>0===e.backup_status||1===e.backup_status},{title:"还原",onClick:se,isHide:e=>0===e.backup_status||1===e.backup_status},{title:"详情",onClick:le},{title:"日志",onClick:oe},{title:"删除",onClick:te}])])),extension:[m(R),s],empty:()=>h("span",null,[g("您的列表为空,您可以"),h("span",{class:"bt-link",onClick:ke},[g("创建一个备份")])])}),i={"x-http-token":window.vite_public_request_token},r=k(null),v=k(null),y=b({f_size:0,f_path:"/www/backup/backup_restore/",f_name:"",f_start:0}),F=e=>{y.f_size=e.size,y.f_name=e.name},J=(e,a,s)=>{t.error("导入失败"),de.value=!1,R.value=!0},K=(e,a,t)=>{de.value=!1,R.value=!0};return x((()=>{window.openFilePath=()=>L({path:"/www/backup/whole_machine_backup"}),setTimeout((()=>{const e=localStorage.getItem("hasJump");a.value.migration&&e&&(Z("restore"),localStorage.removeItem("hasJump"))}),1e3)})),(e,a)=>{const t=V,s=A,u=I,p=D,c=_,m=f;return T(),j("div",null,[h(u,null,{"header-left":C((()=>[z("div",ve,[h(s,{class:"upload-demo h-[0] w-[0]",ref_key:"upload",ref:r,name:"blob",data:E(y),action:"#",headers:i,"http-request":E(fe),accept:".tar,.gz","show-file-list":!1,multiple:!1,"auto-upload":!0,"on-error":J,"on-success":K,"on-change":F},{default:C((()=>[P(h(t,{ref_key:"open",ref:v,size:"default",type:"default"},{default:C((()=>a[2]||(a[2]=[g(" 选择文件 ")]))),_:1},512),[[q,!1]])])),_:1},8,["data","http-request"]),h(t,{type:"primary",onClick:E(ke)},{default:C((()=>a[3]||(a[3]=[g("创建备份")]))),_:1},8,["onClick"]),h(t,{onClick:a[0]||(a[0]=e=>E(ne)(K))},{default:C((()=>a[4]||(a[4]=[g("上传文件")]))),_:1}),a[5]||(a[5]=z("span",{class:"text-[#999] ml-4px"},"上传格式为.tar,.gz文件",-1))])])),"header-right":C((()=>[h(E(o))])),content:C((()=>[h(E(l))])),"footer-left":C((()=>[h(E(n))])),_:1}),h(c,{modelValue:E(de),"onUpdate:modelValue":a[1]||(a[1]=e=>O(de)?de.value=e:null),area:52,title:!1},{default:C((()=>[z("div",ye,[a[6]||(a[6]=z("span",{class:"mb-[0.8rem]"},null,-1)),h(p,{"text-inside":!0,"stroke-width":20,percentage:E(_e)},null,8,["percentage"])])])),_:1},8,["modelValue"]),h(m,{class:"mt-[1rem]",options:[{isHtml:!0,content:"9.5以前版本的备份还原不会在备份列表中显示,如有需要请<span class='bt-link' onClick='openFilePath()'>点击查看</span>"}]})])}}}),ge=y({__name:"index",setup:e=>(e,a)=>(T(),F(we))}),xe=Object.freeze(Object.defineProperty({__proto__:null,default:ge},Symbol.toStringTag,{value:"Module"}));export{ue as a,ie as b,be as d,ce as g,xe as i,pe as s}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { __vite__mapDeps.viteFileDeps = [] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) }
Save File
Cancel