mirror of https://gitee.com/answerdev/answer.git
Merge pull request #441 from answerdev/feat/1.1.1/ui
refactor: Cancels the delayed handling of jump actions.
This commit is contained in:
commit
64c97219cb
|
@ -93,8 +93,8 @@ const Index: React.FC = () => {
|
|||
}
|
||||
|
||||
login(params)
|
||||
.then((res) => {
|
||||
passwordCaptcha.close();
|
||||
.then(async (res) => {
|
||||
await passwordCaptcha.close();
|
||||
updateUser(res);
|
||||
const userStat = guard.deriveLoginState();
|
||||
if (userStat.isNotActivated) {
|
||||
|
|
|
@ -94,42 +94,36 @@ export interface NavigateConfig {
|
|||
}
|
||||
const navigate = (to: string | number, config: NavigateConfig = {}) => {
|
||||
let { handler = 'href' } = config;
|
||||
/**
|
||||
* Note: Synchronised navigation can result in asynchronous actions such as page animations and state modifications not being completed.
|
||||
*/
|
||||
setTimeout(() => {
|
||||
if (to && typeof to === 'string') {
|
||||
if (equalToCurrentHref(to)) {
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* 1. Blocking redirection of two login pages
|
||||
* 2. Auto storage login redirect
|
||||
* Note: The or judgement cannot be missing here, both jumps will be used
|
||||
*/
|
||||
if (to === RouteAlias.login || to === getLoginUrl()) {
|
||||
storageLoginRedirect();
|
||||
}
|
||||
|
||||
if (!isRoutableLink(to) && handler !== 'href' && handler !== 'replace') {
|
||||
handler = 'href';
|
||||
}
|
||||
if (handler === 'href' && config.options?.replace) {
|
||||
handler = 'replace';
|
||||
}
|
||||
if (handler === 'href') {
|
||||
window.location.href = to;
|
||||
} else if (handler === 'replace') {
|
||||
window.location.replace(to);
|
||||
} else if (typeof handler === 'function') {
|
||||
handler(to, config.options);
|
||||
}
|
||||
if (to && typeof to === 'string') {
|
||||
if (equalToCurrentHref(to)) {
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* 1. Blocking redirection of two login pages
|
||||
* 2. Auto storage login redirect
|
||||
* Note: The or judgement cannot be missing here, both jumps will be used
|
||||
*/
|
||||
if (to === RouteAlias.login || to === getLoginUrl()) {
|
||||
storageLoginRedirect();
|
||||
}
|
||||
|
||||
if (typeof to === 'number' && typeof handler === 'function') {
|
||||
handler(to);
|
||||
if (!isRoutableLink(to) && handler !== 'href' && handler !== 'replace') {
|
||||
handler = 'href';
|
||||
}
|
||||
});
|
||||
if (handler === 'href' && config.options?.replace) {
|
||||
handler = 'replace';
|
||||
}
|
||||
if (handler === 'href') {
|
||||
window.location.href = to;
|
||||
} else if (handler === 'replace') {
|
||||
window.location.replace(to);
|
||||
} else if (typeof handler === 'function') {
|
||||
handler(to, config.options);
|
||||
}
|
||||
}
|
||||
if (typeof to === 'number' && typeof handler === 'function') {
|
||||
handler(to);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue