VideoMonitorBox.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <div class="video-box">
  3. <template v-if="videoSrc">
  4. <video :src="videoSrc" autoplay loop muted class="real-video"></video>
  5. <div class="close-btn" title="关闭视频" @click="handleClose">
  6. ×
  7. </div>
  8. </template>
  9. <template v-else>
  10. <div class="empty-state" @click="handleOpen" title="点击关联视频">
  11. <span class="empty-tag">关联视频</span>
  12. <img :src="require('@/assets/images/camera.png')" alt="camera" class="camera-image" />
  13. </div>
  14. </template>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. name: 'VideoMonitorBox',
  20. props: {
  21. videoUrl: { type: String, default: '' }
  22. },
  23. data() {
  24. return {
  25. videoSrc: null,
  26. }
  27. },
  28. methods: {
  29. // 处理关闭/关联视频的事件
  30. handleClose() {
  31. this.$emit('close');
  32. this.videoSrc = null;
  33. },
  34. handleOpen() {
  35. this.$emit('open');
  36. this.videoSrc = this.videoUrl;
  37. }
  38. }
  39. }
  40. </script>
  41. <style scoped>
  42. .video-box {
  43. background: #112445;
  44. border-radius: 6px;
  45. height: 220px;
  46. position: relative;
  47. overflow: hidden;
  48. border: 1px solid rgba(68, 138, 255, 0.15);
  49. box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
  50. }
  51. .real-video { width: 100%; height: 100%; object-fit: cover; }
  52. .close-btn {
  53. position: absolute;
  54. top: 10px;
  55. right: 10px;
  56. background: rgba(0,0,0,0.6);
  57. color: #fff;
  58. width: 24px;
  59. height: 24px;
  60. border-radius: 50%;
  61. display: flex;
  62. align-items: center;
  63. justify-content: center;
  64. cursor: pointer;
  65. transition: background 0.3s;
  66. z-index: 10;
  67. }
  68. .close-btn:hover { background: rgba(0, 0, 0, 1) }
  69. .empty-state {
  70. display: flex;
  71. flex-direction: column;
  72. align-items: center;
  73. justify-content: center;
  74. height: 100%;
  75. cursor: pointer;
  76. transition: all 0.3s ease;
  77. }
  78. .empty-state:hover {
  79. background: rgba(68, 138, 255, 0.1);
  80. }
  81. .empty-state:hover .empty-tag {
  82. background: rgba(68, 138, 255, 1);
  83. box-shadow: 0 0 10px rgba(68, 138, 255, 0.5);
  84. }
  85. .empty-state:hover .camera-image {
  86. transform: scale(1.05);
  87. transition: transform 0.3s ease;
  88. }
  89. .empty-tag {
  90. background: rgba(68, 138, 255, 0.8);
  91. color: #fff;
  92. padding: 4px 16px;
  93. border-radius: 4px;
  94. font-size: 14px;
  95. margin-bottom: 20px;
  96. letter-spacing: 1px;
  97. transition: all 0.3s ease;
  98. }
  99. .camera-image {
  100. width: 80px;
  101. height: 80px;
  102. object-fit: contain;
  103. opacity: 0.8;
  104. margin-bottom: 20px;
  105. }
  106. </style>