<template>
  <div class="page-index">
    <pageHeader></pageHeader>
    <div class="second-view">
      <keep-alive>
        <router-view v-if="$route.meta.keeplive"></router-view>
      </keep-alive>
      <router-view v-if="!$route.meta.keeplive"></router-view>
    </div>
  </div>
</template>
<script>
import pageHeader from "@/components/Header.vue";
import { getUserInfo } from "@/api/user.js";
import { mapState, mapGetters, mapActions, mapMutations } from "vuex";
export default {
  components: {
    pageHeader
  },
  created() {
    if (!this.getuserinfo || !this.getuserinfo.pid) this.loadUserInfo();
  },
  computed: {
    ...mapGetters(["getuserinfo"])
  },
  methods: {
    async loadUserInfo() {
      let res = await getUserInfo();
      if (res.ResultCode == 0) {
        await this.setInfo(res.Data);
      }
    },
    ...mapActions({
      setInfo: "user/setUserinfoAndPermissions"
    }),
  }
};
</script>
<style lang="scss" scoped>
.page-index {
  height: 100vh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.second-view {
  padding: 5px 5px 5px;
  // height: 20%;
  // height: 780px;
  // height: 818px;
  // height: 526px;
  flex: 1;
  box-sizing: border-box;
  overflow: auto;
  // background: red;
}
</style>
