import{l as a,aa as e,am as t,a4 as l,$ as s,ac as i,x as n,M as o,af as r,a2 as c,_ as m}from"./utils-lib.js?v=20260328163632";import{u as d,v as p,w as u,x as y}from"./database.js?v=20260328163632";import{u as w}from"./store.js?v=20260328163632";import{k as b,r as v,o as I,V as h,W as k,O as M,a3 as f,Y as _,X as D,Z as R,U as g,l as A,N as B}from"./base-lib.js?v=20260328163632";import{D as O}from"./naive-ui.js?v=20260328163632";import"./__commonjsHelpers__.js?v=20260328163632";import"./env-lib.js?v=20260328163632";const x={class:"p-[16px]"},S={class:"mt-20px ml-[16px] leading-8 text-[1.2rem] list-disc"},j=m(b({__name:"index",props:{compData:{}},setup(m){const b=m,{tabActive:j}=w(),N=v([]),z=a=>a.Name,C=v(!1),E=v(a("数据库名称: -- 大小: 0")),T=async()=>{await n({request:d({id:b.compData.id,db_type:j.value}),success:e=>{K.value.data=e.data.table_list||[],E.value=a("数据库名称: {0} 大小: {1}",[e.data.database,t(e.data.total_size)||0])}})},q=async(e,t)=>{const l=o.load(a("正在操作表【{0}】，请稍后...",[e.Name])),s=await H(e,t);l.close(),o.request(s),T()},K=v({columns:[e(),{title:a("表名"),key:"Name",showOverflowTooltip:!0},{title:a("引擎"),key:"Engine",width:80},{title:a("字符集"),key:"Collation",showOverflowTooltip:!0},{title:a("行数"),align:"center",width:60,key:"Rows"},{title:a("大小"),key:"Data_length",width:90,render:a=>t(a.Data_length)},l([{onClick:a=>q(a,"Repair"),title:a("修复")},{onClick:a=>q(a,"Optimization"),title:a("优化")},{onClick:a=>q(a,"MyISAM"===a.Engine?"InnoDB":"MyISAM"),title:a("转换引擎"),width:70}])],data:[]}),[P,U]=s(K),Z=async(e,t,l,s)=>{let i={Repair:[a("修复"),""],Optimization:[a("优化"),a("，将回收未释放的磁盘空间，")],InnoDB:[a("转换引擎"),a("为【InnoDB】")],MyISAM:[a("转换引擎"),a("为【MyISAM】")]};const{label:n,value:o}=s;await e({title:a("批量{0}",[n]),content:a("批量{0}已选数据库表{1}，是否继续？",[i[o][0],i[o][1]]),column:[{key:"Name",title:a("表名")},r()],onConfirm:async()=>(await t((a=>H(a,o))),!1)})},H=async(e,t)=>{const{Name:l}=e;try{let a={id:b.compData.id,tables:JSON.stringify([l]),table_type:t};switch(["Repair","Optimization"].includes(t)&&delete a.table_type,t){case"Repair":return await y(a);case"Optimization":return await u(a);case"InnoDB":case"MyISAM":return await p(a)}}catch(s){return{status:!1,msg:a("操作失败")}}},{BtBatch:J}=i({tableRef:U,checkedRowKeys:N,options:[{label:a("修复"),value:"Repair",event:Z},{label:a("优化"),value:"Optimization",event:Z},{label:a("转为MyISAM"),value:"MyISAM",event:Z},{label:a("转为InnoDB"),value:"InnoDB",event:Z}]});return I(T),(e,t)=>{const l=O,s=g("bt-loading");return h(),k("div",x,[M(_(c),null,{"header-left":f((()=>[M(l,{title:_(E),bordered:!1,type:"default",closable:!1},null,8,["title"])])),content:f((()=>[A(M(_(P),{"max-height":350,"checked-row-keys":_(N),"onUpdate:checkedRowKeys":t[0]||(t[0]=a=>B(N)?N.value=a:null),"row-key":z},null,8,["checked-row-keys"]),[[s,_(C)]])])),"footer-left":f((()=>[M(_(J))])),_:1}),D("ul",S,[D("li",null,R(_(a)("【优化】执行OPTIMIZE命令，可回收未释放的磁盘空间，建议每月执行一次")),1),D("li",null,R(_(a)("【修复】尝试使用REPAIR命令修复损坏的表，仅能做简单修复，若修复不成功请考虑使用myisamchk工具")),1),D("li",null,R(_(a)("【转为InnoDB/MyISAM】转换数据表引擎，建议将所有表转为InnoDB")),1)])])}}}),[["__scopeId","data-v-e18f7e0d"]]);export{j as default};
