App.vue 1.1 KB
Newer Older
ibizdev's avatar
ibizdev committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
<template>
  <div id='app'>
    <router-view v-if="isRouterAlive"/>
  </div>
</template>
+<script lang='ts'>
import { Vue, Component, Provide } from 'vue-property-decorator';
import store from '@/store';
import { LoadAppData } from '@/utils';

@Component({
    
})
export default class App extends Vue  {

  /**
   *  控制视图是否显示
   */
  public isRouterAlive:boolean = false;

  /**
   *  向后代注入加载行为
   */
  @Provide()
  public reload = this.viewreload;

  /**
   *  vue生命周期
   */
  public created(){
    this.loadAppData();
  }

  /**
   *  视图重新加载
   */
  public viewreload () {
      this.isRouterAlive = false;
      this.$nextTick(function () {
          this.isRouterAlive = true;
      }) 
  }

  /**
   *  视图加载代码表
   */
  public async loadAppData(){
    const _store:any = store;
    if(_store.state && _store.state.codelists && _store.state.codelists.length >0){
      this.isRouterAlive = true;
      return;
    }else{
      await LoadAppData.getInstance().load(store);
      this.isRouterAlive = true;
    }
  }
 
}
</script>
<style lang='less'>
@import './styles/default.less';
</style>