feat(client): 获取url参数后更新url
This commit is contained in:
@@ -67,8 +67,22 @@ export const clearGroupId = (): void => {
|
|||||||
export const handleAuthTokenAndGroupIdFromUrl = (): void => {
|
export const handleAuthTokenAndGroupIdFromUrl = (): void => {
|
||||||
const tokenFromUrl = getAuthTokenFromUrl();
|
const tokenFromUrl = getAuthTokenFromUrl();
|
||||||
const groupIdFromUrl = getGroupIdFromUrl();
|
const groupIdFromUrl = getGroupIdFromUrl();
|
||||||
if (tokenFromUrl && groupIdFromUrl) {
|
|
||||||
|
let updated = false;
|
||||||
|
if (tokenFromUrl) {
|
||||||
saveAuthToken(tokenFromUrl);
|
saveAuthToken(tokenFromUrl);
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
if (groupIdFromUrl) {
|
||||||
saveGroupId(groupIdFromUrl);
|
saveGroupId(groupIdFromUrl);
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean URL if we consumed any param
|
||||||
|
if (updated) {
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
url.searchParams.delete('authToken');
|
||||||
|
url.searchParams.delete('groupId');
|
||||||
|
window.history.replaceState(null, '', url.toString());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user