BroadcastOverlay.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <Teleport to="body">
  3. <div v-if="show" class="broadcast-bar" @click.stop>
  4. <!-- 左侧状态标签 -->
  5. <div class="bar-status">
  6. <span class="voice-dot"></span>
  7. <span>正在播报</span>
  8. </div>
  9. <!-- 中间内容区 -->
  10. <div class="bar-content">
  11. <div class="bar-title">{{ displayTitle }}</div>
  12. <div class="bar-text">{{ broadcast?.content }}</div>
  13. </div>
  14. <!-- 右侧音频波纹 -->
  15. <div class="bar-wave">
  16. <span></span>
  17. <span></span>
  18. <span></span>
  19. </div>
  20. </div>
  21. </Teleport>
  22. </template>
  23. <script setup>
  24. import { computed } from 'vue'
  25. const props = defineProps({
  26. broadcast: {
  27. type: Object,
  28. default: () => ({})
  29. }
  30. })
  31. // 是否显示播报条
  32. const show = computed(() => {
  33. return !!(
  34. props.broadcast &&
  35. props.broadcast.broadcasting === true &&
  36. !!props.broadcast.audioUrl
  37. )
  38. })
  39. // 显示标题
  40. const displayTitle = computed(() => {
  41. return props.broadcast?.title || '通知播报'
  42. })
  43. </script>
  44. <style scoped>
  45. .broadcast-bar {
  46. position: fixed;
  47. left: 50%;
  48. bottom: 128px;
  49. transform: translateX(-50%);
  50. z-index: 1000;
  51. width: min(780px, calc(100vw - 120px));
  52. min-height: 86px;
  53. padding: 14px 22px;
  54. border-radius: 26px;
  55. background: rgba(15, 23, 42, 0.72);
  56. border: 1px solid rgba(255, 255, 255, 0.18);
  57. box-shadow: 0 14px 44px rgba(0, 0, 0, 0.28);
  58. backdrop-filter: blur(14px);
  59. -webkit-backdrop-filter: blur(14px);
  60. display: flex;
  61. align-items: center;
  62. gap: 20px;
  63. }
  64. /* 左侧状态标签 */
  65. .bar-status {
  66. flex-shrink: 0;
  67. display: flex;
  68. align-items: center;
  69. gap: 10px;
  70. padding: 7px 14px;
  71. border-radius: 999px;
  72. background: rgba(47, 142, 229, 0.82);
  73. color: #fff;
  74. font-size: 17px;
  75. font-weight: 800;
  76. white-space: nowrap;
  77. }
  78. .voice-dot {
  79. width: 8px;
  80. height: 8px;
  81. border-radius: 50%;
  82. background: #fff;
  83. box-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
  84. animation: voicePulse 1.4s ease-in-out infinite;
  85. }
  86. /* 中间内容区 */
  87. .bar-content {
  88. flex: 1;
  89. min-width: 0;
  90. }
  91. .bar-title {
  92. font-size: 24px;
  93. font-weight: 900;
  94. color: rgba(255, 255, 255, 0.96);
  95. line-height: 1.2;
  96. margin-bottom: 5px;
  97. white-space: nowrap;
  98. overflow: hidden;
  99. text-overflow: ellipsis;
  100. }
  101. .bar-text {
  102. font-size: 19px;
  103. font-weight: 500;
  104. color: rgba(255, 255, 255, 0.78);
  105. line-height: 1.35;
  106. display: -webkit-box;
  107. -webkit-line-clamp: 2;
  108. -webkit-box-orient: vertical;
  109. overflow: hidden;
  110. }
  111. /* 右侧音频波纹 */
  112. .bar-wave {
  113. flex-shrink: 0;
  114. display: flex;
  115. align-items: center;
  116. gap: 5px;
  117. width: 36px;
  118. height: 30px;
  119. opacity: 0.8;
  120. }
  121. .bar-wave span {
  122. width: 5px;
  123. height: 14px;
  124. border-radius: 999px;
  125. background: rgba(255, 255, 255, 0.9);
  126. animation: waveMove 1s ease-in-out infinite;
  127. }
  128. .bar-wave span:nth-child(2) {
  129. animation-delay: 0.15s;
  130. }
  131. .bar-wave span:nth-child(3) {
  132. animation-delay: 0.3s;
  133. }
  134. @keyframes voicePulse {
  135. 0%, 100% {
  136. opacity: 1;
  137. transform: scale(1);
  138. }
  139. 50% {
  140. opacity: 0.55;
  141. transform: scale(0.78);
  142. }
  143. }
  144. @keyframes waveMove {
  145. 0%, 100% {
  146. height: 12px;
  147. opacity: 0.55;
  148. }
  149. 50% {
  150. height: 30px;
  151. opacity: 1;
  152. }
  153. }
  154. /* 响应式适配 */
  155. @media (max-width: 980px), (max-height: 720px) {
  156. .broadcast-bar {
  157. bottom: 122px;
  158. width: min(740px, calc(100vw - 100px));
  159. min-height: 82px;
  160. padding: 13px 20px;
  161. border-radius: 24px;
  162. }
  163. .bar-status {
  164. font-size: 16px;
  165. padding: 7px 13px;
  166. }
  167. .bar-title {
  168. font-size: 23px;
  169. }
  170. .bar-text {
  171. font-size: 18px;
  172. }
  173. }
  174. </style>