feat: support login button loading state (#3694)

This commit is contained in:
DacongDA 2025-04-01 00:57:24 +08:00 committed by GitHub
parent e55cd94298
commit 2cc5e82d91
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -63,6 +63,7 @@ class LoginPage extends React.Component {
termsOfUseContent: "", termsOfUseContent: "",
orgChoiceMode: new URLSearchParams(props.location?.search).get("orgChoiceMode") ?? null, orgChoiceMode: new URLSearchParams(props.location?.search).get("orgChoiceMode") ?? null,
userLang: null, userLang: null,
loginLoading: false,
}; };
if (this.state.type === "cas" && props.match?.params.casApplicationName !== undefined) { if (this.state.type === "cas" && props.match?.params.casApplicationName !== undefined) {
@ -423,6 +424,7 @@ class LoginPage extends React.Component {
} }
login(values) { login(values) {
this.setState({loginLoading: true});
// here we are supposed to determine whether Casdoor is working as an OAuth server or CAS server // here we are supposed to determine whether Casdoor is working as an OAuth server or CAS server
values["language"] = this.state.userLang ?? ""; values["language"] = this.state.userLang ?? "";
if (this.state.type === "cas") { if (this.state.type === "cas") {
@ -452,6 +454,7 @@ class LoginPage extends React.Component {
} else { } else {
Setting.showMessage("error", `${i18next.t("application:Failed to sign in")}: ${res.msg}`); Setting.showMessage("error", `${i18next.t("application:Failed to sign in")}: ${res.msg}`);
} }
this.setState({loginLoading: false});
}); });
} else { } else {
// OAuth // OAuth
@ -507,6 +510,7 @@ class LoginPage extends React.Component {
} else { } else {
Setting.showMessage("error", `${i18next.t("application:Failed to sign in")}: ${res.msg}`); Setting.showMessage("error", `${i18next.t("application:Failed to sign in")}: ${res.msg}`);
} }
this.setState({loginLoading: false});
}); });
} }
} }
@ -694,6 +698,7 @@ class LoginPage extends React.Component {
<Form.Item key={resultItemKey} className="login-button-box"> <Form.Item key={resultItemKey} className="login-button-box">
<div dangerouslySetInnerHTML={{__html: ("<style>" + signinItem.customCss?.replaceAll("<style>", "").replaceAll("</style>", "") + "</style>")}} /> <div dangerouslySetInnerHTML={{__html: ("<style>" + signinItem.customCss?.replaceAll("<style>", "").replaceAll("</style>", "") + "</style>")}} />
<Button <Button
loading={this.state.loginLoading}
type="primary" type="primary"
htmlType="submit" htmlType="submit"
className="login-button" className="login-button"