← Back
Editing: index63.js
import{K as e,eY as a,eZ as t,at as l,e_ as s,e$ as n,u as o,eP as r,M as i,n as u,L as c,p,a6 as m,w as d,R as _,f0 as v,f1 as b,aM as y,f2 as g,a7 as f,a8 as h,e as w,f3 as R,f4 as k,f5 as E,f6 as x,al as S}from"./utils-lib.js?v=VERSION_NUMBER";import{j as q,bJ as L,s as M,r as j,e as D,B as C,bM as O,bN as T,i as B,c as A,p as P,n as I,q as V,v as W,A as H,x as N,J as Y,M as z,P as Q}from"./base-lib.js?v=VERSION_NUMBER";import{_ as $}from"./index103.js?v=VERSION_NUMBER";import{c as G,u as F,a as J}from"./column.js?v=VERSION_NUMBER";import"./useController6.js?v=VERSION_NUMBER";const K=q("MASTER-STORE",(()=>({tabActive:L("nodeRedisTabActive","mysqlMaster")}))),U=q("MASTER-MYSQL-STORE",(()=>{const o=j(!1),r=j([]);return{deleteMysqlSlaveEvent:async t=>{try{let l={slave_ip:t.slave_ip};const s=await e({loading:"正在删除从库,请稍候...",request:a(l),message:!0});return{status:s.status,msg:s.msg}}catch(l){return{status:!1,msg:"删除从库失败"}}},multDeleteMysqlSlaveEvent:async(e,t,l,s)=>{const{label:n,value:r}=s,i=async(e,t)=>{if("delete"===r)return await a({slave_ip:e.slave_ip})};await e({title:"批量".concat(n,"从库"),content:"批量".concat(n,"已选的从库,是否继续操作!"),column:[{label:"从库地址",prop:"slave_ip"},G()],onConfirm:async()=>(await t(i),o.value=!0,!1)})},setMysqlSlaveEvent:async(e,a)=>{try{return await n({slave_ip:e.slave_ip,status:a})}catch(t){l(t)}},getMysqlSlaveHistoryEvent:async()=>{try{return await t()}catch(e){l(e)}},deleteMysqlSlaveHistoryEvent:async e=>{try{return await s(e)}catch(a){l(a)}},isRefreshList:o,mysqlRowData:r}})),Z=()=>({...U(),...M(U())});function X(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!B(e)}const{mysqlRowData:ee}=Z(),{plugin:ae,getGlobalInfo:te}=o(),le=async()=>{var a;const t=await te();await e({request:r(),loading:"正在获取节点数据,请稍等...",success:e=>{e.msg&&!1===e.status&&i.error(e.msg),ee.value=e.data.data.filter((e=>!e.is_local&&!e.lpver)).map((e=>({label:"".concat(e.remarks," - ").concat(e.server_ip),value:e.id,remarks:e.server_ip})))}}),u({title:"添加主从",area:62,compData:{panel_address:"object"==typeof t&&(null==(a=null==t?void 0:t.panel)?void 0:a.address)},btn:["添加","取消"],component:()=>c((()=>import("./add-form.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),showFooter:!0})},se=(e,a=!1)=>{const{openMasterSlaveLog:t}=oe();t(e,a)},ne=async e=>{await p({title:"".concat("start"===e.run_status?"停止":"启动","从库同步【").concat(e.slave_ip,"】"),content:"是否确认".concat("start"===e.run_status?"停止":"启动","从库同步【").concat(e.slave_ip,"】?")});const{setMysqlSlaveEvent:a,isRefreshList:t}=Z();await a(e,"start"===e.run_status?"stop":"start"),t.value=!0},oe=()=>({openMasterSlaveLog:async(e,a=!1)=>{let t=j();if(a&&"done"===e.config_status){const{data:a}=await v({slave_ip:e.slave_ip});t.value=a}else{if(b(e.error_msg))return void("done"!==e.config_status&&i.error("主从配置未完成,请先完成主从配置:操作 - 同步中"));t.value=e.error_msg}const l=i.load("正在获取日志信息,请稍后...");u({title:"从库状态日志",area:60,component:()=>{let a;return D("div",{class:"p-[1.6rem] max-h-[60rem] overflow-y-auto"},[D("div",{class:"mb-[1.6rem]"},[C("从库地址: "),e.slave_ip]),D(O,{column:1,border:!0},X(a=Object.entries(t.value).map((([e,a])=>{let t;return D(T,{label:e},X(t=String(a))?t:{default:()=>[t]})})))?a:{default:()=>[a]})])}}),null==l||l.close()}}),re=e=>{u({title:"同步进度",area:[60,"auto"],component:()=>c((()=>import("./index348.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),compData:{slave_ip:e}})},ie=w(A({__name:"index",setup(e){o();const{isRefreshList:a,multDeleteMysqlSlaveEvent:t}=Z(),{BtOperation:l}=y({options:[{type:"button",label:"添加主从",active:!0,onClick:le},{type:"button",label:"历史备份",active:!1,onClick:()=>{const{openHistoryBackup:e}=(()=>{const{getMysqlSlaveHistoryEvent:e,deleteMysqlSlaveHistoryEvent:a}=Z();return{openHistoryBackup:()=>{const{BtTable:t,refresh:l}=m({request:async()=>{const{data:a}=await e();return a.msg&&!1===a.status&&i.error(a.msg),{data:a.data,total:a.data.length}},columns:[{label:"文件名",prop:"name"},{label:"大小",prop:"size",render:e=>d(e.size)},{label:"创建时间",prop:"mtime",width:160,render:e=>_(e.mtime)},F([{title:"下载",onClick:e=>{window.open("/download?filename="+e.path)}},{title:"删除",onClick:async e=>{await p({title:"删除备份文件",content:"是否确认删除该备份文件?"});const{status:t,msg:s}=await a({path:e.path});t?(i.success(s),l()):i.error(s)}}])]});u({title:"主库历史备份文件",area:62,component:()=>D("div",{class:"p-[1.6rem]"},[D(t,{maxHeight:"40rem"},null)])})}}})();e()}}]}),s=h([{label:"删除从库",value:"delete",event:t}]),n=e=>({label:e.label,prop:e.prop,render:a=>{const t="function"==typeof e.status?e.status(a):a[e.prop];return e.render?e.render(a):D("span",{class:"bt-link ".concat(e.onClick?"cursor-pointer":""," ").concat(e.class?e.class(a):""),style:{color:"success"===t.type?"#20a53a":"#ef0808"},onClick:()=>{var t;null==(t=e.onClick)||t.call(e,a)}},[t.text])}}),{BtTable:r,BtSearch:v,BtRefresh:b,BtPage:w,BtColumn:R,BtBatch:k,refresh:E}=m({request:async e=>{const{data:a}=await g(e);return a.msg&&!1===a.status&&i.error(a.msg),{data:a.data,total:0,search:{}}},columns:[J({key:"slave_ip"}),{label:"从库地址",prop:"slave_ip",minWidth:220},{label:"同步中的数据库",prop:"db_name",render:e=>e.db_name},n({label:"读写状态",prop:"io_status",status:e=>({type:"Yes"===e.io_status&&"done"===e.config_status?"success":"danger",text:"done"!==e.config_status?"未开始":"Yes"===e.io_status?"正常":"异常"}),onClick:se}),n({label:"同步状态",prop:"sql_status",status:e=>({type:"Yes"===e.sql_status&&"done"===e.config_status?"success":"danger",text:"done"!==e.config_status?"未开始":"Yes"===e.sql_status?"正常":"异常"}),onClick:se}),n({label:"是否启用",prop:"run_status",status:e=>({type:"start"===e.run_status?"success":"danger",text:"start"===e.run_status?"已启用":"已停用"}),onClick:ne}),F([{render:e=>{const a="done"===e.config_status?"状态":"同步中";return D("span",null,[D("span",{onClick:()=>"done"===e.config_status?se(e,!0):re(e.slave_ip),title:a,class:"bt-link"},[a]),D("div",{class:"el-divider el-divider--vertical",role:"separator",style:"--el-border-style: solid;"},null)])}},{title:"删除",onClick:e=>(async e=>{const{deleteMysqlSlaveEvent:a,isRefreshList:t}=Z();await p({title:"".concat("删除mysql从库【".concat(e.slave_ip,"】")),content:"".concat("风险操作,此操作不可逆,删除【".concat(e.slave_ip,"】后您将无法管理该从库,是否继续操作?"))});const{status:l,msg:s}=await a(e);l?(i.success(s),t.value=!0):i.error(s)})(e)}])],extension:[s,f(a)],empty:()=>D("span",null,[C("您的列表为空,您可以"),D("span",{class:"bt-link",onClick:le},[C("添加一个主从")])])});return P((()=>{I((()=>{c((()=>import("./index349.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),c((()=>import("./index350.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url)}))})),(e,a)=>{const t=$;return V(),W("div",null,[D(t,null,{"header-left":H((()=>[D(N(l))])),"header-right":H((()=>[D(N(v),{class:Y(["mr-[10px]","!w-[210px]"]),placeholder:"请输入地址"}),D(N(b))])),content:H((()=>[D(N(r))])),"footer-left":H((()=>[D(N(k))])),"footer-right":H((()=>[D(N(w))])),_:1})])}}}),[["__scopeId","data-v-f67b8eeb"]]),ue=q("MASTER-REDIS-STORE",(()=>({isRedisRefreshList:j(!1),redisRowData:j([]),redisAvailableNodes:j({row:[],nodes:[]}),redisGroupDetail:j({}),openNodesLoading:j(!0),slaveListLoad:j(!0)}))),ce=()=>({...ue(),...M(ue())}),{isRedisRefreshList:pe,redisAvailableNodes:me,redisGroupDetail:de,openNodesLoading:_e,slaveListLoad:ve}=ce(),be=(e,a=2)=>{if("number"!=typeof e||isNaN(e))return"-";let t=(+(100*e).toFixed(a)).toString();return t.indexOf(".")>-1&&(t=t.replace(/\.0+$/,""),t=t.replace(/(\.[1-9]*)0+$/,"$1")),t+"%"},ye=async()=>{u({title:"新建主从复制组",area:60,btn:["创建","取消"],component:()=>c((()=>import("./index351.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url)});try{const{data:e}=await E();e.status||i.error(e.msg||"获取可用节点失败!"),me.value={row:e.data,nodes:e.data.map((e=>{var a;return{label:"".concat(e.name," - ").concat(e.server_ip," ").concat(null===e.group_info?"":"(主从组 - ".concat(null==(a=e.group_info)?void 0:a.group_name,")")),value:e.id,server_ip:e.server_ip,disabled:null!==e.group_info}}))}}catch(e){}finally{_e.value=!1}},ge=async(e,a,t,l)=>{const{label:s,value:n}=l,o=async(e,a)=>{if("delete"===n)return await k({group_id:e.group_id})};await e({title:"批量".concat(s),content:"批量删除选中的项目后,项目将无法恢复,是否继续操作?",column:[{label:"主从组名称",prop:"group_name"},G()],onConfirm:async()=>(await a(o),pe.value=!0,!1)})},fe=async e=>{u({title:"管理主从复制组【".concat(e.group_name,"】"),area:80,component:()=>c((()=>import("./index352.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),compData:{rowData:e}});const{data:a}=await R({group_id:e.group_id});a.status||i.error(a.msg||"获取主从复制组失败!"),de.value=a.data,ve.value=!1},he=(e,a)=>{var t,l,s;u({title:"".concat("slave"===a?"从节点详情【".concat(e.data.server_ip,"】"):"主节点详情【".concat(null==(s=null==(l=null==(t=e.value)?void 0:t.master_detail)?void 0:l.data)?void 0:s.address,"】")),area:70,component:()=>c((()=>import("./index353.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),compData:{rowData:e,type:a||"master"}})},we=async a=>{try{await p({icon:"warning-filled",title:"删除主从复制组【".concat(a.group_name,"】"),content:"即将删除主从复制组,是否继续操作?"}),await e({loading:"正在删除主从复制组,因需重新还原所有redis相关配置进行重启操作,过程可能较长请稍等...",request:k({group_id:a.group_id}),message:!0,success:e=>{pe.value=!0}})}catch(t){}},Re=async e=>{u({title:"创建主从复制组",area:60,component:()=>c((()=>import("./redis-create-log.js?v=VERSION_NUMBER")),__vite__mapDeps([]),import.meta.url),compData:{task_id:e}})};function ke(e,a="master"){var t,l,s,n,o,r,i,u,c,p,m,_,v,b,y,g,f,h,w,R,k,E,x,S,q,L,M,j,D,C;const O="master"==a?(null==(t=e.value)?void 0:t.master_detail.data)||{}:e.data||{},T=O.memory||{},B=O.performance||{},A=O.connections||{},P=O.replication||{},I=[{name:"base",label:"基础信息",items:[{label:"节点状态",value:"online"===O.status?"在线":"离线"},{label:"Redis版本",value:O.redis_version||"--"},{label:"运行天数",value:(null!=(l=O.uptime_days)?l:"--")+"天"},{label:"监听端口",value:null!=(s=O.port)?s:"--"},{label:"连接数",value:null!=(n=O.connected_slaves)?n:"--"},{label:"角色",value:null!=(o=O.role)?o:"--"}]},{name:"memory",label:"内存信息",items:[{label:"已使用内存",value:null!=(r=T.used_memory_human)?r:"--"},{label:"系统内存",value:T.max_memory?d(T.max_memory):"--"},{label:"内存使用率",value:null!=T.usage_percent?be(T.usage_percent):"--",tooltip:"计算方式:已使用内存/系统内存"}]},{name:"connection",label:"连接信息",items:[{label:"当前连接数",value:null!=(i=A.connected_clients)?i:"--"},{label:"总连接数",value:null!=(u=A.total_connections)?u:"--",tooltip:"仅记录TCP连接数"},{label:"最大连接数限制",value:null!=(c=A.max_clients)?c:"--"},{label:"拒绝连接数",value:null!=(p=A.rejected_connections)?p:"--"}]},{name:"performance",label:"性能统计",items:[{label:"当前QPS",value:null!=(m=B.qps)?m:"--"},{label:"总执行命令数",value:null!=(_=B.total_commands)?_:"--"},{label:"键命中次数",value:null!=(v=B.keyspace_hits)?v:"--"},{label:"键未命中次数",value:null!=(b=B.keyspace_misses)?b:"--"},{label:"命中率",value:null!=B.hit_rate?be(B.hit_rate):"--"}]}],V=[{name:"base",label:"基础信息",items:[{label:"Redis版本",value:O.redis_version||"--"},{label:"运行天数",value:(null!=(y=O.uptime_days)?y:"--")+"天"},{label:"监听端口",value:null!=(g=O.tcp_port)?g:"--"},{label:"角色",value:null!=(f=P.role)?f:"--"},{label:"主节点地址",value:null!=(h=P.master_host)?h:"--"},{label:"主节点端口",value:null!=(w=P.master_port)?w:"--"}]},{name:"memory",label:"内存信息",items:[{label:"已使用内存",value:null!=(R=T.used_memory_human)?R:"--"},{label:"系统内存",value:T.max_memory?d(T.max_memory):"--"},{label:"内存使用率",value:null!=T.usage_percent?be(T.usage_percent):"--"}]},{name:"connection",label:"连接信息",items:[{label:"当前连接数",value:null!=(k=A.connected_clients)?k:"--"},{label:"总连接数",value:null!=(E=A.total_connections)?E:"--"},{label:"阻塞连接数",value:null!=(x=A.rejected_connections)?x:"--"}]},{name:"replication",label:"复制信息",items:[{label:"主从连接状态",value:null!=(S=P.master_link_status)?S:"--"},{label:"最后IO时间",value:P.last_io_seconds?P.last_io_seconds+"秒前":"--"},{label:"同步进度",value:P.sync_in_progress?"是":"否"},{label:"复制偏移量",value:null!=(q=P.repl_offset)?q:"--"},{label:"复制延迟(秒)",value:null!=(L=P.lag)?L:"--"},{label:"是否在线",value:P.is_online?"是":"否"}]},{name:"performance",label:"性能统计",items:[{label:"当前QPS",value:null!=(M=B.qps)?M:"--"},{label:"总执行命令数",value:null!=(j=B.total_commands)?j:"--"},{label:"键命中次数",value:null!=(D=B.keyspace_hits)?D:"--"},{label:"键未命中次数",value:null!=(C=B.keyspace_misses)?C:"--"},{label:"命中率",value:null!=B.hit_rate?be(B.hit_rate):"--"}]}];return"master"==a?I:V}const Ee={class:"node-master-redis"},xe=A({__name:"index",setup(e){const{isRedisRefreshList:a}=ce(),t=h([{label:"删除主从组",value:"delete",event:ge}]),{BtOperation:l}=y({options:j([{type:"button",label:"新建主从复制组",active:!0,onClick:()=>ye()}])}),s=[J({key:"group_id"}),{label:"主从组名称",prop:"group_name",minWidth:120},{label:"主库地址",prop:"master_server_ip",minWidth:160},{label:"内存占用",prop:"memory_usage",minWidth:100,render:e=>D("span",{style:{color:e.memory_usage>=.95?"#fa1616":e.memory_usage>.8?"#ef8a08":"#20a53a"}},[be(e.memory_usage,0)])},{label:"QPS",prop:"qps",minWidth:80},{label:"连接数",prop:"connections",minWidth:80},{label:"从库数量",prop:"slave_count",minWidth:80},{label:"从库正常数",prop:"normal_slaves",minWidth:100,render:e=>D("span",{style:{color:e.normal_slaves<e.slave_count?"#ef0808":"#333"}},[e.normal_slaves])},{label:"平均延迟(秒)",prop:"avg_lag",minWidth:100},F([{title:"管理",onClick:fe},{title:"删除",onClick:we}])],{BtTable:n,BtBatch:o,BtSearch:r,BtRefresh:u,BtPage:c}=m({request:async e=>{const{data:a}=await x(e);return a.status||i.error(a.msg),{data:a.data,total:a.page.total_count,search:{}}},columns:s,extension:[t,f(a)],empty:()=>D("span",null,[C("您的列表为空,您可以"),D("span",{class:"bt-link",onClick:()=>ye()},[C("新建主从复制组")])])});return(e,a)=>{const t=$;return V(),W("div",Ee,[D(t,null,{"header-left":H((()=>[D(N(l))])),"header-right":H((()=>[D(N(r),{class:Y(["mr-[10px]","!w-[210px]"]),placeholder:"请输入名称或地址"}),D(N(u))])),content:H((()=>[D(N(n))])),"footer-left":H((()=>[D(N(o))])),"footer-right":H((()=>[D(N(c))])),_:1})])}}}),Se=[{label:"MySQL",name:"mysqlMaster",lazy:!0,render:()=>D(ie,null,null)},{label:"Redis",name:"redisMaster",lazy:!0,render:()=>D(xe,null,null)}],qe=A({__name:"index",setup(e){const{tabActive:a}=M(K());return(e,t)=>{const l=S;return V(),z(l,{class:"module-ui",type:"card",modelValue:N(a),"onUpdate:modelValue":t[0]||(t[0]=e=>Q(a)?a.value=e:null),options:N(Se)},null,8,["modelValue","options"])}}}),Le=Object.freeze(Object.defineProperty({__proto__:null,default:qe},Symbol.toStringTag,{value:"Module"}));export{Z as a,re as b,be as f,ke as g,he as h,Le as i,Re as o,ce as u}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { __vite__mapDeps.viteFileDeps = [] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) }
Save File
Cancel