<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() {
      if (this.$route.query.permit_code) {
        localStorage.setItem(
          "PermitAuthorization",
          this.$route.query.permit_code
        );
      }
      if (
        this.$route.query.token_code != localStorage.getItem("token") &&
        !this.$route.query.permit_code &&
        !this.$route.query.api_type
      ) {
        getXAccessToken(this.$route.query.token_code).then((res) => {
          if (res.status == 200) {
            localStorage.setItem("token", this.$route.query.token_code);
            localStorage.setItem("Authorization", res.data.access_token);
            this.$nextTick(() => {
              this.signIn = true;
            });
          }
        });
      } else {
        this.$nextTick(() => {
          this.signIn = true;
        });
      }
    },
  },
  mounted() {
    this.getXAccessToken();
  },
};
</script>

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

*::-webkit-scrollbar {
  display: none;
}
</style>
