<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
export default {
  name: 'App',
  components: {},
  data() {
    return {};
  },
  created() {
    this.initDataFun(); // 初始化数据
  },
  mounted() {},
  methods: {
    // 初始化数据
    initDataFun() {
      // 从session中取工种信息，存在即存储到vuex中
      let ENGINEERING_WORK_LIST = sessionStorage.getItem(
        'ENGINEERING_WORK_LIST'
      );
      if (ENGINEERING_WORK_LIST) {
        this.$store.commit(
          'common/SET_ENGINEERING_WORK_LIST',
          JSON.parse(ENGINEERING_WORK_LIST)
        );
      }
      // 从session中取试题类型信息，存在即存储到vuex中
      let EXAM_QUESTION_TYPE_CONDITION_PARENT = sessionStorage.getItem(
        'EXAM_QUESTION_TYPE_CONDITION_PARENT'
      );
      if (EXAM_QUESTION_TYPE_CONDITION_PARENT) {
        this.$store.commit(
          'common/SET_EXAM_QUESTION_TYPE_CONDITION_PARENT',
          JSON.parse(EXAM_QUESTION_TYPE_CONDITION_PARENT)
        );
      }

      this.$store.commit('common/SET_SCREENHEIGHT', document.body.clientHeight); // 赋值网页内容区域可视化高度值
      this.$store.commit('common/SET_SCREENWIDTH', document.body.clientWidth); // 赋值网页内容区域可视化宽度值
      // 监听屏幕高度变化，同步表单高度
      window.onresize = () => {
        return (() => {
          this.$store.commit(
            'common/SET_SCREENHEIGHT',
            document.body.clientHeight
          ); // 赋值网页内容区域可视化高度值
          this.$store.commit(
            'common/SET_SCREENWIDTH',
            document.body.clientWidth
          ); // 赋值网页内容区域可视化宽度值
          this.$store.commit('common/SET_WINDOW_ONRESIZE'); // 通知网页内容区域可视化宽高有变化
        })();
      };
    },
  },
};
</script>

<style>
#app {
}
</style>
