feat:gitee绑定使用postMessage通信
This commit is contained in:
@@ -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 }
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user