<template>
  <div id="app">
    <!-- <transition> -->
    <router-view v-if="!isLoggedIn" class="router-view" :key="$route.fullPath" />
    <keep-alive v-else include="FormList,CirculateMatter,MyTask,MyRequest,MyDelegate,newMatterSearch,newMatter">
      <router-view class="router-view" :key="$route.fullPath" />
    </keep-alive>
    
    <!-- </transition> -->
  </div>
</template>

<script>
  export default {
    name: 'App',
    components: {},
    data() {
    return {
      isLoggedIn: false,
    };
    
  },
  watch: {
    //监听路由变化，没有token时去除缓存
    $route(to, from) {
      let token = this.$store.state.login.currentUser && this.$store.state.login.currentUser.token ||'';
      if (token) {
        this.isLoggedIn = true;
      } else {
        this.isLoggedIn = false;
      }
    },
  },
  }
</script>

<style lang="scss">
  #app {
    height: 100%;
    overflow: hidden;
    .router-view {
      & > .box-card:first-child {
        margin-top: 0 !important;
      }
    }
  }
</style>
