chore: init bj_power monorepo (dashboard/mes/wms/wms_client/workstation), clear subproject git metadata and align naming to folder names
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Nav } from '@douyinfe/semi-ui'
|
||||
import React from 'react'
|
||||
import { useLocale } from '@/locales'
|
||||
import useGlobalStore from '@/stores'
|
||||
import useLocalStore from '@/stores/local'
|
||||
import routers, { Router } from '@/router/routers'
|
||||
import {
|
||||
NavItemProps,
|
||||
NavItems,
|
||||
SubNavPropsWithItems
|
||||
} from '@douyinfe/semi-ui/lib/es/navigation'
|
||||
import { hasPermission } from '@/router/util'
|
||||
|
||||
export default () => {
|
||||
const { formatMessage } = useLocale()
|
||||
|
||||
const { currentKeys } = useGlobalStore()
|
||||
const { userInfo } = useLocalStore()
|
||||
|
||||
const genMenus = (items: Router[], level = 1): NavItems => {
|
||||
const menus: NavItems = []
|
||||
items.forEach(r => {
|
||||
if (r.isMenu && hasPermission(userInfo, r.permission)) {
|
||||
if (r.children) {
|
||||
// 有子菜单
|
||||
menus.push({
|
||||
itemKey: r.path ? r.path : `${r.name}_${level}`,
|
||||
indent: true,
|
||||
level: level,
|
||||
disabled: r.disabled,
|
||||
text: formatMessage({ id: r.name }),
|
||||
icon: r.icon,
|
||||
items: genMenus(r.children, level + 1)
|
||||
} as SubNavPropsWithItems)
|
||||
} else {
|
||||
menus.push({
|
||||
itemKey: r.path ? r.path : `${r.name}_${level}`,
|
||||
indent: true,
|
||||
level: level,
|
||||
disabled: r.disabled,
|
||||
text: formatMessage({ id: r.name }),
|
||||
icon: r.icon
|
||||
} as NavItemProps)
|
||||
}
|
||||
}
|
||||
})
|
||||
return menus
|
||||
}
|
||||
|
||||
return (
|
||||
<Nav
|
||||
style={{ maxWidth: 220, height: '100%' }}
|
||||
limitIndent={false}
|
||||
defaultIsCollapsed={false}
|
||||
// defaultSelectedKeys={['/']}
|
||||
selectedKeys={currentKeys}
|
||||
renderWrapper={({ itemElement, isSubNav, props }) => {
|
||||
if (isSubNav || props.disabled) {
|
||||
return <>{itemElement} </>
|
||||
}
|
||||
return (
|
||||
<Link
|
||||
style={{
|
||||
textDecoration: 'none',
|
||||
textIndent: props.level ? props.level * 10 : 0
|
||||
}}
|
||||
to={props.itemKey as string}>
|
||||
{itemElement}
|
||||
</Link>
|
||||
)
|
||||
}}
|
||||
items={genMenus(routers, 1)}
|
||||
footer={{
|
||||
collapseButton: true
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user