mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-06 07:36:37 +08:00
feat: unify website and certificate management
This commit is contained in:
@@ -22,14 +22,9 @@ export const dashboardNavigation: NavigationItem[] = [
|
||||
icon: 'release',
|
||||
},
|
||||
{
|
||||
href: '/managed-domain',
|
||||
label: '域名',
|
||||
icon: 'domain',
|
||||
},
|
||||
{
|
||||
href: '/tls-certificate',
|
||||
label: '证书',
|
||||
icon: 'certificate',
|
||||
href: '/website',
|
||||
label: '网站',
|
||||
icon: 'website',
|
||||
},
|
||||
{
|
||||
href: '/user',
|
||||
|
||||
@@ -16,18 +16,34 @@ export function isPathActive(pathname: string, href: string) {
|
||||
return normalizedPathname === '/';
|
||||
}
|
||||
|
||||
return normalizedPathname === href || normalizedPathname.startsWith(`${href}/`);
|
||||
return (
|
||||
normalizedPathname === href || normalizedPathname.startsWith(`${href}/`)
|
||||
);
|
||||
}
|
||||
|
||||
export function isNavigationItemActive(pathname: string, item: NavigationItem): boolean {
|
||||
return isPathActive(pathname, item.href) || item.children?.some((child) => isNavigationItemActive(pathname, child)) || false;
|
||||
export function isNavigationItemActive(
|
||||
pathname: string,
|
||||
item: NavigationItem,
|
||||
): boolean {
|
||||
return (
|
||||
isPathActive(pathname, item.href) ||
|
||||
item.children?.some((child) => isNavigationItemActive(pathname, child)) ||
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
export function flattenNavigationItems(items: NavigationItem[]): NavigationItem[] {
|
||||
return items.flatMap((item) => [item, ...(item.children ? flattenNavigationItems(item.children) : [])]);
|
||||
export function flattenNavigationItems(
|
||||
items: NavigationItem[],
|
||||
): NavigationItem[] {
|
||||
return items.flatMap((item) => [
|
||||
item,
|
||||
...(item.children ? flattenNavigationItems(item.children) : []),
|
||||
]);
|
||||
}
|
||||
|
||||
export function getCurrentNavigationItem(pathname: string): NavigationItem | undefined {
|
||||
export function getCurrentNavigationItem(
|
||||
pathname: string,
|
||||
): NavigationItem | undefined {
|
||||
const findMatch = (items: NavigationItem[]): NavigationItem | undefined => {
|
||||
for (const item of items) {
|
||||
if (item.children) {
|
||||
|
||||
Reference in New Issue
Block a user