<template>
  <div class="container bgcolor">
    <!-- <keep-alive>
      <router-view :key="$route.fullPath" />
    </keep-alive> -->
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive"></router-view>
  </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>
