| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <template>
- <div class="l-flex--col">
- <tabs
- v-if="useTabs"
- :items="tabs"
- :active.sync="active"
- />
- <div class="l-flex__fill u-overflow-y--auto">
- <component
- :is="activeComponent"
- v-bind="$attrs"
- />
- </div>
- </div>
- </template>
- <script>
- import {
- startSensor,
- stopSensor
- } from '../monitor'
- import Tabs from './Tabs'
- import DeviceRuntime from './DeviceRuntime'
- import DeviceSensor from './DeviceSensor'
- export default {
- name: 'DeviceStatus',
- components: {
- Tabs,
- DeviceRuntime,
- DeviceSensor
- },
- data () {
- const tabs = [
- { key: 'runtime', name: '播控器状态' },
- __SENSOR__ ? { key: 'sensor', name: '传感器状态' } : null
- ].filter(val => val)
- return {
- tabs,
- active: tabs[0].key
- }
- },
- computed: {
- useTabs () {
- return this.tabs.length > 1
- },
- activeComponent () {
- switch (this.active) {
- case 'runtime':
- return 'DeviceRuntime'
- case 'sensor':
- return 'DeviceSensor'
- default:
- return null
- }
- }
- },
- activated () {
- startSensor()
- },
- deactivated () {
- stopSensor()
- }
- }
- </script>
- <style lang="scss">
- .c-runtime {
- padding: 12px 16px 16px;
- color: $info;
- font-size: 14px;
- line-height: 1;
- .medium {
- font-size: 18px;
- }
- .large {
- font-size: 32px;
- }
- &__icon {
- display: inline-block;
- width: 32px;
- height: 32px;
- margin-right: 8px;
- background-position: 0 0;
- background-size: 100% 100%;
- background-repeat: no-repeat;
- &.running {
- background-image: url("~@/assets/icon_condition.png");
- }
- &.screenshot {
- background-image: url("~@/assets/icon_image.png");
- }
- &.download {
- background-image: url("~@/assets/icon_download.png");
- }
- &.temperature {
- background-image: url("~@/assets/icon_temperature.png");
- }
- &.smoke {
- background-image: url("~@/assets/icon_smoke.png");
- }
- &.flooding {
- background-image: url("~@/assets/icon_flooding.png");
- }
- &.light {
- background-image: url("~@/assets/icon_light.png");
- }
- }
- &__title {
- color: $info--dark;
- }
- &__list {
- color: $blue;
- font-size: 18px;
- }
- }
- </style>
|