|
@@ -1,6 +1,9 @@
|
|
import { piniaStore } from "@/stores";
|
|
import { piniaStore } from "@/stores";
|
|
|
|
+import { h } from "vue";
|
|
import { isWap } from "@/utils";
|
|
import { isWap } from "@/utils";
|
|
import storage from "@/utils/storage";
|
|
import storage from "@/utils/storage";
|
|
|
|
+import Msg from "@/views/Home/components/msg.vue"
|
|
|
|
+import { useAlarm } from "@/hooks/useAlarm";
|
|
|
|
|
|
const {
|
|
const {
|
|
API_VIEW_BC_LIST_GET,
|
|
API_VIEW_BC_LIST_GET,
|
|
@@ -29,6 +32,8 @@ export const useSystemStore = defineStore("systemStore", {
|
|
BallCameraId: "",
|
|
BallCameraId: "",
|
|
BallCameraInfo: {}, // 球机信息
|
|
BallCameraInfo: {}, // 球机信息
|
|
cilpInfo: {}, // 裁剪信息
|
|
cilpInfo: {}, // 裁剪信息
|
|
|
|
+ aiList: [], // ai报警信息列表
|
|
|
|
+ typeObj: null, // ai告警类型
|
|
points: [
|
|
points: [
|
|
{
|
|
{
|
|
Id: 1,
|
|
Id: 1,
|
|
@@ -139,6 +144,104 @@ export const useSystemStore = defineStore("systemStore", {
|
|
// points: points.map((v) => ({ ...v, upd: false })),
|
|
// points: points.map((v) => ({ ...v, upd: false })),
|
|
// });
|
|
// });
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+ async connectAlarmWS() {
|
|
|
|
+ const { API_AI_TYPE_GET, API_FREE_LOGIN_URL } = useRequest()
|
|
|
|
+ const res = await API_AI_TYPE_GET()
|
|
|
|
+ this.typeObj = res
|
|
|
|
+ const resUrl = await API_FREE_LOGIN_URL()
|
|
|
|
+ // 模拟数据
|
|
|
|
+
|
|
|
|
+ // setTimeout(() => {
|
|
|
|
+ // // const data = {
|
|
|
|
+ // // AlarmTime: 1709274691,
|
|
|
|
+ // // CfgId: 95,
|
|
|
|
+ // // Type: 'human',
|
|
|
|
+ // // SerialNumber: '5cc8e284-55c9-4916-b493-20a222d3386f',
|
|
|
|
+ // // AlarmId: 1516,
|
|
|
|
+ // // Res: {
|
|
|
|
+ // // '16535ccf-ab52-4553-a494-f168f5144bd2%7C9%7C1546372969796': [
|
|
|
|
+ // // { x: 525, y: 1775, w: 1615, h: 2067 }
|
|
|
|
+ // // ],
|
|
|
|
+ // // 'd29e7346-8d8d-44ff-918b-ca0928687f75|0|1709628059861': [
|
|
|
|
+ // // { x: 525, y: 1775, w: 1615, h: 2067 }
|
|
|
|
+ // // ]
|
|
|
|
+ // // }
|
|
|
|
+ // // }
|
|
|
|
+ // const data = {
|
|
|
|
+ // "AlertType": "28",
|
|
|
|
+ // "Archived": 0,
|
|
|
|
+ // "ArchivedTime": "0000-00-00 00:00:00",
|
|
|
|
+ // "ArchivedUserPhone": "",
|
|
|
|
+ // "AssociateResult": null,
|
|
|
|
+ // "AssociateType": null,
|
|
|
|
+ // "CameraId": 24,
|
|
|
|
+ // "CreatedAt": "2025-08-06 18:01:19",
|
|
|
|
+ // "DataID": "4dd2a7d672ac11f091380242ac120007",
|
|
|
|
+ // "GUID": "003a3374-7b1f-4d2f-a4ec-2c94602d5603",
|
|
|
|
+ // "HandleStatus": 0,
|
|
|
|
+ // "HandleStatusTime": "0000-00-00 00:00:00",
|
|
|
|
+ // "HandleStatusUserPhone": "",
|
|
|
|
+ // "Id": 94276,
|
|
|
|
+ // "JsonFile": "resultJson/20250806/20250806180119_433968_28_24_result.json?serverUUID=3f16a3b113234807b81f6f8d0f268232",
|
|
|
|
+ // "OriginPicture": "originPicture/20250806/20250806180119_433968_28_24_src.jpg?serverUUID=3f16a3b113234807b81f6f8d0f268232",
|
|
|
|
+ // "Other": "",
|
|
|
|
+ // "Picture": "picture/20250806/20250806180119_433968_28_24_alarm.jpg",
|
|
|
|
+ // "Remark": "",
|
|
|
|
+ // "RemarkTime": "0000-00-00 00:00:00",
|
|
|
|
+ // "RemarkUserPhone": "",
|
|
|
|
+ // "StandardPicture": "",
|
|
|
|
+ // "TaskGroupId": null,
|
|
|
|
+ // "TaskId": 9,
|
|
|
|
+ // "Thumbnail": "picthumbnail/20250806/20250806180119_433968_28_24_src.jpg?serverUUID=3f16a3b113234807b81f6f8d0f268232",
|
|
|
|
+ // "UserId": 1,
|
|
|
|
+ // "Video": null
|
|
|
|
+ // }
|
|
|
|
+ // useAlarm("警告⚠️", "", { default: () => h(Msg, { ...data, AlertType: '123123' }) }, {
|
|
|
|
+ // itemClick: () => {
|
|
|
|
+ // location.href = resUrl
|
|
|
|
+ // }
|
|
|
|
+ // });
|
|
|
|
+ // this.aiList.unshift({
|
|
|
|
+ // ...data,
|
|
|
|
+ // state: 0,
|
|
|
|
+ // })
|
|
|
|
+ // if (this.aiList.length >= 30) {
|
|
|
|
+ // this.aiList.splice(20, 10)
|
|
|
|
+ // }
|
|
|
|
+ // }, 1000)
|
|
|
|
+
|
|
|
|
+ let websocket
|
|
|
|
+ let that = this
|
|
|
|
+ ; (() => {
|
|
|
|
+ websocket = new WebSocket(`wss://${this.ipF}/Ai/Alarm`)
|
|
|
|
+ websocket.onopen = function (e) {
|
|
|
|
+ console.log('/Ai/Alarm 连接已经建立')
|
|
|
|
+ }
|
|
|
|
+ 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
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ websocket.onerror = function (e) {
|
|
|
|
+ console.log('Ai/Alarm 发生错误')
|
|
|
|
+ }
|
|
|
|
+ websocket.onclose = function (e) {
|
|
|
|
+ console.log('Ai/Alarm 连接断开')
|
|
|
|
+ }
|
|
|
|
+ })()
|
|
|
|
+ },
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
|