ezhizao_zx 4 月之前
父節點
當前提交
1ba89dab37
共有 2 個文件被更改,包括 16 次插入3 次删除
  1. 4 2
      .env.production
  2. 12 1
      src/views/business/outsourceInspectionVerify/index.vue

+ 4 - 2
.env.production

@@ -29,6 +29,8 @@ VITE_HOST_INNET = 'http://192.168.10.41=2:82/onlinePreview?url='
 VITE_HOST_OUTNET = 'http://120.46.159.163:8012/onlinePreview?url='
 
 #站内信地址
-VITE_WS_API = '/ws/'
+VITE_WS_INNET_API = 'ws://192.168.10.41:7001/ws/'
+VITE_WS_OUTNET_API = 'ws://120.46.159.163:7001/ws/'
 #导出地址
-VITE_WS_EXPORT_API = '/ws-production/'
+VITE_WS_INNET_EXPORT_API = 'ws://192.168.10.41:7003/wsExport/'
+VITE_WS_OUTNET_EXPORT_API = 'ws://120.46.159.163:7003/wsExport/'

+ 12 - 1
src/views/business/outsourceInspectionVerify/index.vue

@@ -167,7 +167,11 @@ const doingExport = ref(false)
 const exportProgress = ref(0)
 const exportUrl = ref(null)
 // const wsUrl = 'ws://localhost:8081/wsExport/'
-const wsUrl = import.meta.env.VITE_WS_EXPORT_API
+const innetUrl = import.meta.env.VITE_WS_INNET_EXPORT_API
+const outnetUrl = import.meta.env.VITE_WS_OUTNET_EXPORT_API
+const hostIp = import.meta.env.VITE_HOST_IP;
+
+// const wsUrl = import.meta.env.VITE_WS_EXPORT_API
 let ws = null
 
 const webHost = import.meta.env.VITE_APP_BASE_API;
@@ -382,6 +386,13 @@ async function createWebSocket(id, token) {
   try {
     // const options = { headers: { Authorization: 'Bearer ' + token } }
     // console.log(options)
+    var itemUrl = document.location.origin;
+    var wsUrl = "";
+    if (itemUrl.includes(hostIp)) {
+      wsUrl = innetUrl;
+    } else {
+      wsUrl = outnetUrl;
+    }
     ws = new WebSocket(wsUrl + id, [token])
   } catch (e) {
     console.log(e)