diff --git a/src/common/menu.js b/src/common/menu.js index 7093151ce363bbe7e8539fb2f86e3f9d3e1f0dc3..75f47dcf891756525a3343e55ecbea409cb22b14 100644 --- a/src/common/menu.js +++ b/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) { diff --git a/src/utils/utils.js b/src/utils/utils.js index e80cce5bfb0ac22c70bc876b358725ecdcef4da9..46a0a0f28fd364edf2c9a3424f4869ef7e5a0e7b 100644 --- a/src/utils/utils.js +++ b/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); +}