tiny-vue/examples/sites/demos/saas/menus.js

50 lines
1.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 合并mobile-first和pc的菜单作为saas官网的菜单
import { docMenus, cmpMenus as pcCmpMenus } from '../pc/menus'
import { cmpMenus as mfCmpMenus } from '../mobile-first/menus'
const noSaasComponents = [
'ActionMenu',
'Anchor',
'ColorPicker',
'ColorSelectPanel',
'ConfigProvider',
'DatePickerMobileFirst',
'Divider',
'IndexBar',
'IndexBarAnchor',
'Label',
'Mask',
'MindMap',
'MultiSelect',
'MultiSelectItem',
'QrCode',
'RichTextEditor',
'TimelineItem',
'Toast',
'TopBox',
'Watermark',
'Wheel',
'Skeleton',
'Statistic'
]
// mobile-first上所有分类pc上都有因此可以用pc端menu分类进行合并
const cmpMenus = pcCmpMenus.map((pcMenusitem) => {
const mfMenusItem = mfCmpMenus.find((i) => i.key === pcMenusitem.key)
pcMenusitem.children = pcMenusitem.children.map((i) => ({ ...i, mode: ['pc'] }))
if (mfMenusItem?.children) {
mfMenusItem.children.forEach((mfMenusChild) => {
const matchChild = pcMenusitem.children.find((pcMenusChild) => pcMenusChild.key === mfMenusChild.key)
if (matchChild) {
matchChild.mode.push('mobile-first')
} else {
pcMenusitem.children.push({ ...mfMenusChild, mode: ['mobile-first'] })
}
})
}
pcMenusitem.children = pcMenusitem.children.filter((item) => !noSaasComponents.includes(item.name))
return pcMenusitem
})
export { docMenus, cmpMenus }