ws.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. const innetExportUrl = import.meta.env.VITE_WS_INNET_EXPORT_API
  2. const outnetExportUrl = import.meta.env.VITE_WS_OUTNET_EXPORT_API
  3. const innetUrl = import.meta.env.VITE_WS_INNET_API
  4. const outnetUrl = import.meta.env.VITE_WS_OUTNET_API
  5. const hostIp = import.meta.env.VITE_HOST_IP;
  6. export function getWsUrl() {
  7. var itemUrl = document.location.origin;
  8. console.log(itemUrl)
  9. if (itemUrl.includes(hostIp)) {
  10. return innetUrl;
  11. } else {
  12. return outnetUrl;
  13. }
  14. }
  15. export function getWsExportUrl() {
  16. var itemUrl = document.location.origin;
  17. if (itemUrl.includes(hostIp)) {
  18. return innetExportUrl;
  19. } else {
  20. return outnetExportUrl;
  21. }
  22. }
  23. export function patternNginxWsUrl() {
  24. var itemUrl = document.location.origin;
  25. // console.log(itemUrl)
  26. // if (itemUrl.includes(hostIp)) {
  27. // return "ws://" + hostIp + "/ws/"
  28. // } else {
  29. // return "ws://120.46.159.163/ws/"
  30. // }
  31. return itemUrl.replace('http', 'ws') + '/ws/'
  32. }
  33. export function patternNginxExportWsUrl() {
  34. // var itemUrl = document.location.origin;
  35. // console.log(itemUrl)
  36. // if (itemUrl.includes(hostIp)) {
  37. // return "ws://" + hostIp + "/ws/"
  38. // } else {
  39. // return "ws://120.46.159.163/ws/"
  40. // }
  41. return itemUrl.replace('http', 'ws') + '/ws-production/'
  42. }