import{_ as e}from"./index105.js?v=1761009159";import{aP as a,V as l,x as s,P as t,hx as o,hy as n,p as i,hz as u,hA as r,l as c,j as d,b as p}from"./utils-lib.js?v=1761009159";import{c as m,r as _,o as f,V as b,e as k,q as v,H as w,v as h,x as y,B as g,C as z,I as V,y as x,Q as C,z as j,R as q,J as D,A as U,N as F,D as R,G as A,b3 as H,ab as I,U as N,a9 as P}from"./base-lib.js?v=1761009159";import{d as B,u as G}from"./column.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./index106.js?v=1761009159";const J={class:"p-2rem"},L={class:"p-[2rem]"},Q={class:"flex items-center"},S=m({__name:"backup-view",props:{compData:{default:()=>{}}},setup(m){const S=m,{refs:{isRefreshInstallList:$}}=a(),E={"x-http-token":window.vite_public_request_token},K=_(!1),M=_(null),O=_(null),T=window.location.protocol+"//"+window.location.host+"/mod/docker/com/upload_backup",W=f({id:S.compData.id,restore_backup:!1,backup:!1,f_size:0,f_path:"/www/dk_project/backup/apps",f_name:"",f_start:0}),{id:X}=S.compData,Y=_(!1),Z=p(),ee=b([]),ae=b(!1),le=async()=>{t({request:o({id:X}),loading:ae,success:e=>{ee.value=e.data.data}})},se=async()=>{t({request:n({id:X}),loading:"正在备份中，请稍后...",message:!0,success:le})},te=async()=>{var e;if(W.f_name)return Y.value=Z.load("正在上传中，请稍后..."),await(null==(e=M.value)?void 0:e.submit()),!1;Z.error("请选择文件")},oe=e=>{var a;Z.request(e),K.value=!1,W.f_name="",le(),null==(a=Y.value)||a.close(),e.status&&(K.value=!1)},ne=e=>{W.f_size=e.size,W.f_name=e.name},ie=()=>{var e;Z.error("导入失败"),W.f_name="",null==(e=Y.value)||e.close(),le()},ue=()=>{O.value.$el.click()},re=()=>{var e;null==(e=M.value)||e.clearFiles(),K.value=!1,W.f_name="",W.restore_backup=!1},ce=[{label:"备份名称",prop:"file_name",width:160},{label:"类型",render:e=>k("span",null,["local"===e.backup_type?"本地":e.backup_type])},{label:"备份时间",width:140,render:e=>k("span",null,[l(Number(e.backup_time))])},B({prop:"backup_path",label:"备份目录"}),{label:"大小",render:e=>k("span",null,[s(e.size)])},G([{title:"恢复",onClick:async e=>{await i({content:"恢复备份将会覆盖已有数据，是否继续？",title:"恢复备份-"+e.file_name,icon:"warning-filled",type:"check",check:{content:"备份覆盖前的数据",onConfirm:async a=>{await t({request:r({id:X,file_name:e.file_name,backup:a}),loading:"正在恢复中，请稍后...",message:!0}),le(),$.value=!0}}})}},{title:"下载",onClick:async e=>{window.open("/download?filename="+e.backup_path+"/"+e.file_name,"_blank","noopener,noreferrer")}},{title:"删除",onClick:async e=>{await i({content:"即将删除备份文件，是否继续？",title:"删除备份-"+e.file_name,icon:"warning-filled"}),t({request:u({id:X,file_name:e.file_name}),loading:"正在删除中，请稍后...",message:!0,success:le})}}])];return v(le),(a,l)=>{const s=A,t=c,o=H,n=I,i=N,u=P,r=d,p=e,m=w("bt-loading");return h(),y("div",J,[k(p,null,{"header-left":g(()=>[k(s,{type:"primary",onClick:se},{default:g(()=>l[5]||(l[5]=[z("点击备份",-1)])),_:1,__:[5]}),k(s,{onClick:l[0]||(l[0]=e=>K.value=!0)},{default:g(()=>l[6]||(l[6]=[z("上传备份",-1)])),_:1,__:[6]})]),content:g(()=>[V(k(t,{column:ce,data:x(ee),"max-height":500},null,8,["data"]),[[m,x(ae)]])]),popup:g(()=>[k(r,{title:"上传文件",modelValue:x(K),"onUpdate:modelValue":l[4]||(l[4]=e=>C(K)?K.value=e:null),area:50,onConfirm:te,onCancel:re,showFooter:""},{default:g(()=>[j("div",L,[k(u,{ref:"cmdFormRef",size:"default",model:x(W),class:"relative w-full","label-position":"right",onSubmit:l[3]||(l[3]=q(()=>{},["prevent"]))},{default:g(()=>[k(n,{prop:"dep_zip",label:"上传文件"},{default:g(()=>[j("div",Q,[k(o,{class:"upload-demo h-[0] w-[0]",ref_key:"upload",ref:M,name:"blob",data:x(W),action:T,headers:E,accept:".zip,.gz,.tar","show-file-list":!1,"on-error":ie,multiple:!1,"auto-upload":!1,"on-success":oe,"on-change":ne},{default:g(()=>[V(k(s,{ref_key:"open",ref:O,size:"default",type:"default"},{default:g(()=>l[7]||(l[7]=[z(" 选择文件 ",-1)])),_:1,__:[7]},512),[[D,!1]])]),_:1},8,["data"]),k(s,{title:"导入项目",size:"default",class:"!mr-[.5rem]",onClick:ue},{default:g(()=>l[8]||(l[8]=[z(" 选择文件 ",-1)])),_:1,__:[8]}),j("span",null,U(x(W).f_name||"未选择"),1)])]),_:1}),k(n,{label:" "},{default:g(()=>[k(i,{modelValue:x(W).restore_backup,"onUpdate:modelValue":l[1]||(l[1]=e=>x(W).restore_backup=e)},{default:g(()=>l[9]||(l[9]=[z(" 是否立即导入备份文件 ",-1)])),_:1,__:[9]},8,["modelValue"])]),_:1}),x(W).restore_backup?(h(),F(n,{key:0,label:" "},{default:g(()=>[k(i,{modelValue:x(W).backup,"onUpdate:modelValue":l[2]||(l[2]=e=>x(W).backup=e)},{default:g(()=>l[10]||(l[10]=[z(" 是否备份覆盖前的数据 ",-1)])),_:1,__:[10]},8,["modelValue"])]),_:1})):R("",!0),l[11]||(l[11]=j("ul",{class:"mt-[.8rem] leading-8 text-small list-disc ml-[2rem]"},[j("li",null,"立即导入备份文件将覆盖现有文件数据，请做好相关数据备份")],-1))]),_:1,__:[11]},8,["model"])])]),_:1},8,["modelValue"])]),_:1})])}}});export{S as default};
