<template>
  <transition name="fade">
    <router-view class="wrapper"></router-view>
  </transition>
</template>

<script>
  export default {
    name: 'app',
    watch: {
      // 监听路由
      $route: {
        handler: function (val, oldVal) {
          // 从首页离开清除首页的计时器
          if (oldVal.name === 'dashboard') {
            if (Window.indexinterval) {
              clearInterval(Window.indexinterval)
            }
          } else if (oldVal.name === 'equipment') { // 从设备列表离开清除设备列表的计时器
            if (Window.equimentinterval) {
              clearInterval(Window.equimentinterval)
            }
          } else if (oldVal.name === 'alerts') { // 从报警器列表离开清除报警器列表的计时器
            if (Window.alerterinterval) {
              clearInterval(Window.alerterinterval)
            }
          } else if (oldVal.name === 'management') { // 从账户一览离开清除账户一览的计时器
            if (Window.managementinterval) {
              clearInterval(Window.managementinterval)
            }
          }
        },
        // 深度观察监听
        deep: true
      }
    }
  }
</script>
