|
1 | | -import React, { Suspense, useEffect } from 'react'; |
2 | | -import { BrowserRouter, Routes, Route, Navigate, Outlet, HashRouter } from 'react-router-dom'; |
3 | | -import { Layout } from '@graphscope/studio-components'; |
4 | | -import { SIDE_MENU } from './const'; |
5 | | -import { ConfigProvider } from 'antd'; |
6 | | -import locales from '../locales'; |
7 | | -import { IntlProvider } from 'react-intl'; |
8 | | -import PaperReading from '../pages/explore/paper-reading'; |
| 1 | +import React, { Suspense } from 'react'; |
| 2 | +import { Route, Navigate } from 'react-router-dom'; |
9 | 3 |
|
10 | 4 | /** 注册 服务 */ |
11 | 5 | import { registerServices } from '../pages/explore/paper-reading/components/registerServices'; |
@@ -56,69 +50,24 @@ const routes = [ |
56 | 50 | path: '/dataset/cluster', |
57 | 51 | component: React.lazy(() => import('./dataset/cluster')), |
58 | 52 | }, |
59 | | - { path: '/explore', component: React.lazy(() => import('./explore')) }, |
60 | 53 | ]; |
61 | 54 |
|
62 | | -const Apps = () => { |
63 | | - const [isReady, setIsReady] = React.useState(false); |
64 | | - useEffect(() => { |
65 | | - reload().then(res => { |
66 | | - setIsReady(true); |
67 | | - }); |
68 | | - }, []); |
| 55 | +const ROUTES = routes.map(({ path, redirect, component: Component }, index) => { |
| 56 | + if (redirect) { |
| 57 | + return <Route key={index} path={path} element={<Navigate to={redirect} replace />} />; |
| 58 | + } |
69 | 59 | return ( |
70 | | - <> |
71 | | - <Outlet /> |
72 | | - {isReady && <PaperReading />} |
73 | | - </> |
| 60 | + <Route |
| 61 | + key={index} |
| 62 | + path={path} |
| 63 | + element={ |
| 64 | + <Suspense fallback={<></>}> |
| 65 | + {/** @ts-ignore */} |
| 66 | + <Component /> |
| 67 | + </Suspense> |
| 68 | + } |
| 69 | + /> |
74 | 70 | ); |
75 | | -}; |
76 | | -const Pages: React.FunctionComponent<IPagesProps> = props => { |
77 | | - const locale = 'en-US'; |
78 | | - const messages = locales[locale]; |
79 | | - const routeComponents = routes.map(({ path, redirect, component: Component }, index) => { |
80 | | - if (redirect) { |
81 | | - return <Route key={index} path={path} element={<Navigate to={redirect} replace />} />; |
82 | | - } |
83 | | - return ( |
84 | | - <Route |
85 | | - key={index} |
86 | | - path={path} |
87 | | - element={ |
88 | | - <Suspense fallback={<></>}> |
89 | | - {/** @ts-ignore */} |
90 | | - <Component /> |
91 | | - </Suspense> |
92 | | - } |
93 | | - /> |
94 | | - ); |
95 | | - }); |
| 71 | +}); |
96 | 72 |
|
97 | | - return ( |
98 | | - <ConfigProvider |
99 | | - theme={{ |
100 | | - components: { |
101 | | - Menu: { |
102 | | - itemSelectedBg: '#ececec', |
103 | | - itemSelectedColor: '#191919', |
104 | | - collapsedWidth: 50, |
105 | | - collapsedIconSize: 14, |
106 | | - }, |
107 | | - }, |
108 | | - }} |
109 | | - > |
110 | | - <IntlProvider messages={messages} locale={locale}> |
111 | | - <HashRouter> |
112 | | - <Routes> |
113 | | - <Route path="/" element={<Layout sideMenu={[SIDE_MENU]} />}> |
114 | | - {routeComponents} |
115 | | - </Route> |
116 | | - <Route path={'/paper-reading'} element={<Apps />} /> |
117 | | - </Routes> |
118 | | - </HashRouter> |
119 | | - </IntlProvider> |
120 | | - </ConfigProvider> |
121 | | - ); |
122 | | -}; |
123 | | - |
124 | | -export default Pages; |
| 73 | +export default ROUTES; |
0 commit comments