FormView, FormEdit ve FormNew için MenuIcon
This commit is contained in:
parent
203160fce0
commit
17df35102d
1 changed files with 16 additions and 0 deletions
|
|
@ -4,6 +4,16 @@ import { FaUser } from 'react-icons/fa'
|
||||||
import navigationIcon from '@/proxy/menus/navigation-icon.config'
|
import navigationIcon from '@/proxy/menus/navigation-icon.config'
|
||||||
import { navigationTreeToFlat } from '@/utils/navigation'
|
import { navigationTreeToFlat } from '@/utils/navigation'
|
||||||
|
|
||||||
|
const extractListFormCode = (path: string): string | null => {
|
||||||
|
const p = (path ?? '').toLowerCase()
|
||||||
|
|
||||||
|
// /admin/form/<code>/..., /admin/list/<code>/..., /admin/chart/<code>/..., /admin/pivot/<code>/...
|
||||||
|
let m = p.match(/\/admin\/(?:list|form|chart|pivot)\/([^/?#]+)/)
|
||||||
|
if (m?.[1]) return m[1]
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
export function useCurrentMenuIcon(className = 'w-6 h-6'): JSX.Element {
|
export function useCurrentMenuIcon(className = 'w-6 h-6'): JSX.Element {
|
||||||
const mainMenu = useStoreState((state) => state.abpConfig.menu.mainMenu)
|
const mainMenu = useStoreState((state) => state.abpConfig.menu.mainMenu)
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
|
|
@ -18,6 +28,12 @@ export function useCurrentMenuIcon(className = 'w-6 h-6'): JSX.Element {
|
||||||
// Exact match
|
// Exact match
|
||||||
if (currentPath.startsWith(menuPath)) return true
|
if (currentPath.startsWith(menuPath)) return true
|
||||||
|
|
||||||
|
// Form/list/chart/pivot routes can include extra segments (e.g. /:id, /edit).
|
||||||
|
// Match by listFormCode extracted from both paths.
|
||||||
|
const currentCode = extractListFormCode(currentPath)
|
||||||
|
const menuCode = extractListFormCode(menuPath)
|
||||||
|
if (currentCode && menuCode && currentCode === menuCode) return true
|
||||||
|
|
||||||
// Extract the form code (e.g., "App.Definitions.Program" from path)
|
// Extract the form code (e.g., "App.Definitions.Program" from path)
|
||||||
const menuFormCode = menuPath.split('/').pop() || ''
|
const menuFormCode = menuPath.split('/').pop() || ''
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue