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

<script>
import { getXAccessToken } from "@/api/index";
export default {
  name: "App",
  components: {},
  data() {
    return {
      signIn: false,
    };
  },
  methods: {
    getXAccessToken() {
      getXAccessToken(localStorage.getItem("token")).then((res) => {
        if (res.status == 200) {
          localStorage.setItem("Authorization", res.data.access_token);
          this.$nextTick(() => {
            this.signIn = true;
          });
        }
      });
    },
  },
  beforeCreate() {
    console.log(this.$route);
    if (this.$route.query.token_code) {
      localStorage.setItem("token", this.$route.query.token_code);
    }
  },
  mounted() {
    this.getXAccessToken();
  },
};
</script>

<style>
* {
  margin: 0;
  padding: 0;
}
#app {
  margin: 0px;
  background: url(assets/background.png) no-repeat;
  background-size: 100% 100%;
  background-attachment: fixed;
  min-height: 100vh;
}
</style>
