<template>
    <div class="err">
        <div v-if="error">
            <i class="el-icon-warning"></i>
            <p>{{error}}</p>
            <el-button @click="close">关闭当前页面</el-button>
        </div>
    </div>
</template>
<script>
import { authSuccess } from "@/api/accounts/account";
export default {
    data() {
        return {
            error: ''
        }
    },
    created() {
        if (window.location.hash.indexOf('?') !== -1) {
            let url = location.hash?.split('?')[1];
            authSuccess(url).then(response => {
                if (response.data) {
                    let data = response.data
                    if (data) {
                        localStorage.setItem("code", "ok");
                    } else {
                        localStorage.setItem("code", "false");
                    }
                    this.close()
                }
            }).catch(err => {
                console.log(err)
                this.error = err
            });
        }
    },
    methods: {
        close() {
            window.close()
        }
    }
}
</script>

<style lang="scss">
    .err{
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        div{
            display: flex;
            flex-direction: column;
            align-items: center;
            i{
                color: #f76260;
                font-size: 150px;
            }
            p{
                margin-top: 50px;
                font-size: 28px;
            }
        }
        
    }
</style>