index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <pannel class="fence-location-container">
  3. <template v-slot:title>
  4. 围栏闯禁事件
  5. </template>
  6. <template v-slot:action>
  7. </template>
  8. <template v-slot:content>
  9. <div>
  10. <socket-message :onMessage="onMessage" :ws="ws"></socket-message>
  11. </div>
  12. </template>
  13. </pannel>
  14. </template>
  15. <script>
  16. import { listFenceVioEvt } from '@/api/bd/fenceVioEvt';
  17. import SocketMessage from '@/components/WebsocketMessage/index.vue';
  18. import Pannel from '@/views/bd/pannel/index.vue';
  19. import FingerprintJS from '@fingerprintjs/fingerprintjs';
  20. import dayjs from 'dayjs';
  21. export default {
  22. name: 'fenceVioEvt',
  23. components: {
  24. SocketMessage,
  25. Pannel,
  26. },
  27. data() {
  28. return {
  29. evtList: [],
  30. fp: null,
  31. ws: null,
  32. };
  33. },
  34. // 组件卸载前清空图层信息
  35. beforeDestroy() {
  36. },
  37. created() {
  38. },
  39. mounted() {
  40. this.getFenceVioEvtList();
  41. this.getFingerprint();
  42. },
  43. methods: {
  44. dayjs,
  45. async getFenceVioEvtList() {
  46. const { rows } = await listFenceVioEvt({
  47. pageNum: 1,
  48. pageSize: 10,
  49. });
  50. this.evtList = rows;
  51. },
  52. async getFingerprint() {
  53. // 初始化FingerprintJS
  54. const fp = await FingerprintJS.load();
  55. // 获取访问者的指纹
  56. const result = await fp.get();
  57. // 配置
  58. const {
  59. osCpu,
  60. webGlBasics,
  61. languages,
  62. audioBaseLatency,
  63. reducedTransparency,
  64. vendor,
  65. vendorFlavors,
  66. fonts,
  67. fontPreferences,
  68. plugins,
  69. forcedColors,
  70. domBlockers,
  71. pdfViewerEnabled,
  72. audio,
  73. canvas,
  74. webGlExtensions,
  75. math,
  76. ...components
  77. } = result.components;
  78. const extendedComponents = {
  79. ...components,
  80. };
  81. const fingerprintId = FingerprintJS.hashComponents(extendedComponents);
  82. this.ws = `/ws/evt/${fingerprintId}`;
  83. },
  84. onMessage(a) {
  85. const data = JSON.parse(a.data);
  86. this.$notify({
  87. title: '警告',
  88. message: `${data.msg.fenceName}发生闯禁事件。`,
  89. type: 'warning',
  90. });
  91. this.getFenceVioEvtList();
  92. },
  93. },
  94. };
  95. </script>
  96. <style lang="scss" src="./index.scss" />