🐛 fixed the third-party login bug

This commit is contained in:
landaiqing
2024-08-30 21:52:48 +08:00
parent d91e683e87
commit 2c6ad81720
11 changed files with 254 additions and 72 deletions

View File

@@ -73,25 +73,23 @@ async function getQQRedirectUrl() {
* 获取client_id
*/
async function getClientId() {
const id: string | null = localStorage.getItem('client_id');
if (!id) {
const res: any = await generateClientId();
if (res.code === 0 && res.data) {
localStorage.setItem('client_id', res.data);
}
const client = useStore().client;
const res: any = await generateClientId();
if (res.code === 0 && res.data) {
client.setClientId(res.data);
}
}
/**
* 获取本地client_id
*/
function getLocalClientId(): string | null {
const clientID: string | null = localStorage.getItem('client_id');
if (clientID) {
return clientID;
function getLocalClientId() {
const client = useStore().client;
if (client.getClientId()) {
return client.getClientId();
} else {
getClientId();
return localStorage.getItem('client_id');
return client.getClientId();
}
}
@@ -126,7 +124,11 @@ function openGithubUrl() {
setTimeout(() => {
router.push('/main');
}, 1000);
} else {
message.error(t('login.loginError'));
window.removeEventListener("message", messageHandler);
}
}
};
window.addEventListener("message", messageHandler);
@@ -164,6 +166,9 @@ function openGiteeUrl() {
setTimeout(() => {
router.push('/main');
}, 1000);
} else {
message.error(t('login.loginError'));
window.removeEventListener("message", messageHandler);
}
}
};
@@ -201,7 +206,11 @@ function openQQUrl() {
setTimeout(() => {
router.push('/main');
}, 1000);
} else {
message.error(t('login.loginError'));
window.removeEventListener("message", messageHandler);
}
}
};
window.addEventListener("message", messageHandler);