refactor(系统设置): 去掉飞书扫码登陆遗留的url的参数
This commit is contained in:
parent
aa85b34b74
commit
cb37911b9f
|
@ -19,7 +19,7 @@
|
|||
import { useUserStore } from '@/store';
|
||||
import useAppStore from '@/store/modules/app';
|
||||
import useLicenseStore from '@/store/modules/setting/license';
|
||||
import { getQueryVariable } from '@/utils';
|
||||
import { getQueryVariable, getUrlParameterWidthRegExp } from '@/utils';
|
||||
import { setLoginExpires, setLongType, setToken } from '@/utils/auth';
|
||||
import { getLocalStorage, setLocalStorage } from '@/utils/local-storage';
|
||||
import { setFavicon, watchStyle, watchTheme } from '@/utils/theme';
|
||||
|
@ -113,6 +113,18 @@
|
|||
await userStore.checkIsLogin();
|
||||
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();
|
||||
appStore.innerHeight = height.value;
|
||||
if (userStore.id) {
|
||||
|
|
|
@ -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 sequence = 0;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
>
|
||||
<div class="login-page" :style="props.isPreview ? '' : 'min-width: 1200px;'">
|
||||
<banner />
|
||||
<a-spin :loading="appStore.getLoginLoadingStatus" class="w-full">
|
||||
<a-spin :loading="appStore.getLoginLoadingStatus" class="flex-1">
|
||||
<loginForm :is-preview="props.isPreview" />
|
||||
</a-spin>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue