Merge branch 'abp' of https://gitee.com/ccnetcore/Yi into abp
This commit is contained in:
@@ -164,5 +164,6 @@ export default function useAuths(opt) {
|
|||||||
logoutFun,
|
logoutFun,
|
||||||
clearStorage,
|
clearStorage,
|
||||||
registerFun,
|
registerFun,
|
||||||
|
loginSuccess,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ const type = ref(route.query.state);
|
|||||||
const message = ref("");
|
const message = ref("");
|
||||||
const scheme = ref("");
|
const scheme = ref("");
|
||||||
const authData = ref("");
|
const authData = ref("");
|
||||||
|
const closeWindow = () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
window.close();
|
||||||
|
}, 2000);
|
||||||
|
};
|
||||||
watch(
|
watch(
|
||||||
() => code.value,
|
() => code.value,
|
||||||
async (val) => {
|
async (val) => {
|
||||||
@@ -31,19 +36,25 @@ watch(
|
|||||||
scheme.value = "QQ";
|
scheme.value = "QQ";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (type.value === "0") {
|
try {
|
||||||
const { data } = await authOtherLogin({ code: val }, scheme.value);
|
if (type.value === "0") {
|
||||||
authData.value = data;
|
const { data } = await authOtherLogin({ code: val }, scheme.value);
|
||||||
} else if (type.value === "1") {
|
authData.value = data;
|
||||||
const { data } = await authOtherBind({ code: val }, scheme.value);
|
} else if (type.value === "1") {
|
||||||
authData.value = data;
|
const { data } = await authOtherBind({ code: val }, scheme.value);
|
||||||
|
authData.value = data;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (error.status === 403) {
|
||||||
|
closeWindow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
window.opener.postMessage({
|
window.opener.postMessage({
|
||||||
authData: JSON.stringify(authData.value),
|
authData: JSON.stringify(authData.value),
|
||||||
type: scheme.value,
|
type: scheme.value,
|
||||||
});
|
});
|
||||||
console.log(authData.value, "我是打开的窗口页");
|
|
||||||
message.value = "授权成功";
|
message.value = "授权成功";
|
||||||
|
closeWindow();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ import useUserStore from "@/stores/user";
|
|||||||
import useConfigStore from "@/stores/config";
|
import useConfigStore from "@/stores/config";
|
||||||
|
|
||||||
const configStore = useConfigStore();
|
const configStore = useConfigStore();
|
||||||
const { loginFun, registerFun } = useAuths();
|
const { loginFun, registerFun, loginSuccess } = useAuths();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const loginFormRef = ref();
|
const loginFormRef = ref();
|
||||||
@@ -318,6 +318,14 @@ const handleGiteeLogin = () => {
|
|||||||
"width=500,height=500,left=50,top=50"
|
"width=500,height=500,left=50,top=50"
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
window.addEventListener("message", async (e) => {
|
||||||
|
const { authData, type } = e.data;
|
||||||
|
if (authData) {
|
||||||
|
await loginSuccess({ data: authData });
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.login {
|
.login {
|
||||||
|
|||||||
@@ -131,10 +131,7 @@ const handleGiteeLogin = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("message", async (e) => {
|
window.addEventListener("message", async (e) => {
|
||||||
console.log(e, "我是账号设置页");
|
|
||||||
const { authData, type } = e.data;
|
|
||||||
if (e.data) {
|
if (e.data) {
|
||||||
console.log(authData, type, "2333");
|
|
||||||
await checkList();
|
await checkList();
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user