diff --git a/src/components/layout/index.vue b/src/components/layout/index.vue index 7a7a06b8a1b41bbd69251994354e0723247c4769..5ca4f11c88dc210e1bdf2dd23be3ce1474f3a6fc 100644 --- a/src/components/layout/index.vue +++ b/src/components/layout/index.vue @@ -3,39 +3,39 @@ - \ No newline at end of file diff --git a/src/utils/index.js b/src/utils/index.js index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..9ec921518917bf91668c4ad17cae6d3650a7043e 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -0,0 +1,13 @@ +// directory 是要搜索的目录 , useSubdirectories 表示是否搜索子目录, regExp 是匹配文件的正则表达式 +const context = require.context('./modules', false, /.js$/) +// 讲所有模块导出内容添加到_obj中 +const _obj = context.keys().reduce((pre, key) => { + const name = key.replace(/.\/|.js/g,'') + const module=context(key); + Object.entries(module).forEach(([attr,value])=> { + pre[attr] = value; + }) + return pre; +},{}) + +export default _obj \ No newline at end of file diff --git a/src/utils/modules/routeUtils.js b/src/utils/modules/routeUtils.js index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..60d92e1c31f8c6672fae0044536cf943f394559c 100644 --- a/src/utils/modules/routeUtils.js +++ b/src/utils/modules/routeUtils.js @@ -0,0 +1,16 @@ +/** + * + * @param {Array} list 路由数据 + * @param {Function} processFn 处理函数 + * @returns {Array} 数组数据 + */ +export function coventRouteData(list, processFn) { + return list.map(item => { + let { children, component, ...rest } = item; + if (children && Array.isArray(children)) { + children = coventRouteData(children, processFn) + return processFn({ children, ...rest }) + } + return processFn(rest) + }); +}