提交 4893296e 编写于 作者: J jim

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

上级 29e87b86
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) {
......
......@@ -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);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册