<template>
  <a-config-provider :locale="locale">
    <div id="app">
      <div v-if="envtips!=''&&$route.path.indexOf('bigScreen')<0" class="envtipsBox">{{ envtips }}</div>
      <router-view/>
    </div>
  </a-config-provider>
</template>

<script>
import zhCN from 'ant-design-vue/es/locale/zh_CN'
import { AppDeviceEnquire } from '@/utils/mixin'
import moment from 'moment'
import 'moment/locale/zh-cn'
export default {
  mixins: [AppDeviceEnquire],
  data () {
    return {
      locale: zhCN,
      envtips: '',
      moment
    }
  },
  created () {
    this.envtips = process.env.VUE_APP_ENVTIPS
    console.log(this.$route.path)
    // 在页面加载时读取sessionStorage
    if (sessionStorage.getItem('store')) {
      const data = JSON.parse(sessionStorage.getItem('store'))
      sessionStorage.setItem('Access-Token', data.user.token)
      this.$store.replaceState(Object.assign({}, this.$store.state, data))
    }
    // 在页面刷新时将store保存到sessionStorage里
    window.addEventListener('beforeunload', () => {
      sessionStorage.setItem('store', JSON.stringify(this.$store.state))
    })
    this.$message.config({
      top: `100px`,
      duration: 5,
      maxCount: 3
    })
  }
}
</script>
<style>
  #app {
    height: 100%;
  }
  .envtipsBox{
    position: fixed;
    z-index: 100000;
    background: red;
    width: 230px;
    text-align: center;
    color: #fff;
    font-size: 30px;
    top: 0;
    left: 0;
    width: 50%;
    margin-left: 25%;
  }
</style>
