钟铮锁App web部分 需要打包放进对应的安卓项目 生成apk 才能正常使用功能
he wei
2025-01-19 ba2cfa9907623c094e6e2d52d12dc3055ddd587a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// import config from "./config";
// const { serviceIp } = config;
import { useUserStore } from "@/stores/user.js";
import pinia from './pinia.js';
const {  serverIp } = useUserStore(pinia);
/**
 * 获取Websocket的连接
 * @param action
 * @returns {string}
 */
function getWsUrl(action, port) {
  let _port = port ? port : 8100;
  let hostname = window.location.hostname;
  let wsProtocol = "ws://";
  if (window.location.protocol == "https:") {
    wsProtocol = "wss://";
  }
  // if (process.env.NODE_ENV == "development") {
  //   hostname = "localhost";
  // } else {
  // }
 
  hostname = serverIp;
  // _port = window.location.port;
 
  // 处理端口为80
  _port = _port == 80 ? "" : ":" + _port;
  return wsProtocol + hostname + _port + "/bl/" + action;
}
 
export default getWsUrl;