DeviceStatus.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div class="l-flex--col">
  3. <tabs
  4. v-if="useTabs"
  5. :items="tabs"
  6. :active.sync="active"
  7. />
  8. <div class="l-flex__fill u-overflow-y--auto">
  9. <component
  10. :is="activeComponent"
  11. v-bind="$attrs"
  12. />
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. import {
  18. startSensor,
  19. stopSensor
  20. } from '../monitor'
  21. import Tabs from './Tabs'
  22. import DeviceRuntime from './DeviceRuntime'
  23. import DeviceSensor from './DeviceSensor'
  24. export default {
  25. name: 'DeviceStatus',
  26. components: {
  27. Tabs,
  28. DeviceRuntime,
  29. DeviceSensor
  30. },
  31. data () {
  32. const tabs = [
  33. { key: 'runtime', name: '播控器状态' },
  34. __SENSOR__ ? { key: 'sensor', name: '传感器状态' } : null
  35. ].filter(val => val)
  36. return {
  37. tabs,
  38. active: tabs[0].key
  39. }
  40. },
  41. computed: {
  42. useTabs () {
  43. return this.tabs.length > 1
  44. },
  45. activeComponent () {
  46. switch (this.active) {
  47. case 'runtime':
  48. return 'DeviceRuntime'
  49. case 'sensor':
  50. return 'DeviceSensor'
  51. default:
  52. return null
  53. }
  54. }
  55. },
  56. activated () {
  57. startSensor()
  58. },
  59. deactivated () {
  60. stopSensor()
  61. }
  62. }
  63. </script>
  64. <style lang="scss">
  65. .c-runtime {
  66. padding: 12px 16px 16px;
  67. color: $info;
  68. font-size: 14px;
  69. line-height: 1;
  70. .medium {
  71. font-size: 18px;
  72. }
  73. .large {
  74. font-size: 32px;
  75. }
  76. &__icon {
  77. display: inline-block;
  78. width: 32px;
  79. height: 32px;
  80. margin-right: 8px;
  81. background-position: 0 0;
  82. background-size: 100% 100%;
  83. background-repeat: no-repeat;
  84. &.running {
  85. background-image: url("~@/assets/icon_condition.png");
  86. }
  87. &.screenshot {
  88. background-image: url("~@/assets/icon_image.png");
  89. }
  90. &.download {
  91. background-image: url("~@/assets/icon_download.png");
  92. }
  93. &.temperature {
  94. background-image: url("~@/assets/icon_temperature.png");
  95. }
  96. &.smoke {
  97. background-image: url("~@/assets/icon_smoke.png");
  98. }
  99. &.flooding {
  100. background-image: url("~@/assets/icon_flooding.png");
  101. }
  102. &.light {
  103. background-image: url("~@/assets/icon_light.png");
  104. }
  105. }
  106. &__title {
  107. color: $info--dark;
  108. }
  109. &__list {
  110. color: $blue;
  111. font-size: 18px;
  112. }
  113. }
  114. </style>