<template>
  <div class="container bgcolor">
    <!-- 默认都走缓存 keepAlive：true 缓存-->
    <!-- <template v-if="$route.meta.keepAlive">
      <keep-alive>
        <router-view></router-view>
      </keep-alive>
    </template>
    <template v-else>
      <router-view></router-view>
    </template> -->
    <keep-alive>
      <router-view></router-view>
    </keep-alive>
  </div>
</template>
<script>
export default {
  created() {
    if (this.$route.query.token != undefined) {
      localStorage.setItem('loginName', this.$route.query.token);
    }
    if (process.env.NODE_ENV != 'development') {
      var ua = window.navigator.userAgent.toLowerCase();
      if (ua.match(/MicroMessenger/i) == 'micromessenger' && ua.match(/wxwork/i) == 'wxwork') {
      } else {
        if (process.env.NODE_ENV == 'production') {
          this.$router.push('/err');
        }
      }
    }
  },
  watch: {
    $route(to, from) {
      if (this.$route.query.token != undefined) {
        localStorage.setItem('loginName', this.$route.query.token);
      }
      if (process.env.NODE_ENV != 'development') {
        var ua = window.navigator.userAgent.toLowerCase();
        if (ua.match(/MicroMessenger/i) == 'micromessenger' && ua.match(/wxwork/i) == 'wxwork') {
        } else {
          if (process.env.NODE_ENV == 'production') {
            this.$router.push('/err');
          }
        }
      }
    },
  },
};
</script>
