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,
|
||||
clearStorage,
|
||||
registerFun,
|
||||
loginSuccess,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,6 +15,11 @@ const type = ref(route.query.state);
|
||||
const message = ref("");
|
||||
const scheme = ref("");
|
||||
const authData = ref("");
|
||||
const closeWindow = () => {
|
||||
setTimeout(() => {
|
||||
window.close();
|
||||
}, 2000);
|
||||
};
|
||||
watch(
|
||||
() => code.value,
|
||||
async (val) => {
|
||||
@@ -31,19 +36,25 @@ watch(
|
||||
scheme.value = "QQ";
|
||||
break;
|
||||
}
|
||||
if (type.value === "0") {
|
||||
const { data } = await authOtherLogin({ code: val }, scheme.value);
|
||||
authData.value = data;
|
||||
} else if (type.value === "1") {
|
||||
const { data } = await authOtherBind({ code: val }, scheme.value);
|
||||
authData.value = data;
|
||||
try {
|
||||
if (type.value === "0") {
|
||||
const { data } = await authOtherLogin({ code: val }, scheme.value);
|
||||
authData.value = data;
|
||||
} else if (type.value === "1") {
|
||||
const { data } = await authOtherBind({ code: val }, scheme.value);
|
||||
authData.value = data;
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.status === 403) {
|
||||
closeWindow();
|
||||
}
|
||||
}
|
||||
window.opener.postMessage({
|
||||
authData: JSON.stringify(authData.value),
|
||||
type: scheme.value,
|
||||
});
|
||||
console.log(authData.value, "我是打开的窗口页");
|
||||
message.value = "授权成功";
|
||||
closeWindow();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
|
||||
@@ -166,7 +166,7 @@ import useUserStore from "@/stores/user";
|
||||
import useConfigStore from "@/stores/config";
|
||||
|
||||
const configStore = useConfigStore();
|
||||
const { loginFun, registerFun } = useAuths();
|
||||
const { loginFun, registerFun, loginSuccess } = useAuths();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const loginFormRef = ref();
|
||||
@@ -318,6 +318,14 @@ const handleGiteeLogin = () => {
|
||||
"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>
|
||||
<style scoped lang="scss">
|
||||
.login {
|
||||
|
||||
@@ -131,10 +131,7 @@ const handleGiteeLogin = () => {
|
||||
};
|
||||
|
||||
window.addEventListener("message", async (e) => {
|
||||
console.log(e, "我是账号设置页");
|
||||
const { authData, type } = e.data;
|
||||
if (e.data) {
|
||||
console.log(authData, type, "2333");
|
||||
await checkList();
|
||||
window.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user