feat: use lazy load to load management pages (#2752)

This commit is contained in:
DacongDA
2024-02-27 22:31:02 +08:00
committed by GitHub
parent a5499219d1
commit b0d87f60ae
2 changed files with 49 additions and 43 deletions

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import React, {Component} from "react"; import React, {Component, Suspense, lazy} from "react";
import "./App.less"; import "./App.less";
import {Helmet} from "react-helmet"; import {Helmet} from "react-helmet";
import * as Setting from "./Setting"; import * as Setting from "./Setting";
@ -30,7 +30,7 @@ import AuthCallback from "./auth/AuthCallback";
import SamlCallback from "./auth/SamlCallback"; import SamlCallback from "./auth/SamlCallback";
import i18next from "i18next"; import i18next from "i18next";
import {withTranslation} from "react-i18next"; import {withTranslation} from "react-i18next";
import ManagementPage from "./ManagementPage"; const ManagementPage = lazy(() => import("./ManagementPage"));
const {Footer, Content} = Layout; const {Footer, Content} = Layout;
import {setTwoToneColor} from "@ant-design/icons"; import {setTwoToneColor} from "@ant-design/icons";
@ -366,6 +366,7 @@ class App extends Component {
<FloatButton.BackTop /> <FloatButton.BackTop />
<CustomGithubCorner /> <CustomGithubCorner />
{ {
<Suspense fallback={<div>loading</div>}>
<Layout id="parent-area"> <Layout id="parent-area">
<ManagementPage <ManagementPage
account={this.state.account} account={this.state.account}
@ -407,6 +408,7 @@ class App extends Component {
this.renderAiAssistant() this.renderAiAssistant()
} }
</Layout> </Layout>
</Suspense>
} }
</React.Fragment> </React.Fragment>
); );

View File

@ -17,6 +17,10 @@ import LoginPage from "./LoginPage";
import {authConfig} from "./Auth"; import {authConfig} from "./Auth";
class SelfLoginPage extends React.Component { class SelfLoginPage extends React.Component {
constructor(props) {
super(props);
import("../ManagementPage");
}
render() { render() {
return ( return (
<LoginPage type={"login"} mode={"signin"} applicationName={authConfig.appName} {...this.props} /> <LoginPage type={"login"} mode={"signin"} applicationName={authConfig.appName} {...this.props} />