mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-07 16:16:37 +08:00
[重构] 前端改造v1
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { dashboardNavigation } from '@/lib/constants/navigation';
|
||||
import type { NavigationItem } from '@/types/navigation';
|
||||
|
||||
export function isPathActive(pathname: string, href: string) {
|
||||
if (href === '/') {
|
||||
return pathname === '/';
|
||||
}
|
||||
|
||||
return pathname === href || pathname.startsWith(`${href}/`);
|
||||
}
|
||||
|
||||
export function getCurrentNavigationItem(pathname: string): NavigationItem | undefined {
|
||||
return dashboardNavigation.find((item) => isPathActive(pathname, item.href));
|
||||
}
|
||||
Reference in New Issue
Block a user