← Back
Editing: index351.js
import{c as e,r as s,g as a,H as r,G as l,e as t,B as o,ac as i,T as d,aQ as n,aW as u,S as p,D as c,a4 as m,q as v,v as _,x as f,i as g}from"./base-lib.js?v=VERSION_NUMBER";import{G as x,a9 as b,x as w,M as h,iU as j,e as y}from"./utils-lib.js?v=VERSION_NUMBER";import{u as k,o as q}from"./index63.js?v=VERSION_NUMBER";import{b as C,k as R,h as I,f as P}from"./form-item.js?v=VERSION_NUMBER";import{a as S}from"./useController10.js?v=VERSION_NUMBER";import"./__commonjsHelpers__.js?v=VERSION_NUMBER";import"./index103.js?v=VERSION_NUMBER";import"./column.js?v=VERSION_NUMBER";import"./index104.js?v=VERSION_NUMBER";import"./useController6.js?v=VERSION_NUMBER";import"./site.js?v=VERSION_NUMBER";import"./validator.js?v=VERSION_NUMBER";import"./useStore4.js?v=VERSION_NUMBER";const V={class:"p-[2rem] master-redis-add-form"};const H=y(e({__name:"index",setup(e,{expose:y}){const{redisAvailableNodes:H,openNodesLoading:N}=k(),O=s(!1),{BtForm:U,param:B,submit:G}=x({data:{slave_node_ids:[]},options:e=>a((()=>[C("主从名称","group_name",{attrs:{placeholder:"请输入主从复制组名称",class:"!w-[46rem]"},rules:[{required:!0,message:"主从名称不能为空",trigger:["blur","change"]}]}),R("主节点选择","master_node_id",H.value.nodes||[],{attrs:{placeholder:"请选择主节点",class:"!w-[46rem]",loading:N.value,onChange:s=>{const a=H.value.nodes.find((e=>e.value===s));e.value.master_ip=a.server_ip,e.value.slave_node_ids=(e.value.slave_node_ids||[]).filter((e=>e!==s))}},rules:[{required:!0,message:"请选择主节点",trigger:["blur","change"]}]}),C("主节点IP","master_ip",{attrs:{placeholder:"请输入主节点IP地址",class:"!w-[46rem]"},rules:[{required:!0,...b()}]}),I("可用从节点",(()=>{let s;return r(t("div",{class:"slave-checkbox-list border w-full rounded p-[12px] max-h-[42rem] overflow-y-auto",style:{minHeight:N.value?"10rem":"auto"}},[!N.value&&!H.value.row.length&&t("div",{class:"text-[12px] text-[#a8abb2] leading-[12px]"},[o("暂无可用Redis从节点,请先在前往 节点管理 - "),t("span",{class:"bt-link",onClick:()=>location.href="/node/node-mgt"},[o("添加节点")])]),t(i,{modelValue:e.value.slave_node_ids,"onUpdate:modelValue":s=>e.value.slave_node_ids=s},(a=s=H.value.row.map((s=>{const a=t("span",{class:"text-[12px] flex-1"},[s.server_ip,o(" - "),s.name]);return t("div",{class:"flex justify-between items-center mb-[8px] last:mb-0",key:s.id},[t(d,{value:s.id,class:"mr-[8px]",disabled:s.id===e.value.master_node_id||s.is_in_replication_group},{default:()=>{var e;return[s.is_in_replication_group?t(n,{content:"节点已在主从组 - ".concat(null==(e=s.group_info)?void 0:e.group_name),placement:"top"},{default:()=>a}):a]}}),t("span",{class:"ml-[12px] text-[12px] px-[8px] py-[2px] leading-[22px] rounded",style:{background:1===S(s.redis_version,"7.0.0")?"#f6ffed":"#fff7e6",color:1===S(s.redis_version,"7.0.0")?"#52c41a":"#fa8c16"}},[o("Redis "),s.redis_version])])})),"function"==typeof a||"[object Object]"===Object.prototype.toString.call(a)&&!g(a)?s:{default:()=>[s]}))]),[[l("bt-loading"),N.value]]);var a}),"slave_node_ids",{rules:[{required:!0,trigger:["blur","change"],validator:(e,s,a)=>{if(!s||0===s.length)return O.value=!1,void a(new Error("请选择主从节点"));const r=H.value.row.filter((e=>s.includes(e.id))).map((e=>e.redis_version)),l=r.every((e=>e===r[0]));O.value=!l,a()}}]}),O.value&&I(" ",(()=>t(u,{"show-icon":!0,title:"警告:检测到版本不一致,建议使用相同版本的Redis节点",effect:"light",closable:!1,type:"warning"},null))),I("Redis密码",(()=>t("div",{class:"flex items-center w-full"},[t(p,{modelValue:e.value.redis_password,"onUpdate:modelValue":s=>e.value.redis_password=s,placeholder:"请输入Redis密码",class:"!w-[38rem]",type:"password","show-password":!0},null),t(c,{class:"ml-[8px]",type:"default",onClick:()=>e.value.redis_password=w(16)},{default:()=>[o("生成密码")]})])),"redis_password",{rules:[{required:!0,message:"Redis密码不能为空",trigger:["blur","change"]}]}),P(" ",[{content:"设置的密码将会覆盖当前redis密码"},{content:"redis密码建议使用包含字母、数字和特殊字符的复杂密码确保安全性"},{content:"如有安全组,请执行以下两步操作"},{content:"在主节点与从节点设置本机IP为白名单,放行6379端口"},{content:"在主节点机器,设置从节点IP为白名单,放行6379端口"}])])),submit:async(e,s,a)=>{let r=null;try{await s(),r=h.load("正在创建主从复制组,请稍候...");const a={...e.value,slave_node_ids:JSON.stringify(e.value.slave_node_ids)},l=await j(a);return l.data.status?(q(l.data.msg.task_id),h.success(l.data.msg.message)):h.error(l.data.msg||"创建主从复制组失败"),l.status}catch(l){return!1}finally{null==r||r.close()}}});return y({onConfirm:G}),m((()=>{H.value={row:[],nodes:[]},N.value=!0})),(e,s)=>(v(),_("div",V,[t(f(U))]))}}),[["__scopeId","data-v-515c307e"]]);export{H as default};
Save File
Cancel