mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-12 02:06:37 +08:00
migrate frontend
This commit is contained in:
@@ -24,32 +24,48 @@ export interface OpenFlareNavItem {
|
||||
|
||||
/** OpenFlare 业务控制台侧栏导航(子页面通过父级入口或页内链接访问) */
|
||||
export const openflareNavItems: OpenFlareNavItem[] = [
|
||||
{title: '总览', url: '/openflare', icon: LayoutDashboard},
|
||||
{title: '节点', url: '/openflare/nodes', icon: Server, childUrls: ['/openflare/nodes/detail']},
|
||||
{title: '规则', url: '/openflare/proxy-routes', icon: Route, childUrls: ['/openflare/proxy-routes/detail']},
|
||||
{title: 'Pages', url: '/openflare/pages', icon: FileText, childUrls: ['/openflare/pages/detail']},
|
||||
{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: '/openflare/websites',
|
||||
url: '/websites',
|
||||
icon: Globe,
|
||||
childUrls: [
|
||||
'/openflare/websites/detail',
|
||||
'/openflare/websites/certificates',
|
||||
'/openflare/websites/dns-accounts',
|
||||
'/websites/detail',
|
||||
'/websites/certificates',
|
||||
'/websites/dns-accounts',
|
||||
],
|
||||
},
|
||||
{title: 'WAF', url: '/openflare/waf', icon: Shield, childUrls: ['/openflare/waf/ip-groups']},
|
||||
{title: '源站', url: '/openflare/origins', icon: MapPin, childUrls: ['/openflare/origins/detail']},
|
||||
{title: '发布', url: '/openflare/config-versions', icon: GitBranch},
|
||||
{title: '访问日志', url: '/openflare/access-logs', icon: ScrollText},
|
||||
{title: '应用日志', url: '/openflare/apply-logs', icon: ClipboardList},
|
||||
{title: '性能', url: '/openflare/performance', icon: Gauge},
|
||||
{title: '关于', url: '/openflare/about', icon: Info},
|
||||
{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: '/apply-logs', icon: ClipboardList},
|
||||
{title: '性能', url: '/performance', icon: Gauge},
|
||||
{title: '关于', url: '/about', icon: Info},
|
||||
];
|
||||
|
||||
/** 网站模块页内二级导航 */
|
||||
export const openflareWebsiteSubNav = [
|
||||
{title: '网站列表', url: '/openflare/websites'},
|
||||
{title: '证书', url: '/openflare/websites/certificates'},
|
||||
{title: 'DNS 账号', url: '/openflare/websites/dns-accounts'},
|
||||
] as const;
|
||||
{title: '网站列表', url: '/websites'},
|
||||
{title: '证书', url: '/websites/certificates'},
|
||||
{title: 'DNS 账号', url: '/websites/dns-accounts'},
|
||||
] as const;
|
||||
|
||||
const nonConsoleRoutePrefixes = ['/admin', '/settings', '/files', '/home', '/login', '/register', '/docs'];
|
||||
|
||||
/** 判断当前路径是否属于 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}/`);
|
||||
});
|
||||
}
|
||||
@@ -96,7 +96,7 @@ export function generateTransactionCacheKey(params: {
|
||||
* 验证并净化重定向目标 URL,防止 Open Redirect 和 XSS 攻击。
|
||||
* 只允许以单个斜杠 "/" 开头的相对路径,拒绝 "//"、协议、反斜杠、控制字符等编码变体。
|
||||
*/
|
||||
export function safeRedirectTarget(url: string | null | undefined, fallback = "/home"): string {
|
||||
export function safeRedirectTarget(url: string | null | undefined, fallback = "/"): string {
|
||||
if (!url) return fallback
|
||||
|
||||
// 1. 拒绝包含控制字符、空白字符或反斜杠的 URL
|
||||
|
||||
@@ -45,14 +45,14 @@ export interface SearchItem {
|
||||
* 包含所有可搜索的页面和功能
|
||||
*/
|
||||
export const searchData: SearchItem[] = [
|
||||
// ==================== 首页 ====================
|
||||
// ==================== 总览 ====================
|
||||
{
|
||||
id: 'home',
|
||||
title: '首页',
|
||||
description: '返回首页控制台',
|
||||
url: '/home',
|
||||
title: '总览',
|
||||
description: '返回控制台总览',
|
||||
url: '/',
|
||||
category: 'page',
|
||||
keywords: ['home', '主页', '首页', 'dashboard'],
|
||||
keywords: ['home', '主页', '首页', 'dashboard', '总览'],
|
||||
},
|
||||
|
||||
// ==================== 文档库 ====================
|
||||
|
||||
Reference in New Issue
Block a user