2020-07-10 17:49:51 +08:00
|
|
|
<template lang="pug">
|
|
|
|
.auth(v-html="notice")
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
layout: 'auth',
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
notice: 'Loading...'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async mounted () {
|
|
|
|
const code = this.$route.query.code
|
|
|
|
|
|
|
|
if (!code) { this.notice = '<p style="color: #999">非法访问,缺少授权参数"code"。<p><br><br> <a href="https://www.wyr.me" target="_blank">返回首页<a>' }
|
|
|
|
|
|
|
|
const { data } = await this.$axios.post('/visitor/user/auth', {
|
|
|
|
type: 'github',
|
|
|
|
code
|
|
|
|
})
|
|
|
|
|
|
|
|
if (data.status !== 1) {
|
|
|
|
this.notice = '<p style="color: #999">授权失败,请再试一次。<p><br><br> <a href="https://www.wyr.me" target="_blank">返回首页<a>'
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(data)
|
|
|
|
|
2020-07-10 18:01:08 +08:00
|
|
|
window.opener.localStorage.visitorToken = data.token
|
|
|
|
window.opener.authSuccess(data)
|
|
|
|
window.close()
|
|
|
|
|
2020-07-10 17:49:51 +08:00
|
|
|
this.$finishLoad()
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
|
|
|
.auth
|
|
|
|
width 100%
|
|
|
|
height 100%
|
|
|
|
padding 50px
|
|
|
|
</style>
|