refactor(系统设置): 去掉飞书扫码登陆遗留的url的参数

This commit is contained in:
guoyuqi 2024-07-11 18:10:17 +08:00 committed by 刘瑞斌
parent aa85b34b74
commit cb37911b9f
3 changed files with 24 additions and 2 deletions

View File

@ -19,7 +19,7 @@
import { useUserStore } from '@/store'; import { useUserStore } from '@/store';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import useLicenseStore from '@/store/modules/setting/license'; import useLicenseStore from '@/store/modules/setting/license';
import { getQueryVariable } from '@/utils'; import { getQueryVariable, getUrlParameterWidthRegExp } from '@/utils';
import { setLoginExpires, setLongType, setToken } from '@/utils/auth'; import { setLoginExpires, setLongType, setToken } from '@/utils/auth';
import { getLocalStorage, setLocalStorage } from '@/utils/local-storage'; import { getLocalStorage, setLocalStorage } from '@/utils/local-storage';
import { setFavicon, watchStyle, watchTheme } from '@/utils/theme'; import { setFavicon, watchStyle, watchTheme } from '@/utils/theme';
@ -113,6 +113,18 @@
await userStore.checkIsLogin(); await userStore.checkIsLogin();
appStore.setLoginLoading(false); appStore.setLoginLoading(false);
} }
if (getQueryVariable('code') && getQueryVariable('state')) {
const currentUrl = window.location.href;
const url = new URL(currentUrl);
getUrlParameterWidthRegExp('code');
getUrlParameterWidthRegExp('state');
url.searchParams.delete('code');
url.searchParams.delete('state');
const newUrl = url.toString();
// URL使 History API
window.history.replaceState({}, document.title, newUrl);
}
const { height } = useWindowSize(); const { height } = useWindowSize();
appStore.innerHeight = height.value; appStore.innerHeight = height.value;
if (userStore.id) { if (userStore.id) {

View File

@ -696,6 +696,16 @@ export function getQueryVariable(variable: string) {
} }
} }
export function getUrlParameterWidthRegExp(name: string) {
const url = window.location.href;
name = name.replace(/[[\]]/g, '\\$&');
const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);
const results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
let lastTimestamp = 0; let lastTimestamp = 0;
let sequence = 0; let sequence = 0;

View File

@ -8,7 +8,7 @@
> >
<div class="login-page" :style="props.isPreview ? '' : 'min-width: 1200px;'"> <div class="login-page" :style="props.isPreview ? '' : 'min-width: 1200px;'">
<banner /> <banner />
<a-spin :loading="appStore.getLoginLoadingStatus" class="w-full"> <a-spin :loading="appStore.getLoginLoadingStatus" class="flex-1">
<loginForm :is-preview="props.isPreview" /> <loginForm :is-preview="props.isPreview" />
</a-spin> </a-spin>
</div> </div>