提交 f05fa039 编写于 作者: terrfly's avatar terrfly

添加 reconnectingwebsocket 组件, 添加getWebSocketPrefix() 获取webSocket前缀公共函数;

上级 b1331cba
......@@ -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",
......
......@@ -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",
......
......@@ -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://', '')
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册