<template>
  <div id="app">
<!--        <div v-if="!fullscreen" class="full-screen">-->
<!--          <div class="full-screen-box">-->
<!--            <div class="bth-sure" @click="launchFullScreen">进入全屏</div>-->
<!--          </div>-->
<!--        </div>-->
    <router-view/>

  </div>
</template>

<script>


export default {
  data() {
    return {
      fullscreen: false,
    }
  },
  created() {
    if (sessionStorage.getItem('store')) {
      this.$store.replaceState(
          Object.assign(
              {},
              this.$store.state,
              JSON.parse(sessionStorage.getItem('store'))
          )
      )
    }
    // 在页面刷新时将vuex里的信息保存到sessionStorage里
    // beforeunload事件在页面刷新时先触发
    window.addEventListener('beforeunload', () => {
      sessionStorage.setItem('store', JSON.stringify(this.$store.state))
    })
  },
  methods: {
    launchFullScreen() {
      if (!this.fullscreen) {
        let element = document.documentElement;
        if (element.requestFullscreen) {
          element.requestFullscreen();
        } else if (element.mozRequestFullScreen) {
          element.mozRequestFullScreen();
        } else if (element.webkitRequestFullscreen) {
          element.webkitRequestFullscreen();
        } else if (element.msRequestFullscreen) {
          element.msRequestFullscreen();
        }
        this.fullscreen = true
      }
    }
  }
}
</script>

<style>
@import url('assets/base.css');

html {
  width: 100%;
  height: 100%;
  overflow: scroll;
  background: rgb(9, 9, 48);
}

body {
  width: 1920px;
  height: 1080px;
}

#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  width: 100%;
  height: 100%;
  overflow-y: scroll;
  background-color: #FAFAFF;
  position: relative;
}

.app-container {
  display: flex;
  width: 100%;
  height: 100%;
}
</style>
<style scoped>
.full-screen {
  width: 100%;
  height: 100%;
  position: absolute;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.full-screen-box {
  width: 400px;
  height: 300px;
  margin-top: -150px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bth-sure {
  width: 200px;
  height: 45px;
  background: #2773FE;
  border-radius: 45px;
  line-height: 45px;
  text-align: center;
  font-size: 30px;
  color: #fff;
  cursor: pointer;
}
</style>
