Support from link.

This commit is contained in:
Yang Luo
2022-02-12 09:55:06 +08:00
parent 7391773f0e
commit 3aab6c8687
4 changed files with 15 additions and 2 deletions

View File

@ -441,6 +441,7 @@ class App extends Component {
renderLoginIfNotLoggedIn(component) { renderLoginIfNotLoggedIn(component) {
if (this.state.account === null) { if (this.state.account === null) {
sessionStorage.setItem("from", window.location.pathname);
return <Redirect to='/login' /> return <Redirect to='/login' />
} else if (this.state.account === undefined) { } else if (this.state.account === undefined) {
return null; return null;

View File

@ -638,3 +638,11 @@ export function getRandomName() {
export function getRandomNumber() { export function getRandomNumber() {
return Math.random().toString(10).slice(-11); return Math.random().toString(10).slice(-11);
} }
export function getFromLink() {
const from = sessionStorage.getItem("from");
if (from === null) {
return "/";
}
return from;
}

View File

@ -104,7 +104,9 @@ class AuthCallback extends React.Component {
if (responseType === "login") { if (responseType === "login") {
Util.showMessage("success", `Logged in successfully`); Util.showMessage("success", `Logged in successfully`);
// Setting.goToLinkSoft(this, "/"); // Setting.goToLinkSoft(this, "/");
Setting.goToLink("/");
const link = Setting.getFromLink();
Setting.goToLink(link);
} else if (responseType === "code") { } else if (responseType === "code") {
const code = res.data; const code = res.data;
Setting.goToLink(`${oAuthParams.redirectUri}?code=${code}&state=${oAuthParams.state}`); Setting.goToLink(`${oAuthParams.redirectUri}?code=${code}&state=${oAuthParams.state}`);

View File

@ -124,7 +124,9 @@ class LoginPage extends React.Component {
const responseType = this.state.type; const responseType = this.state.type;
if (responseType === "login") { if (responseType === "login") {
Util.showMessage("success", `Logged in successfully`); Util.showMessage("success", `Logged in successfully`);
Setting.goToLink("/");
const link = Setting.getFromLink();
Setting.goToLink(link);
} else if (responseType === "code") { } else if (responseType === "code") {
const code = res.data; const code = res.data;