Files
Dinger de3fd0945b v3.0.1
Signed-off-by: Dinger <quantdinger@gmail.com>
2026-04-06 23:19:41 +08:00

1 line
16 KiB
JavaScript

"use strict";(self["webpackChunkvue_antd_pro"]=self["webpackChunkvue_antd_pro"]||[]).push([[11],{40011:function(e,t,a){a.d(t,{A:function(){return m}});var r=function(){var e=this,t=e._self._c;return t("a-modal",{attrs:{title:e.$t("profile.exchange.addTitle"),visible:e.visible,"wrap-class-name":e.modalWrapClass,confirmLoading:e.savingExchange,okText:e.$t("common.save"),cancelText:e.$t("common.cancel"),maskClosable:!1,width:"520px"},on:{ok:e.handleSaveExchange,cancel:e.handleCancel}},[t("a-form",{staticClass:"exchange-account-form",attrs:{form:e.exchangeForm,layout:"vertical"}},[t("a-form-item",{attrs:{label:e.$t("profile.exchange.selectExchange")}},[t("a-select",{directives:[{name:"decorator",rawName:"v-decorator",value:["exchange_id",{rules:[{required:!0,message:e.$t("profile.exchange.selectExchange")}]}],expression:"['exchange_id', { rules: [{ required: true, message: $t('profile.exchange.selectExchange') }] }]"}],attrs:{placeholder:e.$t("profile.exchange.selectExchange"),"dropdown-class-name":e.isDarkTheme?"profile-exchange-select-dropdown-dark":"","get-popup-container":e.getExchangeSelectPopupContainer},on:{change:e.handleExchangeTypeChange}},[t("a-select-opt-group",{attrs:{label:e.$t("profile.exchange.typeCrypto")}},e._l(e.cryptoExchangeList,function(a){return t("a-select-option",{key:a.id,attrs:{value:a.id}},[e._v(" "+e._s(a.name)+" ")])}),1),t("a-select-opt-group",{attrs:{label:e.$t("profile.exchange.typeIBKR")}},[t("a-select-option",{attrs:{value:"ibkr"}},[e._v("Interactive Brokers (IBKR)")])],1),t("a-select-opt-group",{attrs:{label:e.$t("profile.exchange.typeMT5")}},[t("a-select-option",{attrs:{value:"mt5"}},[e._v("MetaTrader 5")])],1)],1)],1),t("a-form-item",{attrs:{label:e.$t("profile.exchange.accountName")}},[t("a-input",{directives:[{name:"decorator",rawName:"v-decorator",value:["name"],expression:"['name']"}],attrs:{placeholder:e.$t("profile.exchange.accountNamePlaceholder")}})],1),"crypto"===e.addExchangeType?t("a-form-item",{attrs:{label:e.$t("profile.exchange.whitelistIpLabel")}},[t("div",{staticClass:"egress-ip-block"},[e.egressIpLoading?t("a-spin",{attrs:{size:"small"}}):[t("div",{staticClass:"egress-ip-line"},[t("span",{staticClass:"egress-ip-kind"},[e._v(e._s(e.$t("profile.exchange.whitelistIpv4")))]),t("code",{staticClass:"egress-ip-value"},[e._v(e._s(e.egressServerIpv4||"—"))]),t("a-button",{staticClass:"egress-ip-action",attrs:{type:"link",size:"small",disabled:!e.egressServerIpv4},on:{click:function(t){return e.copyEgressIp("v4")}}},[e._v(" "+e._s(e.$t("profile.exchange.whitelistIpCopy"))+" ")])],1),t("div",{staticClass:"egress-ip-line"},[t("span",{staticClass:"egress-ip-kind"},[e._v(e._s(e.$t("profile.exchange.whitelistIpv6")))]),t("code",{staticClass:"egress-ip-value"},[e._v(e._s(e.egressServerIpv6||"—"))]),t("a-button",{staticClass:"egress-ip-action",attrs:{type:"link",size:"small",disabled:!e.egressServerIpv6},on:{click:function(t){return e.copyEgressIp("v6")}}},[e._v(" "+e._s(e.$t("profile.exchange.whitelistIpCopy"))+" ")])],1),t("div",{staticClass:"egress-ip-row egress-ip-refresh-row"},[t("a-button",{staticClass:"egress-ip-action",attrs:{type:"link",size:"small"},on:{click:e.fetchEgressIp}},[e._v(" "+e._s(e.$t("profile.exchange.whitelistIpRefresh"))+" ")])],1)]],2),t("div",{staticClass:"field-hint egress-ip-hint"},[e._v(e._s(e.$t("profile.exchange.whitelistIpHint")))])]):e._e(),"crypto"===e.addExchangeType?[e.selectedExchangeApiDocUrl?t("div",{staticClass:"exchange-api-doc-callout"},[t("div",{staticClass:"exchange-api-doc-callout__content"},[t("div",{staticClass:"exchange-api-doc-callout__icon"},[t("a-icon",{attrs:{type:"link"}})],1),t("div",{staticClass:"exchange-api-doc-callout__text"},[t("div",{staticClass:"exchange-api-doc-callout__title"},[e._v(" "+e._s(e.selectedCryptoExchangeName)+" "+e._s(e.$t("profile.exchange.apiDocTitleSuffix"))+" ")]),t("div",{staticClass:"exchange-api-doc-callout__hint"},[e._v(" "+e._s(e.$t("profile.exchange.apiDocHint"))+" ")])])]),t("a-button",{staticClass:"exchange-api-doc-callout__action",attrs:{type:"link",size:"small"},on:{click:e.openSelectedExchangeApiDoc}},[e._v(" "+e._s(e.$t("profile.exchange.apiDocAction"))+" "),t("a-icon",{attrs:{type:"arrow-right"}})],1)],1):e._e(),t("a-form-item",{attrs:{label:e.$t("profile.exchange.apiKey")}},[t("a-input-password",{directives:[{name:"decorator",rawName:"v-decorator",value:["api_key",{rules:[{required:!0,message:"API Key is required"}]}],expression:"['api_key', { rules: [{ required: true, message: 'API Key is required' }] }]"}],attrs:{placeholder:"API Key",autocomplete:"new-password"}})],1),t("a-form-item",{attrs:{label:e.$t("profile.exchange.secretKey")}},[t("a-input-password",{directives:[{name:"decorator",rawName:"v-decorator",value:["secret_key",{rules:[{required:!0,message:"Secret Key is required"}]}],expression:"['secret_key', { rules: [{ required: true, message: 'Secret Key is required' }] }]"}],attrs:{placeholder:"Secret Key",autocomplete:"new-password"}})],1),e.addExchangeNeedsPassphrase?t("a-form-item",{attrs:{label:e.$t("profile.exchange.passphrase")}},[t("a-input-password",{directives:[{name:"decorator",rawName:"v-decorator",value:["passphrase"],expression:"['passphrase']"}],attrs:{placeholder:"Passphrase",autocomplete:"new-password"}})],1):e._e(),e.addExchangeShowDemo?t("a-form-item",[t("a-checkbox",{directives:[{name:"decorator",rawName:"v-decorator",value:["enable_demo_trading",{valuePropName:"checked",initialValue:!1}],expression:"['enable_demo_trading', { valuePropName: 'checked', initialValue: false }]"}],staticClass:"exchange-demo-checkbox"},[t("span",{staticClass:"exchange-demo-checkbox-label"},[e._v(e._s(e.$t("profile.exchange.demoTrading")))])]),t("div",{staticClass:"field-hint exchange-demo-hint"},[e._v(e._s(e.$t("profile.exchange.demoTradingHint")))])],1):e._e()]:e._e(),"ibkr"===e.addExchangeType?[t("a-alert",{staticStyle:{"margin-bottom":"16px"},attrs:{type:"warning",showIcon:"",message:e.$t("profile.exchange.localDeploymentRequired"),description:e.$t("profile.exchange.localDeploymentHint")}}),t("a-form-item",{attrs:{label:e.$t("profile.exchange.ibkrHost")}},[t("a-input",{directives:[{name:"decorator",rawName:"v-decorator",value:["ibkr_host",{initialValue:"127.0.0.1"}],expression:"['ibkr_host', { initialValue: '127.0.0.1' }]"}],attrs:{placeholder:"127.0.0.1"}})],1),t("a-form-item",{attrs:{label:e.$t("profile.exchange.ibkrPort")}},[t("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["ibkr_port",{initialValue:7497}],expression:"['ibkr_port', { initialValue: 7497 }]"}],staticStyle:{width:"100%"},attrs:{min:1,max:65535}}),t("div",{staticClass:"field-hint"},[t("a-icon",{attrs:{type:"info-circle"}}),t("span",[e._v(e._s(e.$t("profile.exchange.ibkrPortHint")))])],1)],1),t("a-form-item",{attrs:{label:e.$t("profile.exchange.ibkrClientId")}},[t("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["ibkr_client_id",{initialValue:1}],expression:"['ibkr_client_id', { initialValue: 1 }]"}],staticStyle:{width:"100%"},attrs:{min:1,max:999}})],1),t("a-form-item",{attrs:{label:e.$t("profile.exchange.ibkrAccount")}},[t("a-input",{directives:[{name:"decorator",rawName:"v-decorator",value:["ibkr_account"],expression:"['ibkr_account']"}],attrs:{placeholder:"DU123456"}})],1)]:e._e(),"mt5"===e.addExchangeType?[t("a-alert",{staticStyle:{"margin-bottom":"16px"},attrs:{type:"warning",showIcon:"",message:e.$t("profile.exchange.localDeploymentRequired"),description:e.$t("profile.exchange.localDeploymentHint")}}),t("a-form-item",{attrs:{label:e.$t("profile.exchange.mt5Server")}},[t("a-input",{directives:[{name:"decorator",rawName:"v-decorator",value:["mt5_server",{rules:[{required:!0,message:"Server is required"}]}],expression:"['mt5_server', { rules: [{ required: true, message: 'Server is required' }] }]"}],attrs:{placeholder:"MetaQuotes-Demo"}})],1),t("a-form-item",{attrs:{label:e.$t("profile.exchange.mt5Login")}},[t("a-input-number",{directives:[{name:"decorator",rawName:"v-decorator",value:["mt5_login",{rules:[{required:!0,message:"Login is required"}]}],expression:"['mt5_login', { rules: [{ required: true, message: 'Login is required' }] }]"}],staticStyle:{width:"100%"},attrs:{min:1,placeholder:"12345678"}})],1),t("a-form-item",{attrs:{label:e.$t("profile.exchange.mt5Password")}},[t("a-input-password",{directives:[{name:"decorator",rawName:"v-decorator",value:["mt5_password",{rules:[{required:!0,message:"Password is required"}]}],expression:"['mt5_password', { rules: [{ required: true, message: 'Password is required' }] }]"}],attrs:{placeholder:"Password",autocomplete:"new-password"}})],1),t("a-form-item",{attrs:{label:e.$t("profile.exchange.mt5TerminalPath")}},[t("a-input",{directives:[{name:"decorator",rawName:"v-decorator",value:["mt5_terminal_path"],expression:"['mt5_terminal_path']"}],attrs:{placeholder:"C:\\Program Files\\MetaTrader 5\\terminal64.exe"}}),t("div",{staticClass:"field-hint"},[t("a-icon",{attrs:{type:"info-circle"}}),t("span",[e._v(e._s(e.$t("profile.exchange.mt5TerminalPathHint")))])],1)],1)]:e._e(),e.addExchangeType?t("a-form-item",[t("a-button",{attrs:{block:"",loading:e.testingExchange},on:{click:e.handleTestExchangeConnection}},[t("a-icon",{attrs:{type:"api"}}),e._v(" "+e._s(e.$t("profile.exchange.testConnection"))+" ")],1),e.exchangeTestResult?t("div",{staticClass:"test-result-msg",class:e.exchangeTestResult.success?"success":"error"},[t("a-icon",{attrs:{type:e.exchangeTestResult.success?"check-circle":"close-circle"}}),e._v(" "+e._s(e.exchangeTestResult.message)+" ")],1):e._e()],1):e._e()],2)],1)},s=[],i=a(81127),n=a(56252),c=a(76338),o=(a(74423),a(95353)),l=a(42430),p=a(36911),d={name:"ExchangeAccountModal",props:{visible:{type:Boolean,default:!1}},data:function(){return{savingExchange:!1,testingExchange:!1,exchangeTestResult:null,addExchangeType:"",selectedExchangeId:"",egressServerIpv4:"",egressServerIpv6:"",egressIpLoading:!1,cryptoExchangeList:[{id:"binance",name:"Binance",docsUrl:"https://www.binance.com/en/support/faq/detail/360002502072"},{id:"okx",name:"OKX",docsUrl:"https://www.okx.com/docs-v5/zh/#overview-v5-api-key-creation"},{id:"bitget",name:"Bitget",docsUrl:"https://www.bitget.com/api-doc/common/quick-start"},{id:"bybit",name:"Bybit",docsUrl:"https://www.bybit.com/en/help-center/article/How-to-create-your-API-key/"},{id:"coinbaseexchange",name:"Coinbase",docsUrl:"https://docs.cdp.coinbase.com/exchange/rest-api/authentication"},{id:"kraken",name:"Kraken",docsUrl:"https://support.kraken.com/articles/360000919966-how-to-create-an-api-key"},{id:"kucoin",name:"KuCoin",docsUrl:"https://www.kucoin.com/docs-new/authentication"},{id:"gate",name:"Gate.io",docsUrl:"https://www.gate.com/docs/developers/apiv4/"},{id:"bitfinex",name:"Bitfinex",docsUrl:"https://docs.bitfinex.com/docs/create-an-api-key"},{id:"deepcoin",name:"Deepcoin",docsUrl:"https://www.deepcoin.com/docs/authentication"},{id:"htx",name:"HTX",docsUrl:"https://www.htx.com/en-us/opend/newApiPages/?id=414"}]}},computed:(0,c.A)((0,c.A)({},(0,o.aH)({navTheme:function(e){return e.app.theme}})),{},{isDarkTheme:function(){return"dark"===this.navTheme||"realdark"===this.navTheme},modalWrapClass:function(){var e="profile-exchange-modal";return this.isDarkTheme?"".concat(e," ").concat(e,"--dark"):e},addExchangeNeedsPassphrase:function(){return["okx","bitget","kucoin"].includes(this.selectedExchangeId)},addExchangeShowDemo:function(){return"crypto"===this.addExchangeType&&!!this.selectedExchangeId},selectedCryptoExchangeMeta:function(){var e=this;return this.cryptoExchangeList.find(function(t){return t.id===e.selectedExchangeId})||null},selectedCryptoExchangeName:function(){return this.selectedCryptoExchangeMeta?this.selectedCryptoExchangeMeta.name:this.getExchangeDisplayName(this.selectedExchangeId)},selectedExchangeApiDocUrl:function(){return this.selectedCryptoExchangeMeta?this.selectedCryptoExchangeMeta.docsUrl:""}}),watch:{visible:function(e){e&&this.fetchEgressIp()}},beforeCreate:function(){this.exchangeForm=this.$form.createForm(this,{name:"exchangeAccountModal"})},methods:{getExchangeSelectPopupContainer:function(){return document.body},handleCancel:function(){this.$emit("update:visible",!1)},getExchangeDisplayName:function(e){var t={binance:"Binance",okx:"OKX",bitget:"Bitget",bybit:"Bybit",coinbaseexchange:"Coinbase",kraken:"Kraken",kucoin:"KuCoin",gate:"Gate.io",bitfinex:"Bitfinex",deepcoin:"Deepcoin",htx:"HTX",ibkr:"IBKR",mt5:"MetaTrader 5"};return t[e]||e},fetchEgressIp:function(){var e=this;return(0,n.A)((0,i.A)().m(function t(){var a,r,s,n;return(0,i.A)().w(function(t){while(1)switch(t.p=t.n){case 0:return e.egressIpLoading=!0,e.egressServerIpv4="",e.egressServerIpv6="",t.p=1,t.n=2,(0,l.N6)();case 2:a=t.v,1===a.code&&a.data&&(r=null!=a.data.ipv4?String(a.data.ipv4).trim():"",s=null!=a.data.ipv6?String(a.data.ipv6).trim():"",e.egressServerIpv4=r,e.egressServerIpv6=s,r||s||!a.data.ip||(n=String(a.data.ip).trim(),n.includes(":")?e.egressServerIpv6=n:e.egressServerIpv4=n)),t.n=4;break;case 3:t.p=3,t.v,e.egressServerIpv4="",e.egressServerIpv6="";case 4:return t.p=4,e.egressIpLoading=!1,t.f(4);case 5:return t.a(2)}},t,null,[[1,3,4,5]])}))()},copyEgressIp:function(e){var t=this,a="v6"===e?this.egressServerIpv6:this.egressServerIpv4;if(a){var r=function(){return t.$message.success(t.$t("profile.exchange.whitelistIpCopied"))};navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(a).then(r).catch(function(){return t._fallbackCopyText(a,r)}):this._fallbackCopyText(a,r)}},_fallbackCopyText:function(e,t){try{var a=document.createElement("textarea");a.value=e,a.style.position="fixed",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a),t&&t()}catch(r){this.$message.error(this.$t("profile.exchange.whitelistIpCopyFail"))}},handleExchangeTypeChange:function(e){this.selectedExchangeId=e,this.exchangeTestResult=null;var t=this.cryptoExchangeList.map(function(e){return e.id});t.includes(e)?this.addExchangeType="crypto":this.addExchangeType="ibkr"===e?"ibkr":"mt5"===e?"mt5":""},openSelectedExchangeApiDoc:function(){var e=this.selectedExchangeApiDocUrl;e&&window.open(e,"_blank")},handleSaveExchange:function(){var e=this;this.exchangeForm.validateFields(function(){var t=(0,n.A)((0,i.A)().m(function t(a,r){var s,n,o;return(0,i.A)().w(function(t){while(1)switch(t.p=t.n){case 0:if(!a){t.n=1;break}return t.a(2);case 1:return e.savingExchange=!0,t.p=2,s=(0,c.A)({},r),t.n=3,(0,l.PR)(s);case 3:n=t.v,1===n.code?(e.$message.success(e.$t("profile.exchange.saveSuccess")),e.$emit("update:visible",!1),e.exchangeForm.resetFields(),e.addExchangeType="",e.selectedExchangeId="",e.exchangeTestResult=null,e.$emit("success",n.data)):e.$message.error(n.msg||e.$t("profile.exchange.saveFailed")),t.n=5;break;case 4:t.p=4,o=t.v,e.$message.error(o.message||e.$t("profile.exchange.saveFailed"));case 5:return t.p=5,e.savingExchange=!1,t.f(5);case 6:return t.a(2)}},t,null,[[2,4,5,6]])}));return function(e,a){return t.apply(this,arguments)}}())},handleTestExchangeConnection:function(){var e=this;return(0,n.A)((0,i.A)().m(function t(){var a,r,s,n,o,l;return(0,i.A)().w(function(t){while(1)switch(t.p=t.n){case 0:if(a=e.exchangeForm.getFieldsValue(),r=a.exchange_id,r){t.n=1;break}return t.a(2);case 1:return e.testingExchange=!0,e.exchangeTestResult=null,t.p=2,s=(0,c.A)({},a),t.n=3,(0,p.kv)(s);case 3:n=t.v,1===n.code?e.exchangeTestResult={success:!0,message:e.$t("profile.exchange.testSuccess")}:(o=n.data&&n.data.hint_cn?" ".concat(n.data.hint_cn):"",e.exchangeTestResult={success:!1,message:"".concat(e.$t("profile.exchange.testFailed"),": ").concat(n.msg||"Unknown error").concat(o)}),t.n=5;break;case 4:t.p=4,l=t.v,e.exchangeTestResult={success:!1,message:"".concat(e.$t("profile.exchange.testFailed"),": ").concat(l.message||"Network error")};case 5:return t.p=5,e.testingExchange=!1,t.f(5);case 6:return t.a(2)}},t,null,[[2,4,5,6]])}))()}}},h=d,u=a(845),g=(0,u.A)(h,r,s,!1,null,null,null),m=g.exports},42430:function(e,t,a){a.d(t,{IA:function(){return n},N6:function(){return l},PR:function(){return c},kI:function(){return o}});var r=a(76338),s=a(75769),i={list:"/api/credentials/list",get:"/api/credentials/get",create:"/api/credentials/create",delete:"/api/credentials/delete",egressIp:"/api/credentials/egress-ip"};function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,s.Ay)({url:i.list,method:"get",params:e})}function c(e){return(0,s.Ay)({url:i.create,method:"post",data:e})}function o(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,s.Ay)({url:i.delete,method:"delete",params:(0,r.A)({id:e},t)})}function l(){return(0,s.Ay)({url:i.egressIp,method:"get"})}}}]);