Ver código fonte

fix🐛: Ai告警问题修复

gitboyzcf 2 semanas atrás
pai
commit
daa5bf6a8b

+ 2 - 2
src/components/PubMessage.vue

@@ -1,7 +1,7 @@
 <template>
   <div
     ref="modalRef"
-    class="absolute left-4 z-50 bg-#0d317866 transition-all duration-300 rounded-lg"
+    class="absolute left-4 z-50 bg-#0d317866 transition-all duration-300 ease-in-out active:bg-blue-500 focus:outline-none rounded-lg"
     :style="{ top }"
     v-if="visible"
     v-on:[systemStore.event]="itemClickFn"
@@ -71,7 +71,7 @@ const top = computed(
 const itemClickFn = () => {
   if (!props.itemClick) return;
   console.log(modalRef.value);
-  
+
   // modalRef.value.className += "animate__animated animate__rubberBand";
   // modalRef.value.addEventListener("animationend", () => {
   //   // do something

+ 6 - 6
src/router/index.js

@@ -44,12 +44,12 @@ const router = createRouter({
 router.beforeEach((to, from, next) => {
   usePageTitle(to)
   // 登录拦截
-  // if (!storage.local.get('t')) {
-  //   if (whiteList.includes(to.path)) {
-  //     return next()
-  //   }
-  //   return next('/login')
-  // }
+  if (!storage.local.get('t')) {
+    if (whiteList.includes(to.path)) {
+      return next()
+    }
+    return next('/login')
+  }
   next()
 })
 

+ 9 - 10
src/stores/modules/system.js

@@ -73,6 +73,7 @@ export const useSystemStore = defineStore("systemStore", {
       },
     ], // 预制点位
     token: storage.local.get('t') || '', // token
+    websocket: null
   }),
   getters: {
     ipF() {
@@ -113,6 +114,7 @@ export const useSystemStore = defineStore("systemStore", {
     },
     // 退出登录
     async loginOut(router) {
+      this.websocket.close()
       storage.session.clear();
       storage.local.clear();
       router.replace({ name: "Login" });
@@ -151,7 +153,6 @@ export const useSystemStore = defineStore("systemStore", {
       this.typeObj = res
       const resUrl = await API_FREE_LOGIN_URL()
       // 模拟数据
-
       // setTimeout(() => {
       //   // const data = {
       //   //   AlarmTime: 1709274691,
@@ -199,7 +200,7 @@ export const useSystemStore = defineStore("systemStore", {
       //   }
       //   useAlarm("警告⚠️", "", { default: () => h(Msg, { ...data, AlertType: '123123' }) }, {
       //     itemClick: () => {
-      //       location.href = resUrl
+      //       window.open('http://192.168.211.99:8081/#/alarm-center/output-result/algorithm-log?free=jJtp3xy1jJd3cqNqMB3Nvg1u')
       //     }
       //   });
       //   this.aiList.unshift({
@@ -211,33 +212,31 @@ export const useSystemStore = defineStore("systemStore", {
       //   }
       // }, 1000)
 
-      let websocket
       let that = this
         ; (() => {
-          websocket = new WebSocket(`wss://${this.ipF}/Ai/Alarm`)
-          websocket.onopen = function (e) {
+          that.websocket = new WebSocket(`wss://${this.ipF}/Ai/Alarm`)
+          that.websocket.onopen = function (e) {
             console.log('/Ai/Alarm 连接已经建立')
           }
-          websocket.onmessage = function (e) {
+          that.websocket.onmessage = function (e) {
             const data = JSON.parse(e.data)
             that.aiList.unshift({
               ...data,
               state: 0
             })
-            console.log(that.aiList)
             if (that.aiList.length >= 100) {
               that.aiList.splice(50, 10)
             }
             useAlarm("警告⚠️", "", { default: () => h(Msg, { ...data, AlertType: that.typeObj[data.AlertType] }) }, {
               itemClick: () => {
-                location.href = resUrl
+                window.open(resUrl)
               }
             });
           }
-          websocket.onerror = function (e) {
+          that.websocket.onerror = function (e) {
             console.log('Ai/Alarm 发生错误')
           }
-          websocket.onclose = function (e) {
+          that.websocket.onclose = function (e) {
             console.log('Ai/Alarm 连接断开')
           }
         })()

+ 2 - 2
src/views/Home/Home.vue

@@ -10,7 +10,7 @@
           <Loading class="h-200px" v-if="loading" />
           <div
             ref="positionBoxRef"
-            class="position-box absolute w-100px h-80px b-color-red-400 outline outline-[#fff] outline-offset-0 outline-2 b-solid b-4px top-0 hidden transform-translate--50%"
+            class="position-box absolute w-100px h-80px b-color-red-400 outline-[#fff] outline-offset-0 outline-2 b-solid b-4px top-0 hidden transform-translate--50%"
           ></div>
           <!-- 操作按钮 -->
           <div
@@ -96,7 +96,7 @@
           <Loading class="h-200px" v-if="loadingTwo" />
           <div
             ref="positionBoxRefTwo"
-            class="position-box absolute w-100px h-80px b-color-red outline outline-[#fff] outline-offset-0 outline-2 b-solid b-4px top-0 hidden transform-translate--50%"
+            class="position-box absolute w-100px h-80px b-color-red outline-[#fff] outline-offset-0 outline-2 b-solid b-4px top-0 hidden transform-translate--50%"
           ></div>
           <!-- 操作按钮 -->
           <div

+ 1 - 1
vite.config.js

@@ -16,7 +16,7 @@ import vitePluginStyleVwLoader from "vite-plugin-style-vw-loader";
 import { VantResolver } from "@vant/auto-import-resolver";
 // import { visualizer } from 'rollup-plugin-visualizer'
 
-const outDir = `bkq360-dist2.0.1.build${new Date().getFullYear()}${new Date().getMonth() + 1}${new Date().getDate()}`;
+const outDir = `bkq360-dist2.1.1.build${new Date().getFullYear()}${new Date().getMonth() + 1}${new Date().getDate()}`;
 // https://vitejs.dev/config/
 export default ({ mode }) => {
   // const env = loadEnv(mode, process.cwd())