소스 검색

获取ip地址

蒋科 4 달 전
부모
커밋
ac6a81855f
4개의 변경된 파일16개의 추가작업 그리고 8개의 파일을 삭제
  1. 3 1
      src/utils/longRuquest.js
  2. 3 1
      src/utils/request.js
  3. 4 2
      src/views/equipment-monitoring/index.vue
  4. 6 4
      src/views/manage-log/control.vue

+ 3 - 1
src/utils/longRuquest.js

@@ -2,9 +2,11 @@ import axios from 'axios'
 import { Message } from 'element-ui'
 import store from '@/store'
 import { tansParams } from '@/utils/zk'
+const href='http://'+window.location.hostname+'/api'
 const service = axios.create({
   // baseURL: httpurl.devServer.proxy['/api'].target+'/api',
-  baseURL:process.env.VUE_APP_BASE_API,
+  // baseURL:process.env.VUE_APP_BASE_API,
+  baseURL:href,
   timeout: 7200000
 })
 // request interceptor

+ 3 - 1
src/utils/request.js

@@ -2,9 +2,11 @@ import axios from 'axios'
 import { Message } from 'element-ui'
 import store from '@/store'
 import { tansParams } from '@/utils/zk'
+const href='http://'+window.location.hostname+'/api'
 const service = axios.create({
   // baseURL: httpurl.devServer.proxy['/api'].target+'/api',
-  baseURL:process.env.VUE_APP_BASE_API,
+  // baseURL:process.env.VUE_APP_BASE_API,
+  baseURL:href,
   timeout: 5000
 })
 // request interceptor

+ 4 - 2
src/views/equipment-monitoring/index.vue

@@ -186,7 +186,7 @@
                 </div>
               </div>
             </li>
-           
+
           </ul>
         </div>
       </div>
@@ -383,7 +383,9 @@ export default {
     },
     websocketConnect() {
       const wstoken = getToken();
-      this.ws = new WebSocket(process.env.VUE_APP_WS + "/" + wstoken);
+      const appWs='ws://'+window.location.hostname+'/ws'
+      // this.ws = new WebSocket(process.env.VUE_APP_WS + "/" + wstoken);
+      this.ws = new WebSocket(appWs + "/" + wstoken);
       this.ws.onopen = this.websocketOnOpen;
       this.ws.onerror = this.websocketOnError;
       this.ws.onmessage = this.websocketOnMessage;

+ 6 - 4
src/views/manage-log/control.vue

@@ -108,7 +108,7 @@ export default {
       if(d.plcResultDTO){
         this.plcResultDTO=d.plcResultDTO
       }
-      
+
     },
     websocketOnError(e) {
       console.log("socket错误", e);
@@ -126,8 +126,10 @@ export default {
     },
     websocketConnect() {
       const wstoken = getToken();
+      const appWs='ws://'+window.location.hostname+'/ws'
       this.ws = new WebSocket(
-        process.env.VUE_APP_WS + "/" + wstoken
+        // process.env.VUE_APP_WS + "/" + wstoken
+        appWs + "/" + wstoken
       );
       this.ws.onopen = this.websocketOnOpen;
       this.ws.onerror = this.websocketOnError;
@@ -182,7 +184,7 @@ export default {
     display: flex;
     flex-wrap: wrap;
 
-    
+
   }
 }
-</style>
+</style>