<template>
  <div id="app">
     <router-view v-if="isRouterAlive"></router-view>
     <errorPage></errorPage>
  </div>
</template>

<script>
import errorPage from '@components/layout/error_dialog_page'
// import axios from 'axios'
export default {
  name: 'app',
  provide() {
    return {
      reload: this.reload
    }
  },
  data() {
    return {
      isRouterAlive: true,
      setting: {}
    }
  },
  mounted() {
    // this.get_setting()
  },
  methods: {
    // 获取语言包
    // get_lang() {
    //   this.$API.get('mesAPI/pb_resource/query_list/').then(res => {
    //     localStorage.lang = JSON.stringify(res.data)
    //     this.reload()
    //   })
    // },
    // 获取默认语言
    // get_setting() {
    //   axios.get('static/setting.json').then(res => {
    //     this.setting = res.data
    //     sessionStorage.setting = JSON.stringify(this.setting)
    //     axios.defaults.headers.common['user_info'] = sessionStorage.getItem('user_info')
    //       ? sessionStorage.getItem('user_info')
    //       : `{"lang": "${res.data.lang}"}`
    //     this.get_lang()
    //   })
    // },
    reload() {
      this.isRouterAlive = false
      this.$nextTick(_ => {
        this.isRouterAlive = true
      })
    }
  },
  components: { errorPage },
  computed: {
    key() {
      return this.$route.name ? this.$route.name + MathRand() : MathRand()
    }
  }
}
function MathRand() {
  let a = ''
  for (var i = 0; i < 6; i++) {
    a += Math.floor(Math.random() * 10)
  }
  return a
}
</script>

<style>
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

</style>
