Files
UHD_Media_Tool/apps/web/app/components/console/nav.ts
T
rootandClaude Opus 5.5 31a54186c7 copy: second-round copy review across console, settings, agent and server messages
- Trim descriptions, empty states, confirm buttons and toasts to facts
- Unify terms per glossary: 待处理/待识别/整理记录/运行记录/凭证/子会话/Agent 上游
- Subscription-login termsNote states facts only (borrowed client identity, ToS/ban risk)
- Shorter, concrete goal templates for built-in Agent checks
- Human-readable nouns instead of table names in instance CRUD errors
- Audit labels for pi_upstream / schedule / automation_grant actions
- Glossary: add 上游、订阅登录、凭证、定时任务、巡检、运行记录、子会话、停止、持续授权

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

235 lines
6.0 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/:section 之前,先落到现有 ?tab=;
* 调用方只认新分区名,切换时只改这里。
*/
export type SettingsSection =
| "automation"
| "sites"
| "downloaders"
| "library"
| "media-servers"
| "metadata"
| "agent"
| "api-keys"
| "account";
const SETTINGS_LEGACY_TAB: Partial<Record<SettingsSection, string>> = {
automation: "automation",
sites: "site-credentials",
downloaders: "downloaders",
library: "library-roots",
"media-servers": "media-servers",
agent: "pi",
"api-keys": "api-keys",
};
export function settingsPath(section: SettingsSection, anchor?: string): string {
// 缓存阈值现在在"缓存与入库"页签,IA-2 后归到 automation#cache
const tab = section === "automation" && anchor === "cache" ? "storage" : SETTINGS_LEGACY_TAB[section];
return tab ? `${CONSOLE_BASE}/settings?tab=${tab}` : `${CONSOLE_BASE}/settings`;
}
/** 按路径找当前导航项(最长前缀匹配) */
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]
);
}