| | |
| | | // 设置 props默认值 作用就是将字段设置成配置的 |
| | | const propsDefault = { |
| | | label: propsConfig.label || 'name', |
| | | path: 'code', |
| | | pathValue:propsConfig.path || 'path', |
| | | path:'code', |
| | | code: 'code', |
| | | pathValue:'pathValue', |
| | | icon: propsConfig.icon || 'icon', |
| | | children: propsConfig.children || 'children', |
| | | meta: propsConfig.meta || 'meta', |
| | |
| | | } |
| | | })(); |
| | | let code = (() => { |
| | | return oMenu[propsDefault.path] |
| | | return oMenu[propsDefault.code] |
| | | })(); |
| | | // 将字符串分割成数组,以'?'作为分隔符 |
| | | let parts = path.split("?"); |
| | | // 如果数组的长度大于1,表示有'?',则取第一个元素的第一个部分,否则直接取整个字符串 |
| | | let bsValue = parts.length > 1 ? parts[0].split("=")[1] : path.split("=")[1]; |
| | | |
| | | if (bsValue ==='' || bsValue === undefined || bsValue === null ) { |
| | | if (bsValue === '' || bsValue === undefined || bsValue === null) { |
| | | bsValue = "UI"; |
| | | } |
| | | |
| | | //特殊处理组件 执行完这个 component 也就是精确到具体的文件了 views文件夹下面就是具体的页面代码 |
| | | let component = bsValue === 'UI' ? 'views/base/UIContentViewer' : `views/custom-ui/${bsValue}`, |
| | | name = oMenu[propsDefault.label], |
| | |
| | | //是否有子路由 |
| | | const isChild = children.length !== 0; |
| | | const oRouter = { |
| | | path: code, |
| | | path: '/' + code, |
| | | component(resolve) { |
| | | // 判断是否为首路由 |
| | | if (first) { |
| | |
| | | children: !isChild ? (() => { |
| | | if (first) { |
| | | // 这里的isURL判断,因为这个网站有使用 iframe。所以需要判断是否为网页链接 |
| | | if (!isURL(path)) oMenu[propsDefault.path] = `${path}/index`; |
| | | if (!isURL(path)) oMenu[propsDefault.pathValue] = `${path}/index`; |
| | | return [{ |
| | | component(resolve) { |
| | | require([`../${component}.vue`], resolve) |
| | |
| | | const propsConfig = menu.props; |
| | | const propsDefault = { |
| | | label: propsConfig.label || 'name', |
| | | path: 'code', |
| | | path: propsConfig.path || 'path', |
| | | icon: propsConfig.icon || 'icon', |
| | | children: propsConfig.children || 'children' |
| | | } |
| | |
| | | } else { |
| | | ele[propsDefault.children].forEach(child => { |
| | | addPath(child); |
| | | }) |
| | | } |
| | | }); |
| | | |
| | | } |
| | | } |
| | | |
| | | function updateCode(items) { |
| | | items.forEach(item => { |
| | | item.pathValue = item.path; |
| | | item.path = '/' + item.code; |
| | | if (item.children && item.children.length > 0) { |
| | | updateCode(item.children); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | |
| | | "name": "典型规程", |
| | | "parentId": "BDBD6CFA-2F4C-EEF7-C380-5E9BBF6A37B3", |
| | | "parentName": null, |
| | | "path": "bs=?image=typical&type=workorder&context=TypicalProcessLib", |
| | | "path": "bs=test?image=typical&type=workorder&context=TypicalProcessLib", |
| | | "remark": null, |
| | | "sort": 1, |
| | | "source": "" |
| | |
| | | let menu = deepClone(list); |
| | | menu.forEach(ele => { |
| | | addPath(ele, true); |
| | | updateCode([ele]); |
| | | }); |
| | | updateCode(menu) |
| | | function updateCode(items) { |
| | | items.forEach(item => { |
| | | // 将字符串分割成数组,以'?'作为分隔符 |
| | | let parts = item.path.split("?"); |
| | | // 如果数组的长度大于1,表示有'?',则取第一个元素的第一个部分,否则直接取整个字符串 |
| | | let bsValue = parts.length > 1 ? parts[0].split("=")[1] : item.path.split("=")[1]; |
| | | if (bsValue ==='' || bsValue === undefined || bsValue === null) { |
| | | bsValue = "UI"; |
| | | } |
| | | item.path = bsValue === 'UI' ? '/base/UIContentViewer' : `/custom-ui/${bsValue}`; |
| | | // 如果children不为空,递归调用这个函数 |
| | | if (item.children && item.children.length > 0) { |
| | | updateCode(item.children); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | commit('SET_MENU_ALL', menu) |
| | | commit('SET_MENU', menu) |
| | | //dispatch('GetButtons');s |