Commit 7eed81cf authored by 邓晓峰's avatar 邓晓峰

merge master branch

parents c286dbf1 63d38dc6
Pipeline #35392 passed with stages
in 57 minutes 49 seconds
/* eslint-disable */ /* eslint-disable */
// const proxyURL = process.env.NODE_ENV !== 'production' ? 'http://192.168.10.150:8777' : window.location.origin; // const proxyURL = process.env.NODE_ENV !== 'production' ? 'http://192.168.10.150:8777' : window.location.origin;
const proxyURL = 'http://172.16.10.152:8666'; const proxyURL = 'http://172.16.10.206:8666';
module.exports = { module.exports = {
assetsRoot: process.env.NODE_ENV !== 'production' ? proxyURL : './', assetsRoot: process.env.NODE_ENV !== 'production' ? proxyURL : './',
dev: { dev: {
......
...@@ -2,9 +2,9 @@ import React, { Suspense } from 'react'; ...@@ -2,9 +2,9 @@ import React, { Suspense } from 'react';
import { Helmet } from 'react-helmet'; import { Helmet } from 'react-helmet';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { renderRoutes } from 'react-router-config'; // import { renderRoutes } from 'react-router-config';
// import { RouteWithSubRoutes, renderRoutes} from '../../utils/routes' import { renderRoutes } from '../../utils/routes'
import BootPage from '../../pages/bootpage'; // import BootPage from '../../pages/bootpage';
import { import {
Router, Router,
Switch, Switch,
...@@ -13,7 +13,7 @@ import { ...@@ -13,7 +13,7 @@ import {
} from '@wisdom-utils/runtime'; } from '@wisdom-utils/runtime';
import { dyRoutes } from '../../routes/config'; import { dyRoutes } from '../../routes/config';
import routeContext from '@ant-design/pro-layout/lib/RouteContext'; // import routeContext from '@ant-design/pro-layout/lib/RouteContext';
// import { Route } from 'react-router-dom'; // import { Route } from 'react-router-dom';
const pkg = require('../../../package.json'); const pkg = require('../../../package.json');
......
...@@ -18,7 +18,8 @@ import { ...@@ -18,7 +18,8 @@ import {
Tooltip Tooltip
} from 'antd'; } from 'antd';
// import { RouteWithSubRoutes, renderRoutes } from '../utils/routes'; // import { RouteWithSubRoutes, renderRoutes } from '../utils/routes';
import { renderRoutes } from 'react-router-config'; // import { renderRoutes } from 'react-router-config';
import { renderRoutes } from '../utils/routes'
import { PageContainer } from '@ant-design/pro-layout'; import { PageContainer } from '@ant-design/pro-layout';
import Icon from '@ant-design/icons'; import Icon from '@ant-design/icons';
import { store } from 'microser-data'; import { store } from 'microser-data';
...@@ -272,7 +273,7 @@ const BasicLayout = props => { ...@@ -272,7 +273,7 @@ const BasicLayout = props => {
true, true,
); );
const parentMenuName = initSelectRoute && initSelectRoute.parent.label; const parentMenuName = initSelectRoute && initSelectRoute.parent && initSelectRoute.parent.label;
if(parentMenuName) { if(parentMenuName) {
let currentChildrenRoute = currentRoutes.routes.find(item => item.name === parentMenuName); let currentChildrenRoute = currentRoutes.routes.find(item => item.name === parentMenuName);
if(!currentChildrenRoute) { if(!currentChildrenRoute) {
......
...@@ -5,7 +5,7 @@ import { ...@@ -5,7 +5,7 @@ import {
HelmetProvider, HelmetProvider,
} from 'react-helmet-async'; } from 'react-helmet-async';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { renderRoutes } from 'react-router-config'; import { renderRoutes } from '../utils/routes';
import { import {
getMenuData, getMenuData,
......
import { transformURL } from './utils'; import { transformURL } from './utils';
import {
Route, import { matchPath, Route, Switch} from 'react-router';
Switch
} from '@wisdom-utils/runtime';
import React, { Suspense, Fragment } from 'react'; import React, { Suspense, Fragment } from 'react';
export const isURL = function(url) { export const isURL = function(url) {
// eslint-disable-next-line no-useless-escape // eslint-disable-next-line no-useless-escape
...@@ -149,35 +147,64 @@ export function RouteWithSubRoutes(route) { ...@@ -149,35 +147,64 @@ export function RouteWithSubRoutes(route) {
<Route path={route.path} render={props => (<route.component {...props} route={route} routes={route.routes} params={route.params}/>)}></Route> <Route path={route.path} render={props => (<route.component {...props} route={route} routes={route.routes} params={route.params}/>)}></Route>
) )
} }
function matchRoutes(routes, pathname, branch) {
export function renderRoutes(routes) { if (branch === void 0) {
return routes.map((route,index) => ( branch = [];
<Route }
key={index}
path={route.path} routes.some(function (route) {
exact={route.exact} var match = route.path ? matchPath(pathname, route) : branch.length ? branch[branch.length - 1].match // use parent match
render={(props) => { // 利用render 方法处理 : Router.computeRootMatch(pathname); // use default "root" match
if (route.routes){
return ( if (match) {
<> branch.push({
<route.component {...props} route={route} routes={route.routes} params={route.params}></route.component> route: route,
<Switch> match: match
{ });
route.routes.map((child,i) => (
RouteWithSubRoutes(child) if (route.routes) {
)) matchRoutes(route.routes, pathname, branch);
}
{/* <Redirect to={route.routes[0].path}></Redirect> // 子路由找不到,重定向到第一个子路由 */}
</Switch>
</>
)
}else {
return (
<route.component {...props} route={route} routes={route.routes} params={route.params}></route.component>
)
} }
}} }
/>
)) return match;
});
return branch;
}
function renderRoutes(routes, extraProps, switchProps) {
if (extraProps === void 0) {
extraProps = {};
}
if (switchProps === void 0) {
switchProps = {};
} }
return routes ? React.createElement(Switch, switchProps, routes.map(function (route, i) {
return React.createElement(Route, {
key: route.key || i,
path: route.path,
exact: route.exact,
strict: route.strict,
render: function render(props) {
return route.render ? route.render(Object.assign({}, props, {}, extraProps, {
routes: route.routes,
params: route.params,
route: route
})) : React.createElement(route.component, Object.assign({}, props, extraProps, {
route: route,
routes: route.routes,
params: route.params,
}));
}
});
})) : null;
}
export {
renderRoutes,
matchPath
}
export default generRotes; export default generRotes;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment