|
@@ -17,7 +17,7 @@
|
|
|
<script lang="ts" setup>
|
|
|
import Api from '../static/http/api'
|
|
|
import { postRequest } from '../static/http'
|
|
|
-import { getOauthUrl, createWindow, callBackUrl, getCookie, removeCookie } from '../static/utils'
|
|
|
+import { getOauthUrl, createWindow, callBackUrl } from '../static/utils'
|
|
|
import { getStorage, removeStorage, setStorage, storageKey } from '../static/utils/storage'
|
|
|
import { ref } from 'vue'
|
|
|
import { ElMessage } from 'element-plus'
|
|
@@ -89,14 +89,15 @@ const twitterAuth = () => {
|
|
|
if ( code === 0 ) {
|
|
|
let url = getOauthUrl(data.authToken);
|
|
|
let win = createWindow(url);
|
|
|
- // timer
|
|
|
- clearInterval(timer.value);
|
|
|
- timer.value = setInterval(() => {
|
|
|
- if (win && win.closed) {
|
|
|
- clearInterval(timer.value);
|
|
|
- twitterLogin(data);
|
|
|
- }
|
|
|
- }, 500)
|
|
|
+ win?.addEventListener('message', (e) => {
|
|
|
+ console.log(333, e)
|
|
|
+ })
|
|
|
+ // timer.value = setInterval(() => {
|
|
|
+ // if (win && win.closed) {
|
|
|
+ // clearInterval(timer.value);
|
|
|
+ // twitterLogin(data);
|
|
|
+ // }
|
|
|
+ // }, 500)
|
|
|
} else {
|
|
|
ElMessage({
|
|
|
type: 'error',
|
|
@@ -107,7 +108,7 @@ const twitterAuth = () => {
|
|
|
}
|
|
|
|
|
|
const twitterLogin = (data: { authToken: string, consumerKey: string }) => {
|
|
|
- let verifier = JSON.parse(getCookie(storageKey.verifier));
|
|
|
+ let verifier = getStorage(storageKey.verifier)
|
|
|
if (verifier) {
|
|
|
postRequest(Api.twitterLogin, {
|
|
|
params: {
|
|
@@ -119,7 +120,7 @@ const twitterLogin = (data: { authToken: string, consumerKey: string }) => {
|
|
|
let { code, data, msg } = res;
|
|
|
if ( code === 0 ) {
|
|
|
setStorage(storageKey.userInfo, data);
|
|
|
- removeCookie(storageKey.verifier);
|
|
|
+ removeStorage(storageKey.verifier);
|
|
|
location.href = `/nft/list`
|
|
|
} else {
|
|
|
ElMessage({
|