DefaultTip.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <div class="tip-content">
  3. <span v-show="isDefault">默认摄像头</span>
  4. <span>{{ positionText }}</span>
  5. <span>{{ sizeText }}</span>
  6. <div v-if="props.position === TipPositionEnum.TOP" class="tip-narrow bottom"></div>
  7. <div v-else-if="props.position === TipPositionEnum.BOTTOM" class="tip-narrow top"></div>
  8. <div v-else-if="props.position === TipPositionEnum.RIGHT" class="tip-narrow left"></div>
  9. <div v-else class="tip-narrow right"></div>
  10. </div>
  11. </template>
  12. <script setup lang="ts">
  13. import { computed } from 'vue';
  14. import { TipPositionEnum, camerasGroupType } from '../type';
  15. const props = withDefaults(defineProps<{ position: TipPositionEnum; isDefault: boolean, cameraInfo: camerasGroupType | undefined }>(), {
  16. position: TipPositionEnum.TOP,
  17. });
  18. const positionText = computed(() => {
  19. const cameraInfo = props.cameraInfo;
  20. if (!cameraInfo) return ''
  21. const x = cameraInfo.groupConfig.x?.toFixed(2);
  22. const y = cameraInfo.groupConfig.y?.toFixed(2);
  23. return `位置:(x:${x},y:${y})`
  24. })
  25. const sizeText = computed(() => {
  26. const cameraInfo = props.cameraInfo;
  27. if (!cameraInfo) return ''
  28. const scaleX = cameraInfo.groupConfig.scaleX ? cameraInfo.groupConfig.scaleX : 1;
  29. const scaleY = cameraInfo.groupConfig.scaleY ? cameraInfo.groupConfig.scaleY : 1;
  30. const w = Math.round(cameraInfo.config.width! * scaleX)
  31. const h = Math.round(cameraInfo.config.height! * scaleY)
  32. return `大小:(w:${w},h:${h})`
  33. })
  34. </script>
  35. <style scoped lang="scss">
  36. .tip-content {
  37. position: relative;
  38. padding: 5px;
  39. background-color: #3c3c3d;
  40. border-radius: 8px;
  41. display: flex;
  42. flex-direction: column;
  43. justify-content: center;
  44. align-items: center;
  45. font-size: 14px;
  46. font-weight: 400;
  47. color: #ffffff;
  48. margin: 5px;
  49. span {
  50. white-space: nowrap;
  51. }
  52. }
  53. .tip-narrow {
  54. position: absolute;
  55. border: 5px solid transparent;
  56. &.bottom {
  57. top: 100%;
  58. left: 50%;
  59. border-top-color: #3c3c3d;
  60. transform: translateX(-50%);
  61. }
  62. &.top {
  63. top: 0%;
  64. left: 50%;
  65. border-bottom-color: #3c3c3d;
  66. transform: translate(-50%, -100%);
  67. }
  68. &.left {
  69. top: 50%;
  70. left: 0%;
  71. border-right-color: #3c3c3d;
  72. transform: translate(-100%, -50%);
  73. }
  74. &.right {
  75. top: 50%;
  76. right: 0%;
  77. border-left-color: #3c3c3d;
  78. transform: translate(100%, -50%);
  79. }
  80. }
  81. </style>