diff --git a/jeepay-ui-merchant/package-lock.json b/jeepay-ui-merchant/package-lock.json index 990fabba346f4b761cf410f72c2ff5e5ee948b35..0b6b9bf3a06adae418500748146c48a05738f8e4 100644 --- a/jeepay-ui-merchant/package-lock.json +++ b/jeepay-ui-merchant/package-lock.json @@ -16603,6 +16603,11 @@ "util.promisify": "^1.0.0" } }, + "reconnectingwebsocket": { + "version": "1.0.0", + "resolved": "https://registry.npm.taobao.org/reconnectingwebsocket/download/reconnectingwebsocket-1.0.0.tgz", + "integrity": "sha1-C4Jbq7N7ZwRFxlqn0+2XgwAgVEQ=" + }, "redent": { "version": "1.0.0", "resolved": "https://registry.nlark.com/redent/download/redent-1.0.0.tgz?cache=0&sync_timestamp=1620069780522&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fredent%2Fdownload%2Fredent-1.0.0.tgz", diff --git a/jeepay-ui-merchant/package.json b/jeepay-ui-merchant/package.json index 86611fe75c9fddd0a60dcd5223d5924663e3ac68..f2d421d487e282156380694b40f6bb18b5e1acdc 100644 --- a/jeepay-ui-merchant/package.json +++ b/jeepay-ui-merchant/package.json @@ -37,7 +37,8 @@ "vue-svg-component-runtime": "^1.0.1", "vuex": "^3.1.1", "wangeditor": "^3.1.1", - "js-base64": "^2.5.2" + "js-base64": "^2.5.2", + "reconnectingwebsocket": "^1.0.0" }, "devDependencies": { "@ant-design/colors": "^3.2.1", diff --git a/jeepay-ui-merchant/src/api/manage.js b/jeepay-ui-merchant/src/api/manage.js index 3bc05722adc738a4fabea425b1ef601eacf7507f..4598f8aa6c9461fb9518a67d482bf8a81a925d8d 100644 --- a/jeepay-ui-merchant/src/api/manage.js +++ b/jeepay-ui-merchant/src/api/manage.js @@ -201,3 +201,20 @@ export function getUserInfo () { method: 'get' }) } + +/** 获取到webSocket的前缀 (ws://localhost) **/ +export function getWebSocketPrefix () { + // 获取网站域名 + 端口号 + let domain = document.location.protocol + '//' + document.location.host + + // 判断api_base_url 是否设置 + if (process.env.VUE_APP_API_BASE_URL && process.env.VUE_APP_API_BASE_URL !== '/') { + domain = process.env.VUE_APP_API_BASE_URL + } + + if (domain.startsWith('https:')) { + return 'wss://' + domain.replace('https://', '') + } else { + return 'ws://' + domain.replace('http://', '') + } +}