<template>
  <div id="portalApp">
    <Loader />
    <router-view/>
  </div>
</template>

<script>
import Loader from '@/components/Layout/loader'
// import {routes} from '@/router/routes'
import {mapMutations} from 'vuex'
export default {
  name: 'portalApp',
  components: {
    Loader,
  },
  props: {
    content: String,
    loading: Boolean,
  },
  methods: {
    ...mapMutations([
      'setContent',
      'setLoading',
    ])
  },
  mounted() {
    // /** 持久化存储vuex 使其页面刷新后数据不丢失 */
    // //在页面加载时读取sessionStorage里的状态信息
    // if (sessionStorage.getItem('VuexStore')) {
    //   this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(sessionStorage.getItem('VuexStore'))))
    // }
    // //在页面刷新时将vuex里的信息保存到sessionStorage里
    // window.addEventListener('beforeunload', () => {
    //   sessionStorage.setItem('VuexStore', JSON.stringify(this.$store.state))
    // })
  },
  watch: {
    content(cur) {
      this.setContent(cur)
    },
    loading(cur) {
      this.setLoading(cur)
    }
  }
}
</script>

<style>
#portalApp {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
</style>
