CloudGroupDropdown.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <div class="group-dropdown pt-2 pb-2">
  3. <!-- 设备分组下拉 -->
  4. <Dropdown key="deviceList" v-model="activeDevice" :isActvie="true" @change="deviceChange" @visible="(visible)=>($emit('dropdownVisibleChange', visible))" :list="deviceGroupList" :dropdownMenuStyle="{ left: '0', top: '30px' }" :activeStyle="activeStyle">
  5. <!-- 触发下拉 -->
  6. <div class="menu-trigger"><div class="device-trigger-ex">全部设备</div><van-icon class="icon-arrow rotate-down" name="play" color="#fff" size="10" /></div>
  7. </Dropdown>
  8. <!-- 清晰度下拉 -->
  9. <Dropdown key="definition" ref="definitionDropdown" @visible="(visible)=>($emit('dropdownVisibleChange', visible))" :dropdownMenuStyle="{ left: '0', top: '30px' }">
  10. <!-- 触发下拉 -->
  11. <div class="menu-trigger">
  12. <div class="definition-trigger-ex">
  13. <span>{{ activeDefinition }}</span>
  14. <!-- 0-50ms绿色;51-200ms黄色;201-999ms红色;最多显示999ms;变色部分为延迟变色 -->
  15. <span class="definition-val" :class="{success: latency < 51, warning: latency > 50 && latency < 201, danger: latency > 200}">{{ latency }}ms</span>
  16. </div>
  17. <van-icon class="icon-arrow rotate-down" name="play" color="#fff" size="10" />
  18. </div>
  19. <!-- 清晰度下拉 -->
  20. <div slot="dropdown-menu">
  21. <DropdownMenu :activeValue="activeDefinition" :list="definitionList" :isActvie="true" :activeStyle="activeStyle" @change="selectFeatures" />
  22. </div>
  23. </Dropdown>
  24. </div>
  25. </template>
  26. <script>
  27. /**
  28. * 云机分组下拉框
  29. */
  30. // 引入自定义下拉项目组件
  31. import DropdownMenu from './DropdownMenu.vue'
  32. export default {
  33. name: 'CloudGroupDropdown',
  34. components: {
  35. DropdownMenu,
  36. },
  37. props: {
  38. // 拉流渲染引擎实例
  39. engine: {
  40. type: Object,
  41. default: () => ({})
  42. },
  43. // 网络延迟
  44. latency: {
  45. type: Number,
  46. default: 0,
  47. },
  48. // 设备分组下拉菜单数据
  49. deviceGroupList: {
  50. type: Array,
  51. default: () => ([{
  52. label: "批量操作批量操作批量操作",
  53. icon: 'batchOperation_icon',
  54. value: 'batchOperation'
  55. }, {
  56. label: "显示模式",
  57. icon: 'showMode_icon',
  58. value: 'showMode'
  59. }])
  60. },
  61. // 清晰度默认值
  62. definitionValue: {
  63. type: String,
  64. default: ()=> localStorage.getItem('definitionValue') ?? '自动',
  65. },
  66. // 清晰度选项列表
  67. definitionList: {
  68. type: Array,
  69. default: () => [{
  70. label: '自动',
  71. value: '720P',
  72. bitrate: 2800, // 码率
  73. fps: 30, // 帧率
  74. width: 720, // 宽度
  75. height: 1280, // 高度
  76. }, {
  77. label: '高清',
  78. value: '720P',
  79. bitrate: 2800, // 码率
  80. fps: 30, // 帧率
  81. width: 720, // 宽度
  82. height: 1280, // 高度
  83. }, {
  84. label: '标清',
  85. value: '540P',
  86. bitrate: 1500, // 码率
  87. fps: 25, // 帧率
  88. width: 540, // 宽度
  89. height: 960, // 高度
  90. }, {
  91. label: '流畅',
  92. value: '360P',
  93. bitrate: 1000, // 码率
  94. fps: 20, // 帧率
  95. width: 360, // 宽度
  96. height: 640, // 高度
  97. }]
  98. },
  99. },
  100. data() {
  101. return {
  102. // 高亮项样式
  103. activeStyle: {
  104. color: '#FEAE4D',
  105. },
  106. activeDevice: 'batchOperation', // 当前选中的设备分组
  107. activeDefinition: this.definitionValue, // 当前选中的清晰度
  108. }
  109. },
  110. methods: {
  111. // 设备分组下拉框变化回调
  112. deviceChange(val) {
  113. console.log('设备分组变化:', val);
  114. this.activeDevice = val;
  115. },
  116. // 选择清晰度
  117. selectFeatures(item) {
  118. // 更新清晰度值
  119. this.activeDefinition = item.label;
  120. localStorage.setItem('definitionValue', item.label);
  121. // 设置码率
  122. this.setBitrate(item);
  123. // 关闭清晰度下拉框
  124. this.$refs.definitionDropdown.visible = false;
  125. },
  126. // 设置码率
  127. setBitrate({width, height, fps, bitrate, label}) {
  128. // 设置码率和是否允许自动
  129. this.engine?.setCustomBitrate(bitrate, label === '自动');
  130. // 设置编码器分辨率和帧率
  131. this.engine?.setEncoderSize({
  132. width,
  133. height,
  134. fps,
  135. });
  136. },
  137. },
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. .group-dropdown{
  142. display: flex;
  143. justify-content: space-around;
  144. }
  145. .menu-trigger{
  146. background-color: #5C5C5C;
  147. box-shadow: 0px 0px 30px 0px #1E2022;
  148. border-radius: 14px;
  149. padding: 6px 15px;
  150. display: inline-block;
  151. font-weight: 400;
  152. font-size: 12px;
  153. color: #F9F9F9;
  154. // 设备分组触发下拉
  155. .device-trigger-ex{
  156. display: inline-block;
  157. text-align: left;
  158. width: 88px;
  159. }
  160. // 清晰度触发下拉
  161. .definition-trigger-ex{
  162. display: inline-flex;
  163. justify-content: space-between;
  164. width: 94px;
  165. // 0-50ms绿色;51-200ms黄色;201-999ms红色;最多显示999ms;变色部分为延迟变色
  166. .definition-val{
  167. &.danger{
  168. color: #FF2627;
  169. }
  170. &.warning{
  171. color: #FF9800;
  172. }
  173. &.success{
  174. color: #44E2B1;
  175. }
  176. }
  177. }
  178. .icon-arrow{
  179. transition: transform 0.2s ease;
  180. &.rotate-down{
  181. transform: rotate(90deg);
  182. }
  183. &.rotate-up{
  184. transform: rotate(0270deg);
  185. }
  186. }
  187. }
  188. </style>