beatle-app-common
Advanced tools
@@ -21,2 +21,3 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
import PropTypes from 'prop-types'; | ||
import path from 'path'; | ||
import Beatle from 'beatle'; | ||
@@ -177,4 +178,5 @@ import { Layer, LoadingBar, getLayout, BreadCrumb, Cascader, HocCreator, RouteHelper, Resizer, Modaler } from 'hc-materials'; | ||
var location = this.props.history.location; | ||
var pathname = path.normalize(this.context.app.setting.basePath + location.pathname); | ||
if (this._route && this.props.getResolvePath(this._route) === location.pathname) { | ||
if (this._route && this.props.getResolvePath(this._route) === pathname) { | ||
return this._route; | ||
@@ -189,3 +191,3 @@ } | ||
var child = cProps.children.find(function (item) { | ||
return _this2.props.getResolvePath(item.props) === location.pathname; | ||
return _this2.props.getResolvePath(item.props) === pathname; | ||
}); | ||
@@ -254,5 +256,5 @@ this._route = child.props.route; | ||
getResolvePath: function getResolvePath(route) { | ||
return route.path; | ||
return route.resolvePath || route.path; | ||
} | ||
}; | ||
BaseContainer.childContextTypes = {}; |
@@ -12,2 +12,4 @@ "use strict"; | ||
var _path = _interopRequireDefault(require("path")); | ||
var _beatle = _interopRequireDefault(require("beatle")); | ||
@@ -195,3 +197,5 @@ | ||
if (this._route && this.props.getResolvePath(this._route) === location.pathname) { | ||
var pathname = _path["default"].normalize(this.context.app.setting.basePath + location.pathname); | ||
if (this._route && this.props.getResolvePath(this._route) === pathname) { | ||
return this._route; | ||
@@ -206,3 +210,3 @@ } | ||
var child = cProps.children.find(function (item) { | ||
return _this2.props.getResolvePath(item.props) === location.pathname; | ||
return _this2.props.getResolvePath(item.props) === pathname; | ||
}); | ||
@@ -273,5 +277,5 @@ this._route = child.props.route; | ||
getResolvePath: function getResolvePath(route) { | ||
return route.path; | ||
return route.resolvePath || route.path; | ||
} | ||
}; | ||
BaseContainer.childContextTypes = {}; |
{ | ||
"name": "beatle-app-common", | ||
"main": "./lib/index.js", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"author": "", | ||
@@ -6,0 +6,0 @@ "description": "", |
import React, {Fragment} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import path from 'path'; | ||
@@ -49,3 +50,3 @@ import Beatle from 'beatle'; | ||
loadingStyle: {}, | ||
getResolvePath: route => route.path | ||
getResolvePath: route => route.resolvePath || route.path | ||
} | ||
@@ -169,3 +170,4 @@ | ||
const location = this.props.history.location; | ||
if (this._route && this.props.getResolvePath(this._route) === location.pathname) { | ||
const pathname = path.normalize(this.context.app.setting.basePath + location.pathname); | ||
if (this._route && this.props.getResolvePath(this._route) === pathname) { | ||
return this._route; | ||
@@ -177,3 +179,3 @@ } | ||
if (Array.isArray(cProps.children)) { | ||
const child = cProps.children.find(item => this.props.getResolvePath(item.props) === location.pathname); | ||
const child = cProps.children.find(item => this.props.getResolvePath(item.props) === pathname); | ||
this._route = child.props.route; | ||
@@ -180,0 +182,0 @@ } else { |
96809
0.42%2524
0.24%