From 50d381cab9acc1327947a2efe22a49b79dc5bfaa Mon Sep 17 00:00:00 2001 From: Xwen <929716663@qq.com> Date: Tue, 9 Jan 2024 23:00:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:gitee=E7=BB=91=E5=AE=9A=E4=BD=BF=E7=94=A8p?= =?UTF-8?q?ostMessage=E9=80=9A=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Yi.Bbs.Vue3/src/views/Auth/index.vue | 10 +++++++--- Yi.Bbs.Vue3/src/views/profile/AccountSetting.vue | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Yi.Bbs.Vue3/src/views/Auth/index.vue b/Yi.Bbs.Vue3/src/views/Auth/index.vue index b2fd5939..06d42aa7 100644 --- a/Yi.Bbs.Vue3/src/views/Auth/index.vue +++ b/Yi.Bbs.Vue3/src/views/Auth/index.vue @@ -14,6 +14,7 @@ const type = ref(route.query.state); const message = ref(""); const scheme = ref(""); +const authData = ref(""); watch( () => code.value, async (val) => { @@ -32,13 +33,16 @@ watch( } if (type.value === "0") { const res = await authOtherLogin({ code: val }, scheme.value); - console.log(res, "登录的"); + authData.value = res; } else if (type.value === "1") { const res = await authOtherBind({ code: val }, scheme.value); - console.log(res, "绑定的"); + authData.value = res; } + window.opener.postMessage({ + authData: authData.value, + type: scheme.value, + }); message.value = "授权成功"; - // window.close(); } }, { immediate: true } diff --git a/Yi.Bbs.Vue3/src/views/profile/AccountSetting.vue b/Yi.Bbs.Vue3/src/views/profile/AccountSetting.vue index 659964a4..d75c90f9 100644 --- a/Yi.Bbs.Vue3/src/views/profile/AccountSetting.vue +++ b/Yi.Bbs.Vue3/src/views/profile/AccountSetting.vue @@ -123,11 +123,21 @@ const handleQQLogin = () => { const handleGiteeLogin = () => { window.open( - "https://gitee.com/oauth/authorize?client_id=949f3519969adc5cfe82c209b71300e8e0868e8536f3d7f59195c8f1e5b72502&redirect_uri=https%3A%2F%2Fccnetcore.com%2Fauth%2Fgitee&state=1&response_type=code", + "/auth/gitee?code=907b2b59088678ad07d21561c175b0226c031370ab0b4ba1ae9928ea40148d83&state=1", undefined, - "width=500,height=500,left=50,top=50" + "width=500,height=500,left=50,top=50", + "_black" ); }; + +window.addEventListener("message", async (e) => { + const { authData, type } = e.data; + if (e.data) { + console.log(authData, type, "2333"); + await checkList(); + window.close(); + } +});