Browse Source

配置全局路径

wangtao 1 year ago
parent
commit
402498f934

+ 7 - 2
.env.development

@@ -2,5 +2,10 @@
 ENV = 'development'
 
 # base api
-# VUE_APP_BASE_API = 'http://10.21.39.1:8082'
-VUE_APP_BASE_API = 'http://smartpark.caih.com/spapi'
+VUE_APP_BASE_API = 'http://10.21.39.1:8082'
+
+# iframe请求地址
+VUE_APP_IFRAME_API = 'http://10.21.39.6:9000/'
+
+# websocket请求地址
+VUE_APP_WEBSOCKET_API = 'ws://10.21.39.1:8080/afws/uskyWS/'

+ 7 - 1
.env.production

@@ -2,5 +2,11 @@
 ENV = 'production'
 
 # base api
-VUE_APP_BASE_API = 'https://smartpark.caih.com/af'
+VUE_APP_BASE_API = 'http://10.21.39.1:8082'
+
+# iframe请求地址
+VUE_APP_IFRAME_API = 'http://10.21.39.6:9000/'
+
+# websocket请求地址
+VUE_APP_WEBSOCKET_API = 'ws://10.21.39.1:8080/afws/uskyWS/'
 

+ 7 - 1
.env.staging

@@ -4,5 +4,11 @@ NODE_ENV = production
 ENV = 'staging'
 
 # base api
-VUE_APP_BASE_API = '/stage-api'
+VUE_APP_BASE_API = 'http://10.21.39.1:8082'
+
+# iframe请求地址
+VUE_APP_IFRAME_API = 'http://10.21.39.6:9000/'
+
+# websocket请求地址
+VUE_APP_WEBSOCKET_API = 'ws://10.21.39.1:8080/afws/uskyWS/'
 

+ 1 - 2
public/index.html

@@ -18,8 +18,7 @@
       <strong>We're sorry but <%= webpackConfig.name %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
     </noscript>
     <div id="app"></div>
-    <script src="./static/config.js"></script>
     <!-- built files will be auto injected -->
 </body>
 
-</html>
+</html>

+ 0 - 26
public/static/config.js

@@ -1,26 +0,0 @@
-/*
- * @Author: wt 1241351815@qq.com
- * @Date: 2022-04-25 10:21:18
- * @LastEditors: wt 1241351815@qq.com
- * @LastEditTime: 2022-05-13 15:02:51
- * @FilePath: \securityHtml\public\static\config.js
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- */
-
-// api 请求路径
-var PLATFROM_CONFIG = {};
-// PLATFROM_CONFIG.baseUrl = "http://172.16.120.49/securityapi/" //测试服务器
-// PLATFROM_CONFIG.baseUrl = "http://172.16.120.85:8082/"
-PLATFROM_CONFIG.baseUrl = "http://10.21.39.1:8082" //生产
-    //alarming WEBSOCKET
-let userInfo = window.localStorage.getItem("key");
-var PLATFROM_WEBSOCKET = {};
-PLATFROM_WEBSOCKET.wsUrl = `ws://10.21.39.1:8080/afws/uskyWS?${userInfo}`
-    // PLATFROM_WEBSOCKET.wsUrl = `ws://172.16.120.246:8081/uskyWS?${userInfo}`
-
-
-//iframe 请求路径
-//http://www.thingjs.com/s/ef7ee6a73896c01bda77e679?params=105b0f77fd24654d4eebc434e9 初始路径http://172.16.120.246:9000/
-var PLATFROM_IFRAME = {};
-// PLATFROM_IFRAME.iframeUrl = `https://www.thingjs.com/s/ef7ee6a73896c01bda77e679?params=105b0f77fd24654d4eebc434e9`
-PLATFROM_IFRAME.iframeUrl = `http://10.21.39.6:9000/`

+ 2 - 2
src/utils/request.js

@@ -11,7 +11,7 @@ import { MessageBox, Message } from 'element-ui'
 import store from '@/store'
 import { getToken } from '@/utils/auth'
 import Cookies from "js-cookie";
-let baseURL = window.PLATFROM_CONFIG.baseUrl
+let baseURL = process.env.VUE_APP_BASE_API
 axios.defaults.headers['Content-Type'] = 'application/json;multipart/form-data;charset=utf-8'
 const service = axios.create({
     baseURL: baseURL, // url = base url + request url
@@ -69,4 +69,4 @@ service.interceptors.response.use(response => {
     return {}
 })
 
-export default service
+export default service

+ 191 - 191
src/views/index/components/alarming.vue

@@ -1,191 +1,191 @@
-<template>
-  <div class="panel alarming">
-    <div class="panel-tit">告警信息</div>
-
-    <table class="alarm-table">
-      <thead>
-        <tr>
-          <th>序号</th>
-          <th>报警时间</th>
-          <th>报警事件</th>
-        </tr>
-      </thead>
-    </table>
-    <div class="scroll gj">
-      <table class="alarm-table">
-        <tbody id="scroll-box">
-          <tr  v-for="item in arrayList" :key="item.id" @click="alarm">
-
-            <td>{{ item.id }}</td>
-            <td class="online">{{ item.creatTime }}</td>
-            <td>
-                 {{item.eventtriger == '1' ? "恢复事件" : item.eventtriger == '2' ? "触发事件" :""}}
-            </td>
-          </tr>
-        </tbody>
-      </table>
-    </div>
-    <div class="panel-footer"></div>
-  </div>
-</template>
-<script>
-import api from "@/api/alarming"
-export default {
-  name: "alarming",
-  data() {
-    return {
-      username: "",
-      path: "",
-      socket: "",
-      arrayList: [],
-    };
-  },
-  mounted() {
-    // 初始化
-    this.init();
-    this.scroll();
-  setInterval(()=>{
-      this.scroll();
-    },1000 * 10)
-  },
-  methods: {
-    alarm(){
-      this.$router.push({
-          path: '/alarm/alarm-log/index',
-      })
-    },
-    scroll() {
-       api.queryPerimeterAlarm().then((response)=>{
-        if(response.status == "SUCCESS"){
-          if(response.data.pageList.length>0){
-            this.arrayList = response.data.pageList
-            //滚动
-            // if (this.arrayList.length > 5) {
-            //   const dom = document.getElementById("scroll-box");
-            //   const that = this;
-            //   let timer = null;
-            //   const animationEndHandler = (evt) => {
-            //     const dom = document.getElementById("scroll-box");
-            //     dom.style.cssText = "transform:translate(0,0)";
-            //     dom.appendChild(dom.children[0]); //把第一个DOM添加到最后一个去
-            //   };
-            //   const mouseEnterHander = (evt) => {
-            //     clearInterval(timer);
-            //   };
-            //   const initInterval = () => {
-            //     timer = setInterval(() => {
-            //       if (dom.children[0]) {
-            //         let scrollHeight = dom.children[0].offsetHeight;
-            //         scrollHeight = parseInt(scrollHeight);
-            //         dom.style.cssText = `transform:translate(0px,-${
-            //           scrollHeight
-            //         }px);transition:all 1s ease;`;
-            //       }
-            //     }, 3000);
-            //   };
-            //   const mouseLeaveHandler = () => {
-            //     initInterval();
-            //   };
-            //   dom.addEventListener("mouseenter", mouseEnterHander);
-            //   dom.addEventListener("mouseleave", mouseLeaveHandler);
-            //   dom.removeEventListener("transitionend", animationEndHandler);
-            //   dom.addEventListener("transitionend", animationEndHandler); //只要监听到translate就会执行,这样就能一直动了
-            //   initInterval();
-            // }
-          }
-        }
-      })
-
-    },
-    init: function () {
-      let wsUrl = window.PLATFROM_WEBSOCKET.wsUrl
-      this.path = wsUrl;
-      if (typeof WebSocket === "undefined") {
-        alert("您的浏览器不支持socket");
-      } else {
-        // 实例化socket
-        this.socket = new WebSocket(this.path);
-        // 监听socket连接
-        this.socket.onopen = this.open;
-        // 监听socket错误信息
-        this.socket.onerror = this.error;
-        // 监听socket消息
-        this.socket.onmessage = this.getMessage;
-      }
-    },
-    open: function () {
-      console.log("socket连接成功");
-    },
-    error: function () {
-      console.log("连接错误");
-    },
-    getMessage: function (msg) {
-      this.arrayList = JSON.parse(msg.data)
-    },
-    send: function () {
-      this.socket.send("admin");
-    },
-    close: function () {
-      console.log("socket已经关闭");
-    },
-  },
-  destroyed() {
-    // 销毁监听
-    this.socket.onclose = this.close;
-  },
-};
-</script>
-<style lang="scss" scoped>
-#scroll-box {
-  height: 16rem;
-}
-.panel.alarming {
-  margin-top: 2rem;
-  z-index: 3;
-  box-sizing: border-box;
-  table {
-    padding: 0 1rem;
-
-    border-spacing: 0;
-  }
-
-  tr td,
-  tr th {
-    font-size: 1.4rem;
-    height:0.5rem;
-    line-height: 3rem;
-    text-align: left;
-    // padding: 0 1rem;
-    // padding: 0;
-    // margin: 0;
-    // background:pink;
-    border-bottom: 1px solid #1c5899;
-    border-left: 0px solid red;
-    border-right: 0px solid red;
-    border-top: 0px solid red;
-  }
-  .alarm-table tr td:first-child,
-  .alarm-table tr th:first-child {
-    width: 16%;
-  }
-
-  .alarm-table tr td:nth-child(2),
-  .alarm-table tr th:nth-child(2) {
-    width: 60%;
-  }
-
-  .alarm-table tr td:nth-child(3),
-  .alarm-table tr th:nth-child(3) {
-    width: 100px;
-  }
-}
-.gj{
-  height: calc(100vh - 80rem);
-  overflow: hidden;
-}
-.alarm-table tr td{
-  height:30px !important;
-}
-</style>
-<style lang="scss">
-</style>
+<template>
+  <div class="panel alarming">
+    <div class="panel-tit">告警信息</div>
+
+    <table class="alarm-table">
+      <thead>
+        <tr>
+          <th>序号</th>
+          <th>报警时间</th>
+          <th>报警事件</th>
+        </tr>
+      </thead>
+    </table>
+    <div class="scroll gj">
+      <table class="alarm-table">
+        <tbody id="scroll-box">
+          <tr  v-for="item in arrayList" :key="item.id" @click="alarm">
+
+            <td>{{ item.id }}</td>
+            <td class="online">{{ item.creatTime }}</td>
+            <td>
+                 {{item.eventtriger == '1' ? "恢复事件" : item.eventtriger == '2' ? "触发事件" :""}}
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="panel-footer"></div>
+  </div>
+</template>
+<script>
+import api from "@/api/alarming"
+export default {
+  name: "alarming",
+  data() {
+    return {
+      username: "",
+      path: "",
+      socket: "",
+      arrayList: [],
+    };
+  },
+  mounted() {
+    // 初始化
+    this.init();
+    this.scroll();
+  setInterval(()=>{
+      this.scroll();
+    },1000 * 10)
+  },
+  methods: {
+    alarm(){
+      this.$router.push({
+          path: '/alarm/alarm-log/index',
+      })
+    },
+    scroll() {
+       api.queryPerimeterAlarm().then((response)=>{
+        if(response.status == "SUCCESS"){
+          if(response.data.pageList.length>0){
+            this.arrayList = response.data.pageList
+            //滚动
+            // if (this.arrayList.length > 5) {
+            //   const dom = document.getElementById("scroll-box");
+            //   const that = this;
+            //   let timer = null;
+            //   const animationEndHandler = (evt) => {
+            //     const dom = document.getElementById("scroll-box");
+            //     dom.style.cssText = "transform:translate(0,0)";
+            //     dom.appendChild(dom.children[0]); //把第一个DOM添加到最后一个去
+            //   };
+            //   const mouseEnterHander = (evt) => {
+            //     clearInterval(timer);
+            //   };
+            //   const initInterval = () => {
+            //     timer = setInterval(() => {
+            //       if (dom.children[0]) {
+            //         let scrollHeight = dom.children[0].offsetHeight;
+            //         scrollHeight = parseInt(scrollHeight);
+            //         dom.style.cssText = `transform:translate(0px,-${
+            //           scrollHeight
+            //         }px);transition:all 1s ease;`;
+            //       }
+            //     }, 3000);
+            //   };
+            //   const mouseLeaveHandler = () => {
+            //     initInterval();
+            //   };
+            //   dom.addEventListener("mouseenter", mouseEnterHander);
+            //   dom.addEventListener("mouseleave", mouseLeaveHandler);
+            //   dom.removeEventListener("transitionend", animationEndHandler);
+            //   dom.addEventListener("transitionend", animationEndHandler); //只要监听到translate就会执行,这样就能一直动了
+            //   initInterval();
+            // }
+          }
+        }
+      })
+
+    },
+    init: function () {
+      let wsUrl = process.env.VUE_APP_WEBSOCKET_API + localStorage.getItem("vue_admin_template_token1708")
+      this.path = wsUrl;
+      if (typeof WebSocket === "undefined") {
+        alert("您的浏览器不支持socket");
+      } else {
+        // 实例化socket
+        this.socket = new WebSocket(this.path);
+        // 监听socket连接
+        this.socket.onopen = this.open;
+        // 监听socket错误信息
+        this.socket.onerror = this.error;
+        // 监听socket消息
+        this.socket.onmessage = this.getMessage;
+      }
+    },
+    open: function () {
+      console.log("socket连接成功");
+    },
+    error: function () {
+      console.log("连接错误");
+    },
+    getMessage: function (msg) {
+      this.arrayList = JSON.parse(msg.data)
+    },
+    send: function () {
+      this.socket.send("admin");
+    },
+    close: function () {
+      console.log("socket已经关闭");
+    },
+  },
+  destroyed() {
+    // 销毁监听
+    this.socket.onclose = this.close;
+  },
+};
+</script>
+<style lang="scss" scoped>
+#scroll-box {
+  height: 16rem;
+}
+.panel.alarming {
+  margin-top: 2rem;
+  z-index: 3;
+  box-sizing: border-box;
+  table {
+    padding: 0 1rem;
+
+    border-spacing: 0;
+  }
+
+  tr td,
+  tr th {
+    font-size: 1.4rem;
+    height:0.5rem;
+    line-height: 3rem;
+    text-align: left;
+    // padding: 0 1rem;
+    // padding: 0;
+    // margin: 0;
+    // background:pink;
+    border-bottom: 1px solid #1c5899;
+    border-left: 0px solid red;
+    border-right: 0px solid red;
+    border-top: 0px solid red;
+  }
+  .alarm-table tr td:first-child,
+  .alarm-table tr th:first-child {
+    width: 16%;
+  }
+
+  .alarm-table tr td:nth-child(2),
+  .alarm-table tr th:nth-child(2) {
+    width: 60%;
+  }
+
+  .alarm-table tr td:nth-child(3),
+  .alarm-table tr th:nth-child(3) {
+    width: 100px;
+  }
+}
+.gj{
+  height: calc(100vh - 80rem);
+  overflow: hidden;
+}
+.alarm-table tr td{
+  height:30px !important;
+}
+</style>
+<style lang="scss">
+</style>

+ 1 - 1
src/views/index/components/monitor.vue

@@ -215,7 +215,7 @@ export default {
   },
   mounted() {
     let _this = this;
-    _this.iframe_Url = window.PLATFROM_IFRAME.iframeUrl;
+    _this.iframe_Url = process.env.VUE_APP_IFRAME_API;
     // _this.getLocalChannel();
     window.addEventListener(
       "message",

+ 14 - 14
vue.config.js

@@ -39,19 +39,19 @@ module.exports = {
             errors: true
         },
         //解决跨越问题
-        proxy: {
-            [process.env.VUE_APP_BASE_API]: {
-                //target: "http://101.133.214.75:81/af", //75
-                target: 'http://10.21.39.1:8082', //生产
-                //target: 'https://smartpark.caih.com/spapi',
-                //target: 'https://qhome.usky.cn/af',
-                //target: 'http://172.16.120.213:8082', //强
-                changeOrigin: true,
-                pathRewrite: {
-                    ['^' + process.env.VUE_APP_BASE_API]: ''
-                }
-            }
-        },
+        // proxy: {
+        //     [process.env.VUE_APP_BASE_API]: {
+        //         //target: "http://101.133.214.75:81/af", //75
+        //         target: 'http://10.21.39.1:8082', //生产
+        //         //target: 'https://smartpark.caih.com/spapi',
+        //         //target: 'https://qhome.usky.cn/af',
+        //         //target: 'http://172.16.120.213:8082', //强
+        //         changeOrigin: true,
+        //         pathRewrite: {
+        //             ['^' + process.env.VUE_APP_BASE_API]: ''
+        //         }
+        //     }
+        // },
     },
     configureWebpack: {
         // provide the app's title in webpack's name field, so that
@@ -133,4 +133,4 @@ module.exports = {
                 }
             )
     }
-}
+}