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

<script>
  import {mapGetters} from 'vuex'

  export default {
    name: 'App',
    computed: {
      ...mapGetters(['activeIndex','isLoading'])
    },
    provide() {
      return{
        reload: this.reload
      }
    },
    data() {
      return {
        isRouterAlive: true
      }
    },
    watch: {
      $route(to, from) {
        if (to.meta.menuIndex) {
          this.$store.commit('app/SET_ACTIVEINDEX', to.meta.menuIndex)
        } else {
          this.$store.commit('app/SET_ACTIVEINDEX', to.path)
        }
      }
    },
    methods: {
      //页面重新载入函数
      reload() {
        this.isRouterAlive = false;
        this.$nextTick(function () {
          this.isRouterAlive = true
        })
      }
    },

  }
	
	localStorage.setItem('config_ip',window.SITE_CONFIG['config_ip'])
	localStorage.setItem('config_auth_port',window.SITE_CONFIG['config_auth_port'])
	localStorage.setItem('config_public_port',window.SITE_CONFIG['config_public_port'])
	localStorage.setItem('config_backend_port',window.SITE_CONFIG['config_backend_port'])
</script>

