<template>
  <div>
    <!-- <h2>正在登陆中，请稍等。</h2> -->
  </div>
</template>

<script>

export default {
  name: 'SigninOidc',
  data: function() {
    return {
      redirect: undefined,
      otherQuery: {}
    }
  },
  watch: {
    // $route: {
    //   handler: function(route) {
    //     const query = route.query;
    //     if (query) {
    //       this.redirect = query.redirect;
    //       this.otherQuery = this.getOtherQuery(query);
    //     }
    //   },
    //   immediate: true
    // }
  },
  async mounted() {
    const loading = this.$loading({
      lock: true,
      text: '登陆中...',
      spinner: 'el-icon-loading',
      background: 'rgba(0, 0, 0, 0.7)'
    })
    await this.$store.dispatch('user/loginCallbackOidc').then(() => {
      loading.close()
      this.$router.push({ path: '/' })
    })
  },
  methods: {
    getOtherQuery(query) {
      return Object.keys(query).reduce((acc, cur) => {
        if (cur !== 'redirect') {
          acc[cur] = query[cur]
        }
        return acc
      }, {})
    }
  }
}
</script>

<style scoped></style>
