inl-ui 0.1.129 → 0.1.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -49
- package/dist/components/index.cjs +181 -2
- package/dist/components/index.js +180 -2
- package/dist/index.cjs +182 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +181 -3
- package/dist/theme/index.js +70 -70
- package/dist/theme/scripts/dark-vars.js +21 -21
- package/dist/theme/scripts/default-vars.js +25 -25
- package/dist/theme/scripts/light-vars.js +22 -22
- package/dist/theme/style/color/bezierEasing.less +110 -110
- package/dist/theme/style/color/colorPalette.less +81 -81
- package/dist/theme/style/color/colors.less +162 -162
- package/dist/theme/style/color/tinyColor.less +1184 -1184
- package/dist/theme/style/compact.less +4 -4
- package/dist/theme/style/dark.less +4 -4
- package/dist/theme/style/default.less +4 -4
- package/dist/theme/style/index.less +2 -2
- package/dist/theme/style/index.tsx +2 -2
- package/dist/theme/style/themes/compact.less +295 -295
- package/dist/theme/style/themes/dark.less +790 -790
- package/dist/theme/style/themes/default.less +1067 -1067
- package/dist/theme/style/themes/index.less +7 -7
- package/dist/theme/style/themes/var-dark.less +343 -343
- package/dist/theme/style/themes/var-default.less +184 -184
- package/dist/theme/style/themes/variable.less +1122 -1122
- package/dist/theme/style/variable.less +4 -4
- package/dist/video/index.cjs +181 -2
- package/dist/video/index.js +181 -3
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
# 工业PC ui库
|
|
2
|
-
|
|
3
|
-
前端通用库,包括组件、hooks、utils等。
|
|
4
|
-
|
|
5
|
-
### 运行
|
|
6
|
-
|
|
7
|
-
+ 开发模式 yarn dev
|
|
8
|
-
+ 生产打包 yarn build
|
|
9
|
-
+ 生成文档 yarn build:docs
|
|
10
|
-
+ 打包图扑工具 yarn buildtp
|
|
11
|
-
|
|
12
|
-
### 使用方法
|
|
13
|
-
|
|
14
|
-
```javascript
|
|
15
|
-
import inl from 'inl-ui';
|
|
16
|
-
import 'inl-ui/dist/style.css';
|
|
17
|
-
|
|
18
|
-
vue.use(inl)
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
### 激活主题
|
|
24
|
-
|
|
25
|
-
**vite.config.ts**
|
|
26
|
-
|
|
27
|
-
```javascript
|
|
28
|
-
const additionalData = require("inl-ui/dist/theme").default;
|
|
29
|
-
|
|
30
|
-
...
|
|
31
|
-
|
|
32
|
-
css: {
|
|
33
|
-
preprocessorOptions: {
|
|
34
|
-
less: {
|
|
35
|
-
javascriptEnabled: true,
|
|
36
|
-
additionalData,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### 文档链接
|
|
43
|
-
|
|
44
|
-
##### [组件文档](./src/components/README.md)
|
|
45
|
-
|
|
46
|
-
##### [hooks文档](./src/hooks/README.md)
|
|
47
|
-
|
|
48
|
-
##### [Utils文档](./src/utils/README.md)
|
|
49
|
-
|
|
1
|
+
# 工业PC ui库
|
|
2
|
+
|
|
3
|
+
前端通用库,包括组件、hooks、utils等。
|
|
4
|
+
|
|
5
|
+
### 运行
|
|
6
|
+
|
|
7
|
+
+ 开发模式 yarn dev
|
|
8
|
+
+ 生产打包 yarn build
|
|
9
|
+
+ 生成文档 yarn build:docs
|
|
10
|
+
+ 打包图扑工具 yarn buildtp
|
|
11
|
+
|
|
12
|
+
### 使用方法
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
import inl from 'inl-ui';
|
|
16
|
+
import 'inl-ui/dist/style.css';
|
|
17
|
+
|
|
18
|
+
vue.use(inl)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### 激活主题
|
|
24
|
+
|
|
25
|
+
**vite.config.ts**
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
const additionalData = require("inl-ui/dist/theme").default;
|
|
29
|
+
|
|
30
|
+
...
|
|
31
|
+
|
|
32
|
+
css: {
|
|
33
|
+
preprocessorOptions: {
|
|
34
|
+
less: {
|
|
35
|
+
javascriptEnabled: true,
|
|
36
|
+
additionalData,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 文档链接
|
|
43
|
+
|
|
44
|
+
##### [组件文档](./src/components/README.md)
|
|
45
|
+
|
|
46
|
+
##### [hooks文档](./src/hooks/README.md)
|
|
47
|
+
|
|
48
|
+
##### [Utils文档](./src/utils/README.md)
|
|
49
|
+
|
|
@@ -13,6 +13,7 @@ var qiankun = require('qiankun');
|
|
|
13
13
|
var dayjs = require('dayjs');
|
|
14
14
|
require('vite-plugin-qiankun');
|
|
15
15
|
var renderWithQiankun = require('vite-plugin-qiankun/dist/helper');
|
|
16
|
+
var mqtt = require('mqtt');
|
|
16
17
|
var mobile = require('@sszj-temp/mobile');
|
|
17
18
|
var marked = require('marked');
|
|
18
19
|
|
|
@@ -39,6 +40,7 @@ function _interopNamespace(e) {
|
|
|
39
40
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios$2);
|
|
40
41
|
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
41
42
|
var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
|
|
43
|
+
var mqtt__default = /*#__PURE__*/_interopDefaultLegacy(mqtt);
|
|
42
44
|
|
|
43
45
|
const config = {
|
|
44
46
|
prefix: "inl",
|
|
@@ -9639,6 +9641,33 @@ var Tree = vue.defineComponent({
|
|
|
9639
9641
|
}
|
|
9640
9642
|
});
|
|
9641
9643
|
|
|
9644
|
+
let client = null;
|
|
9645
|
+
const ip = "10.255.9.121";
|
|
9646
|
+
let connectUrl = `ws://${ip}:8083/mqtt`;
|
|
9647
|
+
const useMqtt = async (options = {}) => {
|
|
9648
|
+
if (client) {
|
|
9649
|
+
return client;
|
|
9650
|
+
}
|
|
9651
|
+
return new Promise(async (resolve, reject) => {
|
|
9652
|
+
const mqttOptions = {
|
|
9653
|
+
url: connectUrl,
|
|
9654
|
+
clientId: `llm_${new Date().getTime()}`,
|
|
9655
|
+
username: "admin",
|
|
9656
|
+
password: "admin123",
|
|
9657
|
+
...options
|
|
9658
|
+
};
|
|
9659
|
+
client = mqtt__default["default"].connect(connectUrl, mqttOptions);
|
|
9660
|
+
client.on("connect", () => {
|
|
9661
|
+
console.log("\u8FDE\u63A5\u6210\u529F");
|
|
9662
|
+
resolve(client);
|
|
9663
|
+
});
|
|
9664
|
+
client.on("error", err => {
|
|
9665
|
+
console.log("\u8FDE\u63A5\u5931\u8D25", err);
|
|
9666
|
+
reject(err);
|
|
9667
|
+
});
|
|
9668
|
+
});
|
|
9669
|
+
};
|
|
9670
|
+
|
|
9642
9671
|
const props$6 = {
|
|
9643
9672
|
// 视频信息|视频源uuid
|
|
9644
9673
|
camera: {
|
|
@@ -9656,7 +9685,7 @@ const props$6 = {
|
|
|
9656
9685
|
// },
|
|
9657
9686
|
btns: {
|
|
9658
9687
|
type: Array,
|
|
9659
|
-
default: ["change", "fill", "look", "stream", "magnify", "direction", "fullScreen", "close"]
|
|
9688
|
+
default: ["vlm", "change", "fill", "look", "stream", "magnify", "direction", "fullScreen", "close"]
|
|
9660
9689
|
},
|
|
9661
9690
|
alarm: {
|
|
9662
9691
|
default: false,
|
|
@@ -9679,6 +9708,7 @@ const VideoBoxV2 = vue.defineComponent({
|
|
|
9679
9708
|
const streamHistory = vue.ref("");
|
|
9680
9709
|
const streams = vue.ref([]);
|
|
9681
9710
|
const showInfo = vue.ref(true);
|
|
9711
|
+
const showVlmInfo = vue.ref(true);
|
|
9682
9712
|
const magnifyBtn = vue.ref(false);
|
|
9683
9713
|
const videoBtns = [[{
|
|
9684
9714
|
text: "lup",
|
|
@@ -9784,10 +9814,25 @@ const VideoBoxV2 = vue.defineComponent({
|
|
|
9784
9814
|
});
|
|
9785
9815
|
camera.value = res.data.data;
|
|
9786
9816
|
streams.value = JSON.parse(camera.value?.brandTypePo?.streamTypeDict || "[]");
|
|
9817
|
+
console.log("vlmSwitchKey.value", vlmSwitchKey.value);
|
|
9818
|
+
console.log("localStorage.getItem(vlmSwitchKey.value)", localStorage.getItem(vlmSwitchKey.value));
|
|
9819
|
+
if (localStorage.getItem(vlmSwitchKey.value) !== "false") {
|
|
9820
|
+
showVlmInfo.value = true;
|
|
9821
|
+
if (camera.value?.ip && showVlmInfo.value) {
|
|
9822
|
+
initMqtt(camera.value?.ip);
|
|
9823
|
+
}
|
|
9824
|
+
} else {
|
|
9825
|
+
showVlmInfo.value = false;
|
|
9826
|
+
}
|
|
9787
9827
|
};
|
|
9788
9828
|
let timeout;
|
|
9789
9829
|
vue.ref(true);
|
|
9790
|
-
vue.onBeforeUnmount(() => {
|
|
9830
|
+
vue.onBeforeUnmount(() => {
|
|
9831
|
+
if (Mqtt) {
|
|
9832
|
+
Mqtt?.unsubscribe(topic.value);
|
|
9833
|
+
Mqtt = null;
|
|
9834
|
+
}
|
|
9835
|
+
});
|
|
9791
9836
|
const resetZoom = () => {
|
|
9792
9837
|
const chooseFieldDom = document.getElementById("chooseField_" + uuid.value);
|
|
9793
9838
|
chooseFieldDom?.remove();
|
|
@@ -9947,6 +9992,126 @@ const VideoBoxV2 = vue.defineComponent({
|
|
|
9947
9992
|
}, null) : ""])]
|
|
9948
9993
|
});
|
|
9949
9994
|
};
|
|
9995
|
+
let Mqtt = null;
|
|
9996
|
+
const topic = vue.ref("");
|
|
9997
|
+
const initMqtt = async ip => {
|
|
9998
|
+
Mqtt = await useMqtt();
|
|
9999
|
+
topic.value = `vlm/${ip}`;
|
|
10000
|
+
Mqtt.subscribe(topic.value, {
|
|
10001
|
+
qos: 2
|
|
10002
|
+
}, err => {
|
|
10003
|
+
if (!err) {
|
|
10004
|
+
console.log(`\u8BA2\u9605\u6210\u529F\u4E3B\u9898:${topic.value}`);
|
|
10005
|
+
} else {
|
|
10006
|
+
console.log(`\u8BA2\u9605\u5931\u8D25:${err}`);
|
|
10007
|
+
}
|
|
10008
|
+
});
|
|
10009
|
+
Mqtt.on("message", onMtMessageFn);
|
|
10010
|
+
};
|
|
10011
|
+
const onMtMessageFn = (topic2, message2) => {
|
|
10012
|
+
const msg = new TextDecoder("utf-8").decode(message2);
|
|
10013
|
+
console.log("msg", JSON.parse(msg));
|
|
10014
|
+
drawFlog(JSON.parse(msg));
|
|
10015
|
+
};
|
|
10016
|
+
let canvasDom = null;
|
|
10017
|
+
let textBox = null;
|
|
10018
|
+
const createFlogCanvas = () => {
|
|
10019
|
+
const box = document.getElementById("videoBox_" + uuid.value);
|
|
10020
|
+
if (!canvasDom) {
|
|
10021
|
+
canvasDom = document.createElement("canvas");
|
|
10022
|
+
canvasDom.id = "canvas_" + uuid.value;
|
|
10023
|
+
canvasDom.width = box.offsetWidth;
|
|
10024
|
+
canvasDom.height = box.offsetHeight;
|
|
10025
|
+
canvasDom.style.position = "absolute";
|
|
10026
|
+
canvasDom.style.top = "0";
|
|
10027
|
+
canvasDom.style.left = "0";
|
|
10028
|
+
canvasDom.style.zIndex = "999";
|
|
10029
|
+
canvasDom.style.pointerEvents = "none";
|
|
10030
|
+
box.appendChild(canvasDom);
|
|
10031
|
+
}
|
|
10032
|
+
if (!textBox) {
|
|
10033
|
+
textBox = document.createElement("div");
|
|
10034
|
+
textBox.id = "textBox_" + uuid.value;
|
|
10035
|
+
textBox.style.position = "absolute";
|
|
10036
|
+
textBox.style.width = "100%";
|
|
10037
|
+
textBox.style.left = "0";
|
|
10038
|
+
textBox.style.zIndex = "999";
|
|
10039
|
+
textBox.style.pointerEvents = "none";
|
|
10040
|
+
box.appendChild(textBox);
|
|
10041
|
+
}
|
|
10042
|
+
return {
|
|
10043
|
+
canvasDom,
|
|
10044
|
+
textBox,
|
|
10045
|
+
width: box.offsetWidth,
|
|
10046
|
+
height: box.offsetHeight
|
|
10047
|
+
};
|
|
10048
|
+
};
|
|
10049
|
+
let drawCleanTimer = null;
|
|
10050
|
+
const drawFlog = data => {
|
|
10051
|
+
let {
|
|
10052
|
+
canvasDom: canvasDom2,
|
|
10053
|
+
width,
|
|
10054
|
+
height,
|
|
10055
|
+
textBox: textBox2
|
|
10056
|
+
} = createFlogCanvas();
|
|
10057
|
+
const ctx = canvasDom2.getContext("2d");
|
|
10058
|
+
if (drawCleanTimer) {
|
|
10059
|
+
clearTimeout(drawCleanTimer);
|
|
10060
|
+
ctx.clearRect(0, 0, canvasDom2.width, canvasDom2.height);
|
|
10061
|
+
}
|
|
10062
|
+
if (data.bboxes?.length > 0) {
|
|
10063
|
+
(data.bboxes || []).forEach(rect => {
|
|
10064
|
+
ctx.beginPath();
|
|
10065
|
+
ctx.lineWidth = 2;
|
|
10066
|
+
ctx.strokeStyle = rect.color || "red";
|
|
10067
|
+
ctx.fillStyle = rect.color || "red";
|
|
10068
|
+
ctx.rect(rect.xmin * width, rect.ymin * height, (rect.xmax - rect.xmin) * width, (rect.ymax - rect.ymin) * height);
|
|
10069
|
+
ctx.stroke();
|
|
10070
|
+
});
|
|
10071
|
+
}
|
|
10072
|
+
if (data.text) {
|
|
10073
|
+
const fontSize = 14;
|
|
10074
|
+
const margin = 10;
|
|
10075
|
+
const marginTop = height * 0.1 + margin;
|
|
10076
|
+
textBox2.innerHTML = data.text;
|
|
10077
|
+
textBox2.style.top = marginTop + "px";
|
|
10078
|
+
textBox2.style.backgroundColor = "rgba(255, 255, 255, 0.5)";
|
|
10079
|
+
textBox2.style.color = data.text_color || "red";
|
|
10080
|
+
textBox2.style.fontSize = `${fontSize}px`;
|
|
10081
|
+
textBox2.style.padding = `${margin}px`;
|
|
10082
|
+
} else {
|
|
10083
|
+
removeTxtBox();
|
|
10084
|
+
}
|
|
10085
|
+
drawCleanTimer = setTimeout(() => {
|
|
10086
|
+
ctx.clearRect(0, 0, canvasDom2.width, canvasDom2.height);
|
|
10087
|
+
removeTxtBox();
|
|
10088
|
+
}, data.seconds * 1e3);
|
|
10089
|
+
};
|
|
10090
|
+
const removeTxtBox = () => {
|
|
10091
|
+
textBox.innerHTML = "";
|
|
10092
|
+
textBox.remove();
|
|
10093
|
+
textBox = null;
|
|
10094
|
+
};
|
|
10095
|
+
const vlmSwitchKey = vue.computed(() => {
|
|
10096
|
+
return `showVlmInfo_${camera.value?.uuid}`;
|
|
10097
|
+
});
|
|
10098
|
+
vue.watchEffect(() => {
|
|
10099
|
+
if (showVlmInfo.value) {
|
|
10100
|
+
localStorage.removeItem(vlmSwitchKey.value);
|
|
10101
|
+
} else {
|
|
10102
|
+
localStorage.setItem(vlmSwitchKey.value, "false");
|
|
10103
|
+
let {
|
|
10104
|
+
canvasDom: canvasDom2,
|
|
10105
|
+
textBox: textBox2,
|
|
10106
|
+
width,
|
|
10107
|
+
height
|
|
10108
|
+
} = createFlogCanvas();
|
|
10109
|
+
const ctx = canvasDom2.getContext("2d");
|
|
10110
|
+
clearTimeout(drawCleanTimer);
|
|
10111
|
+
removeTxtBox();
|
|
10112
|
+
ctx.clearRect(0, 0, canvasDom2.width, canvasDom2.height);
|
|
10113
|
+
}
|
|
10114
|
+
});
|
|
9950
10115
|
return () => vue.createVNode("div", {
|
|
9951
10116
|
"id": "videoBox_" + uuid.value,
|
|
9952
10117
|
"class": ["videoBox", _prop.alarm ? "alarm" : ""]
|
|
@@ -10003,6 +10168,20 @@ const VideoBoxV2 = vue.defineComponent({
|
|
|
10003
10168
|
}, [_prop.btns.map(btn => {
|
|
10004
10169
|
if (!(camera.value?.brandTypeCode === "MP4" && btn !== "close" && btn !== "fullScreen" && btn !== "look" && btn !== "change")) {
|
|
10005
10170
|
switch (btn) {
|
|
10171
|
+
case "vlm":
|
|
10172
|
+
return vue.createVNode("img", {
|
|
10173
|
+
"title": "\u6253\u5F00/\u5173\u95ED\u591A\u6A21\u6001",
|
|
10174
|
+
"onClick": e => {
|
|
10175
|
+
showVlmInfo.value = !showVlmInfo.value;
|
|
10176
|
+
if (showVlmInfo.value) {
|
|
10177
|
+
initMqtt(camera.value?.ip);
|
|
10178
|
+
} else {
|
|
10179
|
+
Mqtt?.unsubscribe(topic.value);
|
|
10180
|
+
Mqtt = null;
|
|
10181
|
+
}
|
|
10182
|
+
},
|
|
10183
|
+
"src": showVlmInfo.value ? "/micro-assets/inl/video/controls/ai-show.svg" : "/micro-assets/inl/video/controls/ai-hide.svg"
|
|
10184
|
+
}, null);
|
|
10006
10185
|
case "change":
|
|
10007
10186
|
return vue.createVNode("img", {
|
|
10008
10187
|
"title": "\u66F4\u6362\u6444\u50CF\u5934",
|
package/dist/components/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import { loadMicroApp } from 'qiankun';
|
|
|
9
9
|
import dayjs from 'dayjs';
|
|
10
10
|
import 'vite-plugin-qiankun';
|
|
11
11
|
import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper';
|
|
12
|
+
import mqtt from 'mqtt';
|
|
12
13
|
import { XPopup, CommentBlock, setAxiosOption } from '@sszj-temp/mobile';
|
|
13
14
|
import { marked } from 'marked';
|
|
14
15
|
|
|
@@ -9611,6 +9612,33 @@ var Tree = defineComponent({
|
|
|
9611
9612
|
}
|
|
9612
9613
|
});
|
|
9613
9614
|
|
|
9615
|
+
let client = null;
|
|
9616
|
+
const ip = "10.255.9.121";
|
|
9617
|
+
let connectUrl = `ws://${ip}:8083/mqtt`;
|
|
9618
|
+
const useMqtt = async (options = {}) => {
|
|
9619
|
+
if (client) {
|
|
9620
|
+
return client;
|
|
9621
|
+
}
|
|
9622
|
+
return new Promise(async (resolve, reject) => {
|
|
9623
|
+
const mqttOptions = {
|
|
9624
|
+
url: connectUrl,
|
|
9625
|
+
clientId: `llm_${new Date().getTime()}`,
|
|
9626
|
+
username: "admin",
|
|
9627
|
+
password: "admin123",
|
|
9628
|
+
...options
|
|
9629
|
+
};
|
|
9630
|
+
client = mqtt.connect(connectUrl, mqttOptions);
|
|
9631
|
+
client.on("connect", () => {
|
|
9632
|
+
console.log("\u8FDE\u63A5\u6210\u529F");
|
|
9633
|
+
resolve(client);
|
|
9634
|
+
});
|
|
9635
|
+
client.on("error", err => {
|
|
9636
|
+
console.log("\u8FDE\u63A5\u5931\u8D25", err);
|
|
9637
|
+
reject(err);
|
|
9638
|
+
});
|
|
9639
|
+
});
|
|
9640
|
+
};
|
|
9641
|
+
|
|
9614
9642
|
const props$6 = {
|
|
9615
9643
|
// 视频信息|视频源uuid
|
|
9616
9644
|
camera: {
|
|
@@ -9628,7 +9656,7 @@ const props$6 = {
|
|
|
9628
9656
|
// },
|
|
9629
9657
|
btns: {
|
|
9630
9658
|
type: Array,
|
|
9631
|
-
default: ["change", "fill", "look", "stream", "magnify", "direction", "fullScreen", "close"]
|
|
9659
|
+
default: ["vlm", "change", "fill", "look", "stream", "magnify", "direction", "fullScreen", "close"]
|
|
9632
9660
|
},
|
|
9633
9661
|
alarm: {
|
|
9634
9662
|
default: false,
|
|
@@ -9651,6 +9679,7 @@ const VideoBoxV2 = defineComponent({
|
|
|
9651
9679
|
const streamHistory = ref("");
|
|
9652
9680
|
const streams = ref([]);
|
|
9653
9681
|
const showInfo = ref(true);
|
|
9682
|
+
const showVlmInfo = ref(true);
|
|
9654
9683
|
const magnifyBtn = ref(false);
|
|
9655
9684
|
const videoBtns = [[{
|
|
9656
9685
|
text: "lup",
|
|
@@ -9756,10 +9785,25 @@ const VideoBoxV2 = defineComponent({
|
|
|
9756
9785
|
});
|
|
9757
9786
|
camera.value = res.data.data;
|
|
9758
9787
|
streams.value = JSON.parse(camera.value?.brandTypePo?.streamTypeDict || "[]");
|
|
9788
|
+
console.log("vlmSwitchKey.value", vlmSwitchKey.value);
|
|
9789
|
+
console.log("localStorage.getItem(vlmSwitchKey.value)", localStorage.getItem(vlmSwitchKey.value));
|
|
9790
|
+
if (localStorage.getItem(vlmSwitchKey.value) !== "false") {
|
|
9791
|
+
showVlmInfo.value = true;
|
|
9792
|
+
if (camera.value?.ip && showVlmInfo.value) {
|
|
9793
|
+
initMqtt(camera.value?.ip);
|
|
9794
|
+
}
|
|
9795
|
+
} else {
|
|
9796
|
+
showVlmInfo.value = false;
|
|
9797
|
+
}
|
|
9759
9798
|
};
|
|
9760
9799
|
let timeout;
|
|
9761
9800
|
ref(true);
|
|
9762
|
-
onBeforeUnmount(() => {
|
|
9801
|
+
onBeforeUnmount(() => {
|
|
9802
|
+
if (Mqtt) {
|
|
9803
|
+
Mqtt?.unsubscribe(topic.value);
|
|
9804
|
+
Mqtt = null;
|
|
9805
|
+
}
|
|
9806
|
+
});
|
|
9763
9807
|
const resetZoom = () => {
|
|
9764
9808
|
const chooseFieldDom = document.getElementById("chooseField_" + uuid.value);
|
|
9765
9809
|
chooseFieldDom?.remove();
|
|
@@ -9919,6 +9963,126 @@ const VideoBoxV2 = defineComponent({
|
|
|
9919
9963
|
}, null) : ""])]
|
|
9920
9964
|
});
|
|
9921
9965
|
};
|
|
9966
|
+
let Mqtt = null;
|
|
9967
|
+
const topic = ref("");
|
|
9968
|
+
const initMqtt = async ip => {
|
|
9969
|
+
Mqtt = await useMqtt();
|
|
9970
|
+
topic.value = `vlm/${ip}`;
|
|
9971
|
+
Mqtt.subscribe(topic.value, {
|
|
9972
|
+
qos: 2
|
|
9973
|
+
}, err => {
|
|
9974
|
+
if (!err) {
|
|
9975
|
+
console.log(`\u8BA2\u9605\u6210\u529F\u4E3B\u9898:${topic.value}`);
|
|
9976
|
+
} else {
|
|
9977
|
+
console.log(`\u8BA2\u9605\u5931\u8D25:${err}`);
|
|
9978
|
+
}
|
|
9979
|
+
});
|
|
9980
|
+
Mqtt.on("message", onMtMessageFn);
|
|
9981
|
+
};
|
|
9982
|
+
const onMtMessageFn = (topic2, message2) => {
|
|
9983
|
+
const msg = new TextDecoder("utf-8").decode(message2);
|
|
9984
|
+
console.log("msg", JSON.parse(msg));
|
|
9985
|
+
drawFlog(JSON.parse(msg));
|
|
9986
|
+
};
|
|
9987
|
+
let canvasDom = null;
|
|
9988
|
+
let textBox = null;
|
|
9989
|
+
const createFlogCanvas = () => {
|
|
9990
|
+
const box = document.getElementById("videoBox_" + uuid.value);
|
|
9991
|
+
if (!canvasDom) {
|
|
9992
|
+
canvasDom = document.createElement("canvas");
|
|
9993
|
+
canvasDom.id = "canvas_" + uuid.value;
|
|
9994
|
+
canvasDom.width = box.offsetWidth;
|
|
9995
|
+
canvasDom.height = box.offsetHeight;
|
|
9996
|
+
canvasDom.style.position = "absolute";
|
|
9997
|
+
canvasDom.style.top = "0";
|
|
9998
|
+
canvasDom.style.left = "0";
|
|
9999
|
+
canvasDom.style.zIndex = "999";
|
|
10000
|
+
canvasDom.style.pointerEvents = "none";
|
|
10001
|
+
box.appendChild(canvasDom);
|
|
10002
|
+
}
|
|
10003
|
+
if (!textBox) {
|
|
10004
|
+
textBox = document.createElement("div");
|
|
10005
|
+
textBox.id = "textBox_" + uuid.value;
|
|
10006
|
+
textBox.style.position = "absolute";
|
|
10007
|
+
textBox.style.width = "100%";
|
|
10008
|
+
textBox.style.left = "0";
|
|
10009
|
+
textBox.style.zIndex = "999";
|
|
10010
|
+
textBox.style.pointerEvents = "none";
|
|
10011
|
+
box.appendChild(textBox);
|
|
10012
|
+
}
|
|
10013
|
+
return {
|
|
10014
|
+
canvasDom,
|
|
10015
|
+
textBox,
|
|
10016
|
+
width: box.offsetWidth,
|
|
10017
|
+
height: box.offsetHeight
|
|
10018
|
+
};
|
|
10019
|
+
};
|
|
10020
|
+
let drawCleanTimer = null;
|
|
10021
|
+
const drawFlog = data => {
|
|
10022
|
+
let {
|
|
10023
|
+
canvasDom: canvasDom2,
|
|
10024
|
+
width,
|
|
10025
|
+
height,
|
|
10026
|
+
textBox: textBox2
|
|
10027
|
+
} = createFlogCanvas();
|
|
10028
|
+
const ctx = canvasDom2.getContext("2d");
|
|
10029
|
+
if (drawCleanTimer) {
|
|
10030
|
+
clearTimeout(drawCleanTimer);
|
|
10031
|
+
ctx.clearRect(0, 0, canvasDom2.width, canvasDom2.height);
|
|
10032
|
+
}
|
|
10033
|
+
if (data.bboxes?.length > 0) {
|
|
10034
|
+
(data.bboxes || []).forEach(rect => {
|
|
10035
|
+
ctx.beginPath();
|
|
10036
|
+
ctx.lineWidth = 2;
|
|
10037
|
+
ctx.strokeStyle = rect.color || "red";
|
|
10038
|
+
ctx.fillStyle = rect.color || "red";
|
|
10039
|
+
ctx.rect(rect.xmin * width, rect.ymin * height, (rect.xmax - rect.xmin) * width, (rect.ymax - rect.ymin) * height);
|
|
10040
|
+
ctx.stroke();
|
|
10041
|
+
});
|
|
10042
|
+
}
|
|
10043
|
+
if (data.text) {
|
|
10044
|
+
const fontSize = 14;
|
|
10045
|
+
const margin = 10;
|
|
10046
|
+
const marginTop = height * 0.1 + margin;
|
|
10047
|
+
textBox2.innerHTML = data.text;
|
|
10048
|
+
textBox2.style.top = marginTop + "px";
|
|
10049
|
+
textBox2.style.backgroundColor = "rgba(255, 255, 255, 0.5)";
|
|
10050
|
+
textBox2.style.color = data.text_color || "red";
|
|
10051
|
+
textBox2.style.fontSize = `${fontSize}px`;
|
|
10052
|
+
textBox2.style.padding = `${margin}px`;
|
|
10053
|
+
} else {
|
|
10054
|
+
removeTxtBox();
|
|
10055
|
+
}
|
|
10056
|
+
drawCleanTimer = setTimeout(() => {
|
|
10057
|
+
ctx.clearRect(0, 0, canvasDom2.width, canvasDom2.height);
|
|
10058
|
+
removeTxtBox();
|
|
10059
|
+
}, data.seconds * 1e3);
|
|
10060
|
+
};
|
|
10061
|
+
const removeTxtBox = () => {
|
|
10062
|
+
textBox.innerHTML = "";
|
|
10063
|
+
textBox.remove();
|
|
10064
|
+
textBox = null;
|
|
10065
|
+
};
|
|
10066
|
+
const vlmSwitchKey = computed(() => {
|
|
10067
|
+
return `showVlmInfo_${camera.value?.uuid}`;
|
|
10068
|
+
});
|
|
10069
|
+
watchEffect(() => {
|
|
10070
|
+
if (showVlmInfo.value) {
|
|
10071
|
+
localStorage.removeItem(vlmSwitchKey.value);
|
|
10072
|
+
} else {
|
|
10073
|
+
localStorage.setItem(vlmSwitchKey.value, "false");
|
|
10074
|
+
let {
|
|
10075
|
+
canvasDom: canvasDom2,
|
|
10076
|
+
textBox: textBox2,
|
|
10077
|
+
width,
|
|
10078
|
+
height
|
|
10079
|
+
} = createFlogCanvas();
|
|
10080
|
+
const ctx = canvasDom2.getContext("2d");
|
|
10081
|
+
clearTimeout(drawCleanTimer);
|
|
10082
|
+
removeTxtBox();
|
|
10083
|
+
ctx.clearRect(0, 0, canvasDom2.width, canvasDom2.height);
|
|
10084
|
+
}
|
|
10085
|
+
});
|
|
9922
10086
|
return () => createVNode("div", {
|
|
9923
10087
|
"id": "videoBox_" + uuid.value,
|
|
9924
10088
|
"class": ["videoBox", _prop.alarm ? "alarm" : ""]
|
|
@@ -9975,6 +10139,20 @@ const VideoBoxV2 = defineComponent({
|
|
|
9975
10139
|
}, [_prop.btns.map(btn => {
|
|
9976
10140
|
if (!(camera.value?.brandTypeCode === "MP4" && btn !== "close" && btn !== "fullScreen" && btn !== "look" && btn !== "change")) {
|
|
9977
10141
|
switch (btn) {
|
|
10142
|
+
case "vlm":
|
|
10143
|
+
return createVNode("img", {
|
|
10144
|
+
"title": "\u6253\u5F00/\u5173\u95ED\u591A\u6A21\u6001",
|
|
10145
|
+
"onClick": e => {
|
|
10146
|
+
showVlmInfo.value = !showVlmInfo.value;
|
|
10147
|
+
if (showVlmInfo.value) {
|
|
10148
|
+
initMqtt(camera.value?.ip);
|
|
10149
|
+
} else {
|
|
10150
|
+
Mqtt?.unsubscribe(topic.value);
|
|
10151
|
+
Mqtt = null;
|
|
10152
|
+
}
|
|
10153
|
+
},
|
|
10154
|
+
"src": showVlmInfo.value ? "/micro-assets/inl/video/controls/ai-show.svg" : "/micro-assets/inl/video/controls/ai-hide.svg"
|
|
10155
|
+
}, null);
|
|
9978
10156
|
case "change":
|
|
9979
10157
|
return createVNode("img", {
|
|
9980
10158
|
"title": "\u66F4\u6362\u6444\u50CF\u5934",
|