@webank/fes-core
Advanced tools
Comparing version 0.4.0 to 0.4.4
{ | ||
"name": "@webank/fes-core", | ||
"version": "0.4.0", | ||
"version": "0.4.4", | ||
"description": "一个好用的前端管理台快速开发框架", | ||
@@ -32,3 +32,3 @@ "scripts": { | ||
}, | ||
"gitHead": "0a72fba6361c1da954027a5301b56c85e531441e" | ||
"gitHead": "da5c8d73d5b24ab162b0d4093aca6329cc8e7602" | ||
} |
@@ -10,18 +10,19 @@ import _ from 'lodash'; | ||
const util = { | ||
// 验证一个path是否可以访问, 空的allowPage可以访问任何路由 | ||
// 验证一个path是否可以访问 | ||
canRoute(path, allowPage) { | ||
path = path.split('?')[0]; | ||
if (Array.isArray(allowPage) && allowPage.length > 0) { | ||
if (path === '' && allowPage.includes('/')) return true; | ||
if (path) { | ||
for (let i = 0; i < allowPage.length; i++) { | ||
if (path === allowPage[i]) { | ||
return true; | ||
} | ||
// 支持*匹配 | ||
const reg = new RegExp(`^${allowPage[i].replace('*', '.+')}$`); | ||
if (reg.test(path)) { | ||
return true; | ||
} | ||
// 当路由为“/"时,传入的path为“” | ||
if (path === '') { | ||
path = '/'; | ||
} | ||
for (let i = 0; i < allowPage.length; i++) { | ||
if (path === allowPage[i]) { | ||
return true; | ||
} | ||
// 支持*匹配 | ||
const reg = new RegExp(`^${allowPage[i].replace('*', '.+')}$`); | ||
if (reg.test(path)) { | ||
return true; | ||
} | ||
} | ||
@@ -88,3 +89,11 @@ } | ||
}; | ||
objectUtil.merge(util, domUtil, objectUtil, typeUtil, { format }, { event }, { history }); | ||
export default util; | ||
export default { | ||
...util, | ||
...domUtil, | ||
...objectUtil, | ||
...typeUtil, | ||
format, | ||
event, | ||
history | ||
}; |
1742
76316