signal.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div class="signal-box">
  3. <ul>
  4. <li
  5. v-for="(item, idex) in list"
  6. :key="idex"
  7. :class="item.class"
  8. />
  9. </ul>
  10. </div>
  11. </template>
  12. <script setup lang="ts">
  13. import { ref, watch } from 'vue'
  14. import useStore from '@/store/index'
  15. const store = useStore()
  16. const list = ref([
  17. {
  18. id: 1,
  19. class: 'signal-default'
  20. },
  21. {
  22. id: 2,
  23. class: 'signal-default'
  24. },
  25. {
  26. id: 3,
  27. class: 'signal-default'
  28. },
  29. {
  30. id: 4,
  31. class: 'signal-default'
  32. },
  33. {
  34. id: 5,
  35. class: 'signal-default'
  36. }
  37. ])
  38. // watch(() => store.mqtt_message, (value: { type: string, data?: { bitrate: number } }) => {
  39. // const { type, data } = value
  40. // // list.value.forEach((el: { id: number, class: string }) => {
  41. // // if (el.id <= v) {
  42. // // if (v <= 2) {
  43. // // el.class = 'signal-red'
  44. // // } else if (v <= 4) {
  45. // // el.class = 'signal-yellow'
  46. // // } else {
  47. // // el.class = 'signal-green'
  48. // // }
  49. // // } else {
  50. // // el.class = 'signal-default'
  51. // // }
  52. // // })
  53. // })
  54. </script>
  55. <style scoped lang="scss">
  56. .signal-box {
  57. display: inline-flex;
  58. align-items: flex-end;
  59. justify-content: center;
  60. height: 23px;
  61. width: 23px;
  62. position: relative;
  63. z-index: 3;
  64. ul {
  65. height: 21px;
  66. margin: 0;
  67. padding: 0;
  68. display: flex;
  69. align-items: flex-end;
  70. }
  71. li {
  72. width: 4px;
  73. height: 5px;
  74. border-radius: 10px;
  75. list-style: none;
  76. margin: 0 0.5px;
  77. @for $i from 1 through 5 {
  78. &:nth-child(#{$i}) {
  79. height:#{ $i * 5 - ($i - 1) }px;
  80. }
  81. }
  82. }
  83. .signal-default {
  84. background: rgba(255, 255, 255, 0.5);
  85. }
  86. .signal-red {
  87. background-color: #ed4014;
  88. }
  89. .signal-yellow {
  90. background-color: #f90;
  91. }
  92. .signal-green {
  93. background-color: #00CED1;
  94. }
  95. }
  96. </style>