<!-- 移动端 twitter授权登录中间页 -->
<template>
	<div class="welcome">
		<span class="text"></span>
	</div>
</template>

<script>
import { setStorage, storageKey } from '../../utils/help';
export default {
	name: 'authLogin',
	data() {
		return {
			code: '',
		};
	},
	methods: {
		close() {
			window.close();
		},
	},
	mounted() {
		let url = new URL(window.location.href);
		let search = url.search;
		let urlParams = new URLSearchParams(search);
		let verifier = urlParams.get('oauth_verifier');
		if (verifier) {
			setStorage(storageKey.verifier, verifier);
			let time = process.env.NODE_ENV === 'production' ? 200 : 500;
			setTimeout(() => {
				this.close();
			}, time);
		} else {
			// 用户取消 或者 异常进入
			setStorage(storageKey.backFromTwitterLogin, 1);
			this.close();
		}
	},
};
</script>

<style lang="scss" scoped>
body {
	background-color: #f5f5f5;
}

.welcome {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	.text {
		font-size: 22px;
		color: #1d9bf0;
	}
}
</style>
