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