← Back
Editing: add-form-legacy.js
!function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */e=function(){return n};var r,n={},o=Object.prototype,a=o.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",s=u.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(r){f=function(t,e,r){return t[e]=r}}function p(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),u=new G(n||[]);return i(a,"_invoke",{value:I(t,r,u)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}n.wrap=p;var d="suspendedStart",v="suspendedYield",y="executing",m="completed",g={};function b(){}function w(){}function x(){}var _={};f(_,c,(function(){return this}));var j=Object.getPrototypeOf,L=j&&j(j(N([])));L&&L!==o&&a.call(L,c)&&(_=L);var E=x.prototype=b.prototype=Object.create(_);function k(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function S(e,r){function n(o,i,u,c){var l=h(e[o],e,i);if("throw"!==l.type){var s=l.arg,f=s.value;return f&&"object"==t(f)&&a.call(f,"__await")?r.resolve(f.__await).then((function(t){n("next",t,u,c)}),(function(t){n("throw",t,u,c)})):r.resolve(f).then((function(t){s.value=t,u(s)}),(function(t){return n("throw",t,u,c)}))}c(l.arg)}var o;i(this,"_invoke",{value:function(t,e){function a(){return new r((function(r,o){n(t,e,r,o)}))}return o=o?o.then(a,a):a()}})}function I(t,e,n){var o=d;return function(a,i){if(o===y)throw Error("Generator is already running");if(o===m){if("throw"===a)throw i;return{value:r,done:!0}}for(n.method=a,n.arg=i;;){var u=n.delegate;if(u){var c=P(u,n);if(c){if(c===g)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var l=h(t,e,n);if("normal"===l.type){if(o=n.done?m:v,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=m,n.method="throw",n.arg=l.arg)}}}function P(t,e){var n=e.method,o=t.iterator[n];if(o===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=r,P(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var a=h(o,t.iterator,e.arg);if("throw"===a.type)return e.method="throw",e.arg=a.arg,e.delegate=null,g;var i=a.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,g):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function G(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function N(e){if(e||""===e){var n=e[c];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function t(){for(;++o<e.length;)if(a.call(e,o))return t.value=e[o],t.done=!1,t;return t.value=r,t.done=!0,t};return i.next=i}}throw new TypeError(t(e)+" is not iterable")}return w.prototype=x,i(E,"constructor",{value:x,configurable:!0}),i(x,"constructor",{value:w,configurable:!0}),w.displayName=f(x,s,"GeneratorFunction"),n.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,f(t,s,"GeneratorFunction")),t.prototype=Object.create(E),t},n.awrap=function(t){return{__await:t}},k(S.prototype),f(S.prototype,l,(function(){return this})),n.AsyncIterator=S,n.async=function(t,e,r,o,a){void 0===a&&(a=Promise);var i=new S(p(t,e,r,o),a);return n.isGeneratorFunction(e)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},k(E),f(E,s,"Generator"),f(E,c,(function(){return this})),f(E,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},n.values=N,G.prototype={constructor:G,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(T),!t)for(var e in this)"t"===e.charAt(0)&&a.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,o){return u.type="throw",u.arg=t,e.next=n,o&&(e.method="next",e.arg=r),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(c&&l){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;T(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:N(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),g}},n}function r(t,e,r,n,o,a,i){try{var u=t[a](i),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function n(t){return function(){var e=this,n=arguments;return new Promise((function(o,a){var i=t.apply(e,n);function u(t){r(i,o,a,u,c,"next",t)}function c(t){r(i,o,a,u,c,"throw",t)}u(void 0)}))}}System.register(["./utils-lib-legacy.js?v=VERSION_NUMBER","./form-item-legacy.js?v=VERSION_NUMBER","./column-legacy.js?v=VERSION_NUMBER","./index-legacy63.js?v=VERSION_NUMBER","./base-lib-legacy.js?v=VERSION_NUMBER","./index-legacy103.js?v=VERSION_NUMBER","./__commonjsHelpers__-legacy.js?v=VERSION_NUMBER","./index-legacy104.js?v=VERSION_NUMBER","./useController-legacy6.js?v=VERSION_NUMBER","./site-legacy.js?v=VERSION_NUMBER","./validator-legacy.js?v=VERSION_NUMBER","./useStore-legacy4.js?v=VERSION_NUMBER"],(function(t,r){"use strict";var o,a,i,u,c,l,s,f,p,h,d,v,y,m,g,b,w,x,_,j,L,E,k,S,I,P,O,T,G;return{setters:[function(t){o=t.G,a=t.p,i=t.n,u=t.M,c=t.iY,l=t.a6,s=t.iZ,f=t.w,p=t.e},function(t){h=t.k,d=t.b,v=t.h,y=t.f},function(t){m=t.a},function(t){g=t.a,b=t.b},function(t){w=t.c,x=t.r,_=t.e,j=t.T,L=t.B,E=t.ac,k=t.ag,S=t.af,I=t.q,P=t.v,O=t.x,T=t.i},function(t){G=t._},null,null,null,null,null,null],execute:function(){var r={class:"p-[2rem] node-master-mysql-add-form"};var N=w({__name:"add-form",props:{compData:{default:function(){return{panel_address:""}}}},setup:function(t,p){var w,N,q,M,A,B,F,z=p.expose,C=g(),D=C.mysqlRowData,V=C.isRefreshList,H=t,R=[{label:"面板自动同步",value:"auto",desc:"通过主库面板连接从库面板进行导入导出数据,简单快捷,建议内网机器使用"},{label:"手动同步到从库",value:"manual",desc:"通过主库面板备份,手动将备份文件上传至从库导入后进行数据还原后同步,大于1G数据建议使用此方法同步"}],Y=x({node_id:"",master_ip:(null==H||null===(w=H.compData)||void 0===w?void 0:w.panel_address)||"",slave_ip:"",err_code:["1062"],sync_type:"auto",db_name:""}),U=o({data:Y.value,options:[h("选择从库节点","node_id",D.value,{attrs:{placeholder:"请选择从库节点",class:"!w-[45rem]",onChange:function(t){var e;J.value.slave_ip=(null===(e=D.value.find((function(e){return e.value===t})))||void 0===e?void 0:e.remarks)||""}},rules:[{required:!0,message:"请选择从库节点",trigger:"change"}]}),d("主库IP地址","master_ip",{attrs:{placeholder:"请输入主库IP地址,如:192.168.1.100",class:"!w-[45rem]"},rules:[{required:!0,message:"请输入主库IP地址",trigger:["blur","change"]},{pattern:/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,message:"请输入正确的IP地址格式",trigger:["blur","change"]}]}),d("从库IP地址","slave_ip",{attrs:{placeholder:"请输入从库IP地址,如:192.168.1.101",class:"!w-[45rem]"},rules:[{required:!0,message:"请输入从库IP地址",trigger:["blur","change"]},{pattern:/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,message:"请输入正确的IP地址格式",trigger:["blur","change"]}]}),v(" ",(function(){return _(E,{modelValue:J.value.err_code,"onUpdate:modelValue":function(t){return J.value.err_code=t},class:"mb-[1.2rem]"},{default:function(){return[_(j,{value:"1062",key:"1062"},{default:function(){return[_("span",null,[L("跳过1062错误")]),_("div",{class:"err_code_desc"},[L("跳过主键或唯一键冲突错误")])]}})]}})}),"err_code"),(M=l({request:(q=n(e().mark((function t(r){var n,o;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.limit=50,t.next=3,s(r);case 3:return n=t.sent,(o=n.data).data[0].keys_scopes_status=!0,t.abrupt("return",{data:o.data,total:o.page.total_count});case 8:case"end":return t.stop()}}),t)}))),function(t){return q.apply(this,arguments)}),columns:[m({key:"id"}),{label:"数据库名称",prop:"name"},{label:"数据库大小",prop:"size",render:function(t){return _("span",null,[f(t.size)])}},{label:"数据库引擎",prop:"type"}]}),A=M.BtTable,B=M.BtPage,F=M.BtSearch,v("同步数据库",(function(){return _("div",{class:"w-[94.2%]"},[_(G,null,{"header-right":function(){return _(F,{placeholder:"请输入数据库名称",class:"!w-[20rem]"},null)},content:function(){return _(A,{height:"200px",onSelectionChange:(t=n(e().mark((function t(r){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,J.value.db_name=r.map((function(t){return t.name})).join(","),J.value.db_type=r.map((function(t){return t.type})).join(","),t.next=5,Z();case 5:t.next=10;break;case 7:t.prev=7,t.t0=t.catch(0);case 10:case"end":return t.stop()}}),t,null,[[0,7]])}))),function(e){return t.apply(this,arguments)})},null);var t},"footer-right":function(){return _(B,{layout:"prev, pager, next, total, jumper","page-size":50},null)}})])}),"db_name",{class:"node-master-mysql-db-table",rules:[{required:!0,message:"请选择要同步的数据库",trigger:"change"}]})),y(" ",[{content:"添加后仅同步选中的数据库数据,如需新增数据库需删除主从重新配置"}]),v("首次同步方式",(function(){var t,e;return _(S,{modelValue:J.value.sync_type,"onUpdate:modelValue":function(t){return J.value.sync_type=t}},"function"==typeof(e=t=R.map((function(t){return _(k,{class:"mt-[1rem]",value:t.value,key:t.value,style:{height:"auto",lineHeight:"1",alignItems:"flex-start"}},{default:function(){return[_("span",{class:"radio-label"},[t.label]),_("div",{class:"radio-desc mt-[1rem] mb-[1rem] w-[43rem]",style:{whiteSpace:"normal",lineHeight:"1.5"}},[t.desc])]}})})))||"[object Object]"===Object.prototype.toString.call(e)&&!T(e)?t:{default:function(){return[t]}})}),"sync_type")],submit:(N=n(e().mark((function t(r,n,o){var l,s;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,n();case 3:return t.next=5,a({icon:"warning-filled",title:"提示",content:"首次配置将会重启数据库,如从库有同名数据库将会进行数据覆盖,建议空闲时间配置,是否继续?"});case 5:t.next=11;break;case 7:return t.prev=7,t.t0=t.catch(0),t.abrupt("return",!1);case 11:if(!r.value.db_type.includes("MyISAM")){t.next=20;break}return t.prev=12,t.next=15,new Promise((function(t,e){i({title:"MyISAM 引擎警告",area:50,showFooter:!0,component:function(){return _("div",{class:"p-[2rem] text-[1.4rem]"},[_("div",{style:"color:#e53e3e;margin-bottom:8px;font-size: 1.4rem;"},[L("检测到选中的数据库包含 MyISAM 存储引擎的表,可能存在以下风险:")]),_("ul",{style:"margin-bottom:16px;list-style: disc;padding-left: 2rem;"},[_("li",null,[L("数据不一致:MyISAM 不支持事务,同步过程中可能出现数据不完整")]),_("li",null,[L("主从中断:表级锁定机制在高并发时内容易导致同步失败")]),_("li",null,[L("错误频发:需要设置错误跳过机制才能正常运行")])]),_("div",{style:"margin-bottom:2rem"},[_("div",{style:"margin-bottom:1rem"},[L("建议方案:")]),_("div",{style:"color:#22c55e; font-size: 1.4rem;margin-bottom:1rem"},[L("【推荐】转换为 InnoDB: ALTER TABLE table_name ENGINE=InnoDB")]),_("div",{style:"color:#2563eb; font-size: 1.4rem;"},[L("【备选】继续使用并设置错误跳过码(如: 1062)")])]),_("div",null,[L("确定要继续选择这些数据库吗?")])])},confirmText:"继续添加",cancelText:"取消",onConfirm:function(){return t(!0),!0},onCancel:function(){return e(),!1}})}));case 15:t.next=20;break;case 17:return t.prev=17,t.t1=t.catch(12),t.abrupt("return",!1);case 20:return l=u.load("正在添加主从,请稍后..."),t.prev=21,t.next=24,c(r.value);case 24:if(!(s=t.sent).status){t.next=31;break}return u.success("创建成功"),b(r.value.slave_ip),t.abrupt("return",!0);case 31:return u.error(s.msg),t.abrupt("return",!1);case 33:t.next=40;break;case 35:return t.prev=35,t.t2=t.catch(21),u.error("创建失败,请重试"),t.abrupt("return",!1);case 40:return t.prev=40,V.value=!0,l.close(),t.finish(40);case 44:case"end":return t.stop()}}),t,null,[[0,7],[12,17],[21,35,40,44]])}))),function(t,e,r){return N.apply(this,arguments)})}),$=U.BtForm,Z=U.validate,J=U.param,K=U.submit;return z({validate:Z,onConfirm:K,formData:J}),function(t,e){return I(),P("div",r,[_(O($))])}}});t("default",p(N,[["__scopeId","data-v-774616b6"]]))}}}))}();
Save File
Cancel