import{k as a,a9 as e,c as t,r as s,o as l,V as r,W as n,O as i,a3 as o,j as u,Z as p,Y as c,a2 as m}from"./base-lib.js?v=20260328163632";import{u as d,l as v,Y as f,am as g,a4 as z,$ as b,a2 as k,v as y,z as _,x as h,di as j}from"./utils-lib.js?v=20260328163632";import{u as q}from"./store.js?v=20260328163632";import{A as x,C as w}from"./database.js?v=20260328163632";import{B as A}from"./naive-ui.js?v=20260328163632";import"./__commonjsHelpers__.js?v=20260328163632";import"./env-lib.js?v=20260328163632";const C=a({__name:"import",setup(a){const{panel:C,getGlobalInfo:D}=d(),{backupPath:T}=e(C.value),{isRefreshList:P,rowData:Y,tabActive:B}=q(),E=[{content:v("仅支持")+"sql、zip、(tar.gz|gz|tgz)"},{content:v("zip、tar.gz压缩包结构：test.zip或test.tar.gz压缩包内，必需包含test.sql")},{content:v("若文件过大，您还可以使用SFTP工具，将数据库文件上传到C:/backup/database")}],F=t((()=>T.value+"/database/"+B.value)),G=s(null),H=s({columns:[{title:v("文件名称"),key:"name"},{title:v("修改时间"),key:"mtime",width:150,render:a=>f(a.mtime)},{title:v("大小"),key:"size",render:a=>g(a.size)},z([{title:v("导入"),onClick:async a=>{await _({content:v("数据库【{0}】将被覆盖，是否继续?",[a.name]),title:v("导入数据库"),type:"calc"}),h({loading:v("正在导入数据库，请稍等..."),request:x({id:Y.value.id,db_type:B.value,path:(a.path+"/"+a.name).replace(/\\/g,"/")}),message:!0,success:a=>{a.status&&(R(),P.value=!0)}})}}])],data:[]}),[I,L]=b(H),O=async()=>{G.value=await j({title:v("上传文件到【{0}】",[F.value])+'<span class="text-danger>'.concat(v("请上传sql或zip或tar.gz压缩包"),"</span>"),accept:".sql,.zip,.tar.gz,.bak",path:"".concat(F.value),uploadEnd:()=>{R()}})},R=()=>{h({request:w({db_type:B.value}),data:Array,success:a=>{H.value.data=a||[]}})};return l((()=>{T.value||D(),R()})),(a,e)=>{const t=A;return r(),n("div",{class:"p-[20px]",onDragenter:e[0]||(e[0]=m((()=>{}),["prevent"])),onDragover:e[1]||(e[1]=m((a=>{return(e=a).preventDefault(),void((null==(t=null==e?void 0:e.dataTransfer)?void 0:t.items)&&Array.from(null==(s=null==e?void 0:e.dataTransfer)?void 0:s.items).some((a=>"file"===a.kind))&&(G.value||O()));var e,t,s}),["prevent"]))},[i(c(k),null,{"header-left":o((()=>[i(t,{onClick:O},{default:o((()=>[u(p(c(v)("从本地上传")),1)])),_:1})])),content:o((()=>[i(c(I),{"max-height":500})])),_:1}),i(c(y),{options:E})],32)}}});export{C as default};
