Files
UHD_Media_Tool/apps/web/app/components/console/nav.ts
T
rootandClaude Opus 5.5 f8362a3f4c feat(web): site center page, add-site wizard, credentials, health and user-data chart (FE-2)
- 资源 → 站点:卡片 / 列表切换(URL ?view= + localStorage 记住),筛选全部 / 已启用 / 需处理,
  按分享率 / 上传 / 上次登录排序;卡片显示账号状态、凭证类型、上次登录、上传 / 下载 / 分享率、
  等级 / VIP、做种、健康检测结果与时间、快照、限流
- 操作:检测健康、刷新登录(wait:true 同步结果)、更新凭证、编辑(限流 / 快照 / 代理)、启停、
  删除(确认框列出影响)
- 添加站点向导:按适配器分组选 23 个定义(未实测标注)→ 名称 / 域名覆盖 / 凭证三选一
  (馒头默认 API Key)→ 保存并测试(刷新登录 + 健康检测);验证码 / 二次验证提示改用 Cookie
  并链接待处理
- 站点详情:概览(用户数据磁贴 + 30 天上传 / 下载与分享率折线,recharts,无彩)/ 资源 /
  快照与 Feed / 账号(凭证管理、Passkey、登录历史)
- 设置"站点与账号"改为"站点默认"(限流、快照周期、UA、代理、做种页数)
- 侧栏改名"站点";smoke 补站点路由;依赖新增 recharts

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-28 16:08:29 +08:00

221 lines
5.5 KiB
TypeScript

import {
Activity,
Bot,
CalendarClock,
ClipboardList,
Download,
FileStack,
Fingerprint,
FolderTree,
Globe,
House,
Inbox,
Library,
ListChecks,
ListTodo,
type LucideIcon,
Rss,
ScrollText,
Settings,
Tags,
Timer,
} from "lucide-react";
export type NavItem = {
to: string;
label: string;
icon: LucideIcon;
description: string;
/** 侧栏角标的数据来源 */
badge?: "decisions";
};
export type NavGroup = { title: string; items: NavItem[] };
/** 控制台路由前缀 */
export const CONSOLE_BASE = "/console";
/** 拼控制台路径:consolePath("library", id) → /console/library/<id> */
export function consolePath(...segments: (string | number)[]): string {
const rest = segments.map((s) => encodeURIComponent(String(s))).join("/");
return rest ? `${CONSOLE_BASE}/${rest}` : CONSOLE_BASE;
}
/**
* 侧栏 7 组(docs/design/console-ia.md §3.2),按业务流程排:概览 → 资源 → 订阅 → 下载 → 整理 → Agent → 系统。
* 移动端抽屉用同一份表。
*/
export const NAV_GROUPS: NavGroup[] = [
{
title: "概览",
items: [
{
to: "/console",
label: "首页",
icon: House,
description: "自动化概览、当前工作、待处理、缓存、来源健康、最近产出",
},
{
to: "/console/inbox",
label: "待处理",
icon: Inbox,
description: "按作品和问题类型合并的待处理事项",
badge: "decisions",
},
],
},
{
title: "资源",
items: [
{
to: "/console/sites",
label: "站点",
icon: Globe,
description: "站点、凭证、账号数据与健康;资源、快照与 Feed",
},
{
to: "/console/sources",
label: "来源健康",
icon: Rss,
description: "全部 Feed 与站点的抓取状态",
},
],
},
{
title: "订阅",
items: [
{
to: "/console/subscriptions",
label: "订阅",
icon: CalendarClock,
description: "单次收录与持续追踪",
},
{
to: "/console/rules",
label: "收录策略",
icon: ListChecks,
description: "新作品收录条件、默认版本目标与策略版本",
},
{
to: "/console/preferences",
label: "偏好标签",
icon: Tags,
description: "软偏好影响排序,硬规则直接排除",
},
],
},
{
title: "下载",
items: [
{
to: "/console/downloads",
label: "下载队列",
icon: Download,
description: "下载任务与缓存水位",
},
{
to: "/console/downloads/plans",
label: "下载计划",
icon: ClipboardList,
description: "选中候选后生成的计划与空间预留",
},
{
to: "/console/tasks",
label: "业务任务",
icon: ListTodo,
description: "提交下载、核验入库、清理缓存等后台任务",
},
],
},
{
title: "整理",
items: [
{ to: "/console/library", label: "媒体库", icon: Library, description: "作品、季 / 集、版本目标与实际路径" },
{
to: "/console/organize",
label: "整理记录",
icon: FileStack,
description: "每次整理的前后路径与逐文件结果",
},
{
to: "/console/files",
label: "文件管理",
icon: FolderTree,
description: "浏览登记目录,改名、移动、删除与整理",
},
{
to: "/console/identity",
label: "身份与元数据",
icon: Fingerprint,
description: "外部身份、待识别资源与别名",
},
],
},
{
title: "Agent",
items: [
{
to: "/console/agent",
label: "Agent 会话",
icon: Bot,
description: "交代目标,Agent 在授权内执行并汇报",
},
],
},
{
title: "系统",
items: [
{
to: "/console/settings",
label: "设置",
icon: Settings,
description: "下载器、媒体服务器、库根、站点账号、Agent 上游与自动化",
},
{
to: "/console/schedules",
label: "定时任务",
icon: Timer,
description: "周期任务与 Agent 巡检的开关、间隔和运行记录",
},
{
to: "/console/engine",
label: "引擎面板",
icon: Activity,
description: "排查用,业务进度看业务任务。仅管理员",
},
{
to: "/console/audit",
label: "审计日志",
icon: ScrollText,
description: "登录、设置、密钥与实例变更的操作留痕",
},
],
},
];
export const NAV_ITEMS = NAV_GROUPS.flatMap((g) => g.items);
/** 设置页深链(IA-2):`/console/settings#分区[/节]`。调用方只认新分区名 */
export type SettingsSection =
| "automation"
| "sites"
| "downloaders"
| "library"
| "media-servers"
| "metadata"
| "agent"
| "api-keys"
| "account";
export function settingsPath(section: SettingsSection, anchor?: string): string {
return `${CONSOLE_BASE}/settings#${section}${anchor ? `/${anchor}` : ""}`;
}
/** 按路径找当前导航项(最长前缀匹配) */
export function findNavItem(pathname: string): NavItem | undefined {
return (
NAV_ITEMS.find((i) => i.to === pathname.replace(/\/+$/, "")) ??
NAV_ITEMS.filter((i) => i.to !== CONSOLE_BASE && pathname.startsWith(`${i.to}/`)).sort(
(a, b) => b.to.length - a.to.length,
)[0]
);
}