Browse Source

fix #697 when the menu path is url, the parent path is not spliced

pull/713/head
jim 8 years ago
parent
commit
4893296e99
  1. 8
      src/common/menu.js
  2. 8
      src/utils/utils.js

8
src/common/menu.js

@ -1,3 +1,5 @@
import { isUrl } from '../utils/utils';
const menuData = [{
name: 'dashboard',
icon: 'dashboard',
@ -120,9 +122,13 @@ const menuData = [{
function formatter(data, parentPath = '', parentAuthority) {
return data.map((item) => {
let { path } = item;
if (!isUrl(path)) {
path = parentPath + item.path;
}
const result = {
...item,
path: `${parentPath}${item.path}`,
path,
authority: item.authority || parentAuthority,
};
if (item.children) {

8
src/utils/utils.js

@ -132,3 +132,11 @@ export function getRoutes(path, routerData) {
});
return renderRoutes;
}
/* eslint no-useless-escape:0 */
const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/g;
export function isUrl(path) {
return reg.test(path);
}

Loading…
Cancel
Save