inl-ui 0.1.141 → 0.1.142

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 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$3);
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",
@@ -9646,6 +9648,45 @@ var Tree = vue.defineComponent({
9646
9648
  }
9647
9649
  });
9648
9650
 
9651
+ let client = null;
9652
+ const getSystemConfig = async () => {
9653
+ const res = await axios__default["default"].post("api/llm/system/v1/dict/queryBiDict?type=systemConfig", {}, {
9654
+ headers: {
9655
+ Authorization: `Bearer ${sessionStorage.getItem("token") || ""}`,
9656
+ Token: `${sessionStorage.getItem("token") || ""}`
9657
+ }
9658
+ });
9659
+ let config = JSON.parse(res.data?.data || "{}");
9660
+ return config;
9661
+ };
9662
+ const useMqtt = async (options = {}) => {
9663
+ if (client) {
9664
+ return client;
9665
+ }
9666
+ let ip = "";
9667
+ let config = await getSystemConfig();
9668
+ ip = config?.mqttIp;
9669
+ let connectUrl = `ws://${ip}:8083/mqtt`;
9670
+ return new Promise(async (resolve, reject) => {
9671
+ const mqttOptions = {
9672
+ url: connectUrl,
9673
+ clientId: `llm_${new Date().getTime()}`,
9674
+ username: config?.mqttUserName,
9675
+ password: config?.mqttPassword,
9676
+ ...options
9677
+ };
9678
+ client = mqtt__default["default"].connect(connectUrl, mqttOptions);
9679
+ client.on("connect", () => {
9680
+ console.log("\u8FDE\u63A5\u6210\u529F");
9681
+ resolve(client);
9682
+ });
9683
+ client.on("error", err => {
9684
+ console.log("\u8FDE\u63A5\u5931\u8D25", err);
9685
+ reject(err);
9686
+ });
9687
+ });
9688
+ };
9689
+
9649
9690
  const props$6 = {
9650
9691
  // 视频信息|视频源uuid
9651
9692
  camera: {
@@ -9663,7 +9704,7 @@ const props$6 = {
9663
9704
  // },
9664
9705
  btns: {
9665
9706
  type: Array,
9666
- default: ["change", "fill", "look", "stream", "magnify", "direction", "fullScreen", "close"]
9707
+ default: ["vlm", "change", "fill", "look", "stream", "magnify", "direction", "fullScreen", "close"]
9667
9708
  },
9668
9709
  alarm: {
9669
9710
  default: false,
@@ -9681,11 +9722,13 @@ const VideoBoxV2 = vue.defineComponent({
9681
9722
  },
9682
9723
  emits: ["close", "change"],
9683
9724
  setup(_prop, _context) {
9725
+ const videoBoxRef = vue.ref();
9684
9726
  const player = vue.ref();
9685
9727
  const cameraConfig = vue.ref({});
9686
9728
  const streamHistory = vue.ref("");
9687
9729
  const streams = vue.ref([]);
9688
9730
  const showInfo = vue.ref(true);
9731
+ const showVlmInfo = vue.ref(true);
9689
9732
  const magnifyBtn = vue.ref(false);
9690
9733
  const videoBtns = [[{
9691
9734
  text: "lup",
@@ -9714,6 +9757,7 @@ const VideoBoxV2 = vue.defineComponent({
9714
9757
  }]];
9715
9758
  const infos = vue.ref([]);
9716
9759
  const uuid = vue.ref(UUID());
9760
+ let Mqtt = null;
9717
9761
  vue.onMounted(() => {
9718
9762
  showInfo.value = _prop.showInfo;
9719
9763
  });
@@ -9791,10 +9835,26 @@ const VideoBoxV2 = vue.defineComponent({
9791
9835
  });
9792
9836
  camera.value = res.data.data;
9793
9837
  streams.value = JSON.parse(camera.value?.brandTypePo?.streamTypeDict || "[]");
9838
+ console.log("vlmSwitchKey.value", vlmSwitchKey.value);
9839
+ console.log("localStorage.getItem(vlmSwitchKey.value)", localStorage.getItem(vlmSwitchKey.value));
9840
+ clearFlogCanvas();
9841
+ if (localStorage.getItem(vlmSwitchKey.value) !== "false") {
9842
+ showVlmInfo.value = true;
9843
+ if (camera.value?.ip && showVlmInfo.value) {
9844
+ initMqtt(camera.value?.ip);
9845
+ }
9846
+ } else {
9847
+ showVlmInfo.value = false;
9848
+ }
9794
9849
  };
9795
9850
  let timeout;
9796
9851
  vue.ref(true);
9797
- vue.onBeforeUnmount(() => {});
9852
+ vue.onBeforeUnmount(() => {
9853
+ if (Mqtt) {
9854
+ Mqtt?.unsubscribe(topic.value);
9855
+ Mqtt = null;
9856
+ }
9857
+ });
9798
9858
  const resetZoom = () => {
9799
9859
  const chooseFieldDom = document.getElementById("chooseField_" + uuid.value);
9800
9860
  chooseFieldDom?.remove();
@@ -9908,6 +9968,11 @@ const VideoBoxV2 = vue.defineComponent({
9908
9968
  }
9909
9969
  };
9910
9970
  vue.watch(() => _prop.camera, val => {
9971
+ if (Mqtt) {
9972
+ console.log(`\u53D6\u6D88\u8BA2\u9605:${topic.value}`);
9973
+ Mqtt?.unsubscribe(topic.value);
9974
+ Mqtt = null;
9975
+ }
9911
9976
  if (val && Object.keys(val).length != 0) {
9912
9977
  setNewCamera(val);
9913
9978
  showInfo.value = true;
@@ -9958,9 +10023,169 @@ const VideoBoxV2 = vue.defineComponent({
9958
10023
  }, null) : ""])]
9959
10024
  });
9960
10025
  };
10026
+ const topic = vue.ref("");
10027
+ const {
10028
+ isFullscreen,
10029
+ enter,
10030
+ exit,
10031
+ toggle
10032
+ } = core.useFullscreen(videoBoxRef);
10033
+ vue.watch(() => isFullscreen.value, val => {
10034
+ clearFlogCanvas();
10035
+ });
10036
+ const initMqtt = async ip => {
10037
+ Mqtt = await useMqtt();
10038
+ topic.value = `vlm/${ip}`;
10039
+ Mqtt.subscribe(topic.value, {
10040
+ qos: 2
10041
+ }, err => {
10042
+ if (!err) {
10043
+ console.log(`\u8BA2\u9605\u6210\u529F\u4E3B\u9898:${topic.value}`);
10044
+ } else {
10045
+ console.log(`\u8BA2\u9605\u5931\u8D25:${err}`);
10046
+ }
10047
+ });
10048
+ Mqtt.on("message", onMtMessageFn);
10049
+ };
10050
+ const onMtMessageFn = (topicStr, message2) => {
10051
+ if (topicStr !== topic.value) {
10052
+ return;
10053
+ }
10054
+ const msg = new TextDecoder("utf-8").decode(message2);
10055
+ console.log("msg", JSON.parse(msg));
10056
+ drawFlog(JSON.parse(msg));
10057
+ };
10058
+ let canvasDom = null;
10059
+ let textBox = null;
10060
+ const createFlogCanvas = async () => {
10061
+ await vue.nextTick();
10062
+ const box = document.getElementById("videoBox_" + uuid.value);
10063
+ if (!box) {
10064
+ return {
10065
+ canvas: null,
10066
+ textBox: null,
10067
+ width: 0,
10068
+ height: 0
10069
+ };
10070
+ }
10071
+ if (!canvasDom) {
10072
+ canvasDom = document.createElement("canvas");
10073
+ canvasDom.id = "canvas_" + uuid.value;
10074
+ canvasDom.width = box.offsetWidth;
10075
+ canvasDom.height = box.offsetHeight;
10076
+ canvasDom.style.position = "absolute";
10077
+ canvasDom.style.top = "0";
10078
+ canvasDom.style.left = "0";
10079
+ canvasDom.style.zIndex = "999";
10080
+ canvasDom.style.pointerEvents = "none";
10081
+ box.appendChild(canvasDom);
10082
+ }
10083
+ if (!textBox) {
10084
+ textBox = document.createElement("div");
10085
+ textBox.id = "textBox_" + uuid.value;
10086
+ textBox.style.position = "absolute";
10087
+ textBox.style.left = "0";
10088
+ textBox.style.zIndex = "1000";
10089
+ textBox.style.pointerEvents = "none";
10090
+ box.appendChild(textBox);
10091
+ }
10092
+ return {
10093
+ canvasDom,
10094
+ textBox,
10095
+ width: box.offsetWidth,
10096
+ height: box.offsetHeight
10097
+ };
10098
+ };
10099
+ const clearFlogCanvas = () => {
10100
+ if (canvasDom) {
10101
+ canvasDom.remove();
10102
+ canvasDom = null;
10103
+ }
10104
+ if (textBox) {
10105
+ textBox.remove();
10106
+ textBox = null;
10107
+ }
10108
+ if (drawCleanTimer) {
10109
+ clearTimeout(drawCleanTimer);
10110
+ drawCleanTimer = null;
10111
+ }
10112
+ };
10113
+ let drawCleanTimer = null;
10114
+ const drawFlog = async data => {
10115
+ let {
10116
+ canvasDom: canvasDom2,
10117
+ width,
10118
+ height,
10119
+ textBox: textBox2
10120
+ } = await createFlogCanvas();
10121
+ if (!canvasDom2) {
10122
+ return;
10123
+ }
10124
+ const ctx = canvasDom2.getContext("2d");
10125
+ if (drawCleanTimer) {
10126
+ clearTimeout(drawCleanTimer);
10127
+ ctx.clearRect(0, 0, canvasDom2.width, canvasDom2.height);
10128
+ }
10129
+ if (data.bboxes?.length > 0) {
10130
+ (data.bboxes || []).forEach(rect => {
10131
+ ctx.beginPath();
10132
+ ctx.lineWidth = 2;
10133
+ ctx.strokeStyle = rect.color || "red";
10134
+ ctx.fillStyle = rect.color || "red";
10135
+ ctx.rect(rect.xmin * width, rect.ymin * height, (rect.xmax - rect.xmin) * width, (rect.ymax - rect.ymin) * height);
10136
+ ctx.stroke();
10137
+ });
10138
+ }
10139
+ if (data.text) {
10140
+ const fontSize = 16 * width / 800;
10141
+ const margin = 10;
10142
+ const marginTop = height * 0.1 + margin;
10143
+ textBox2.innerHTML = data.text;
10144
+ textBox2.style.top = marginTop + "px";
10145
+ textBox2.style.backgroundColor = "rgba(255, 255, 255, 0.2)";
10146
+ textBox2.style.color = data.text_color || "black";
10147
+ textBox2.style.fontSize = `${fontSize}px`;
10148
+ textBox2.style.padding = `${margin}px`;
10149
+ } else {
10150
+ removeTxtBox();
10151
+ }
10152
+ drawCleanTimer = setTimeout(() => {
10153
+ ctx.clearRect(0, 0, canvasDom2.width, canvasDom2.height);
10154
+ removeTxtBox();
10155
+ }, data.seconds * 1e3);
10156
+ };
10157
+ const removeTxtBox = () => {
10158
+ textBox.innerHTML = "";
10159
+ textBox.remove();
10160
+ textBox = null;
10161
+ };
10162
+ const vlmSwitchKey = vue.computed(() => {
10163
+ return `showVlmInfo_${camera.value?.uuid}`;
10164
+ });
10165
+ vue.watchEffect(async () => {
10166
+ if (showVlmInfo.value) {
10167
+ localStorage.removeItem(vlmSwitchKey.value);
10168
+ } else {
10169
+ localStorage.setItem(vlmSwitchKey.value, "false");
10170
+ let {
10171
+ canvasDom: canvasDom2,
10172
+ textBox: textBox2,
10173
+ width,
10174
+ height
10175
+ } = await createFlogCanvas();
10176
+ if (!canvasDom2) {
10177
+ return;
10178
+ }
10179
+ const ctx = canvasDom2.getContext("2d");
10180
+ clearTimeout(drawCleanTimer);
10181
+ removeTxtBox();
10182
+ ctx.clearRect(0, 0, canvasDom2.width, canvasDom2.height);
10183
+ }
10184
+ });
9961
10185
  return () => vue.createVNode("div", {
9962
10186
  "id": "videoBox_" + uuid.value,
9963
- "class": ["videoBox", _prop.alarm ? "alarm" : ""]
10187
+ "class": ["videoBox", _prop.alarm ? "alarm" : ""],
10188
+ "ref": videoBoxRef
9964
10189
  }, [camera.value ? vue.createVNode(VideoPlayerV2, {
9965
10190
  "ref": player,
9966
10191
  "domId": uuid.value,
@@ -10003,7 +10228,7 @@ const VideoBoxV2 = vue.defineComponent({
10003
10228
  }, [vue.createVNode("div", null, [info.name ? `${info.name}\uFF1A` : ""]), vue.createVNode("div", {
10004
10229
  "class": "value"
10005
10230
  }, [info.displayValue && info.displayValue !== "null" ? info.displayValue + " " : ""]), vue.createVNode("div", null, [info.unit])]);
10006
- })]) : "", camera.value && vue.createVNode("div", {
10231
+ })]) : "", camera.value && vue.withDirectives(vue.createVNode("div", {
10007
10232
  "class": "footer-min",
10008
10233
  "id": "footer_" + uuid.value
10009
10234
  }, [vue.createVNode("div", {
@@ -10014,6 +10239,20 @@ const VideoBoxV2 = vue.defineComponent({
10014
10239
  }, [_prop.btns.map(btn => {
10015
10240
  if (!(camera.value?.brandTypeCode === "MP4" && btn !== "close" && btn !== "fullScreen" && btn !== "look" && btn !== "change")) {
10016
10241
  switch (btn) {
10242
+ case "vlm":
10243
+ return vue.createVNode("img", {
10244
+ "title": "\u6253\u5F00/\u5173\u95ED\u591A\u6A21\u6001",
10245
+ "onClick": e => {
10246
+ showVlmInfo.value = !showVlmInfo.value;
10247
+ if (showVlmInfo.value) {
10248
+ initMqtt(camera.value?.ip);
10249
+ } else {
10250
+ Mqtt?.unsubscribe(topic.value);
10251
+ Mqtt = null;
10252
+ }
10253
+ },
10254
+ "src": showVlmInfo.value ? "/micro-assets/inl/video/controls/ai-show.svg" : "/micro-assets/inl/video/controls/ai-hide.svg"
10255
+ }, null);
10017
10256
  case "change":
10018
10257
  return vue.createVNode("img", {
10019
10258
  "title": "\u66F4\u6362\u6444\u50CF\u5934",
@@ -10135,7 +10374,7 @@ const VideoBoxV2 = vue.defineComponent({
10135
10374
  return vue.createVNode("img", {
10136
10375
  "onClick": e => {
10137
10376
  e.stopPropagation();
10138
- player.value.videoFull();
10377
+ toggle();
10139
10378
  },
10140
10379
  "src": "/micro-assets/inl/video/putUp.png"
10141
10380
  }, null);
@@ -10148,7 +10387,7 @@ const VideoBoxV2 = vue.defineComponent({
10148
10387
  }, null);
10149
10388
  }
10150
10389
  }
10151
- })])]), renderChangeCamera()]);
10390
+ })])]), [[vue.vShow, !isFullscreen.value]]), renderChangeCamera()]);
10152
10391
  }
10153
10392
  });
10154
10393
  var VideoBoxV2$1 = installComponent(VideoBoxV2, "video-box-v2");