Merge branch 'main' into dev

合并侧栏「网站管理」折叠组:保留 dev 导航命名(版本发布等),
源站移入折叠组,并采用 matchesNavPath / isNavGroupActive 路由匹配逻辑。
This commit is contained in:
ryan
2026-06-18 19:49:31 +08:00
5 changed files with 193 additions and 38 deletions
@@ -5,7 +5,6 @@ import {
GitBranch,
Globe,
LayoutDashboard,
MapPin,
Route,
ScrollText,
Server,
@@ -20,29 +19,42 @@ export interface OpenFlareNavItem {
childUrls?: string[];
}
export interface OpenFlareNavSubItem {
title: string;
url: string;
childUrls?: string[];
}
export interface OpenFlareNavGroup {
title: string;
icon: LucideIcon;
items: OpenFlareNavSubItem[];
}
/** OpenFlare 业务控制台侧栏导航(子页面通过父级入口或页内链接访问) */
export const openflareNavItems: OpenFlareNavItem[] = [
{title: '数据看板', url: '/', icon: LayoutDashboard},
{title: '节点管理', url: '/nodes', icon: Server, childUrls: ['/nodes/detail']},
{title: '规则管理', url: '/proxy-routes', icon: Route, childUrls: ['/proxy-routes/detail']},
{title: 'Pages', url: '/pages', icon: FileText, childUrls: ['/pages/detail']},
{
title: '网站',
url: '/websites',
icon: Globe,
childUrls: [
'/websites/detail',
'/websites/certificates',
'/websites/dns-accounts',
],
},
{title: 'WAF', url: '/waf', icon: Shield, childUrls: ['/waf/ip-groups']},
{title: '源站', url: '/origins', icon: MapPin, childUrls: ['/origins/detail']},
{title: '版本发布', url: '/config-versions', icon: GitBranch},
{title: '访问日志', url: '/access-logs', icon: ScrollText},
{title: '性能调优', url: '/performance', icon: Gauge},
];
/** 网站管理折叠组 */
export const openflareWebsiteNavGroup: OpenFlareNavGroup = {
title: '网站管理',
icon: Globe,
items: [
{title: '网站', url: '/websites', childUrls: ['/websites/detail']},
{title: '证书', url: '/websites/certificates'},
{title: 'DNS', url: '/websites/dns-accounts'},
{title: '源站', url: '/origins', childUrls: ['/origins/detail']},
],
};
/** 网站模块页内二级导航 */
export const openflareWebsiteSubNav = [
{title: '网站列表', url: '/websites'},
@@ -52,16 +64,37 @@ export const openflareWebsiteSubNav = [
const nonConsoleRoutePrefixes = ['/admin', '/settings', '/files', '/home', '/login', '/register', '/docs'];
export function matchesNavPath(
pathname: string,
url: string,
childUrls?: string[],
): boolean {
if (url === '/') {
return pathname === '/';
}
if (pathname === url || pathname.startsWith(`${url}/`)) {
return true;
}
return (childUrls ?? []).some(
(childUrl) => pathname === childUrl || pathname.startsWith(`${childUrl}/`),
);
}
export function isNavGroupActive(pathname: string, group: OpenFlareNavGroup): boolean {
return group.items.some((item) => matchesNavPath(pathname, item.url, item.childUrls));
}
/** 判断当前路径是否属于 OpenFlare 业务控制台(用于顶栏版本入口等) */
export function isOpenFlareConsoleRoute(pathname: string): boolean {
if (nonConsoleRoutePrefixes.some((prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`))) {
return false;
}
return openflareNavItems.some((item) => {
if (item.url === '/') {
return pathname === '/';
}
return pathname === item.url || pathname.startsWith(`${item.url}/`);
});
if (isNavGroupActive(pathname, openflareWebsiteNavGroup)) {
return true;
}
return openflareNavItems.some((item) => matchesNavPath(pathname, item.url, item.childUrls));
}