Commit 4893296e authored by jim's avatar jim

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

parent 29e87b86
import { isUrl } from '../utils/utils';
const menuData = [{ const menuData = [{
name: 'dashboard', name: 'dashboard',
icon: 'dashboard', icon: 'dashboard',
...@@ -120,9 +122,13 @@ const menuData = [{ ...@@ -120,9 +122,13 @@ const menuData = [{
function formatter(data, parentPath = '', parentAuthority) { function formatter(data, parentPath = '', parentAuthority) {
return data.map((item) => { return data.map((item) => {
let { path } = item;
if (!isUrl(path)) {
path = parentPath + item.path;
}
const result = { const result = {
...item, ...item,
path: `${parentPath}${item.path}`, path,
authority: item.authority || parentAuthority, authority: item.authority || parentAuthority,
}; };
if (item.children) { if (item.children) {
......
...@@ -132,3 +132,11 @@ export function getRoutes(path, routerData) { ...@@ -132,3 +132,11 @@ export function getRoutes(path, routerData) {
}); });
return renderRoutes; 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);
}
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