|
|
@@ -11,9 +11,29 @@ import GlobalFooter from '../components/GlobalFooter';
|
|
|
import SiderMenu from '../components/SiderMenu';
|
|
|
import NotFound from '../routes/Exception/404';
|
|
|
import { getRoutes } from '../utils/utils';
|
|
|
+import { getMenuData } from '../common/menu';
|
|
|
|
|
|
-const { Content } = Layout;
|
|
|
|
|
|
+/**
|
|
|
+ * 根据菜单取得重定向地址.
|
|
|
+ */
|
|
|
+const redirectData = [];
|
|
|
+const getRedirect = (item) => {
|
|
|
+ if (item && item.children) {
|
|
|
+ if (item.children[0] && item.children[0].path) {
|
|
|
+ redirectData.push({
|
|
|
+ from: `/${item.path}`,
|
|
|
+ to: `/${item.children[0].path}`,
|
|
|
+ });
|
|
|
+ item.children.forEach((children) => {
|
|
|
+ getRedirect(children);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+getMenuData().forEach(getRedirect);
|
|
|
+
|
|
|
+const { Content } = Layout;
|
|
|
const query = {
|
|
|
'screen-xs': {
|
|
|
maxWidth: 575,
|
|
|
@@ -79,17 +99,20 @@ class BasicLayout extends React.PureComponent {
|
|
|
<div style={{ minHeight: 'calc(100vh - 260px)' }}>
|
|
|
<Switch>
|
|
|
{
|
|
|
- getRoutes(match.path, routerData).map(item =>
|
|
|
- (
|
|
|
- <Route
|
|
|
- key={item.key}
|
|
|
- path={item.path}
|
|
|
- component={item.component}
|
|
|
- exact={item.exact}
|
|
|
- />
|
|
|
- )
|
|
|
+ redirectData.map(item =>
|
|
|
+ <Redirect key={item.from} exact from={item.from} to={item.to} />
|
|
|
)
|
|
|
}
|
|
|
+ {
|
|
|
+ getRoutes(match.path, routerData).map(item => (
|
|
|
+ <Route
|
|
|
+ key={item.key}
|
|
|
+ path={item.path}
|
|
|
+ component={item.component}
|
|
|
+ exact={item.exact}
|
|
|
+ />
|
|
|
+ ))
|
|
|
+ }
|
|
|
<Redirect exact from="/" to="/dashboard/analysis" />
|
|
|
<Route render={NotFound} />
|
|
|
</Switch>
|