feat(web): 记录抽屉与两层导航标准
控制台导航最多两层(侧栏一项 = 一页,页内最多一层页签 / 分段);从列表打开的
记录改成列表页上的右侧抽屉,打开的记录写在 ?open=,刷新、分享、前进后退都能还原,
后退就是关抽屉。标准写在 docs/design/console-ia.md §9,ui-controls.md 引用。
- DetailSheet 加 xl 宽度、标题下操作行;抽屉里再开的 DetailSheet 在同一抽屉里换成子视图(返回 / Esc)
- record-sheet.tsx:useRecordSheet / RecordLink / useOpenRecord / recordPath / taskPath
- 整理记录、订阅、站点(含页签)、下载、日志任务改成抽屉;旧业务任务 / 下载任务 id 在任务抽屉里换算
- 回收站并进文件管理右侧视图(?view=trash);设置左栏只列分区
- 规则组、策略版本、媒体库未识别 / 外部身份、设置实例编辑走 ?open=
- 旧地址 /console/{organize,subscriptions,sites,downloads}/:id、/tasks/:id、/files/trash 跳到列表页抽屉
- 站内链接、铃铛、命令面板、任务时间线改拼新地址;冒烟按 ?open= 检查抽屉
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
1 parent
dd0f6e2c09
commit
21c55dfb3a
60 files changed
+2768
-2461
No files matched your search
@@ -32,7 +32,7 @@ describe("下载面板展示换算(DL-2)", () => {
|
||||
expect(organizeState({ status: "completed", organize: rec("succeeded") })).toMatchObject({
|
||||
label: "已整理",
|
||||
tone: "success",
|
||||
to: `/console/organize/${RID}`,
|
||||
to: `/console/organize?open=${RID}`,
|
||||
});
|
||||
expect(organizeState({ status: "completed", organize: rec("running") })?.label).toBe("整理中");
|
||||
const failed = organizeState({
|
||||
@@ -48,7 +48,7 @@ describe("下载面板展示换算(DL-2)", () => {
|
||||
tone: "destructive",
|
||||
hint: "没识别出作品。指定作品后重新整理",
|
||||
});
|
||||
expect(failed?.to).toBe(`/console/organize/${RID}`);
|
||||
expect(failed?.to).toBe(`/console/organize?open=${RID}`);
|
||||
expect(organizeState({ status: "completed", organize: rec("failed", { reason: "磁盘已满" }) })?.hint).toBe(
|
||||
"磁盘已满",
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { DownloadBoardItem, DownloadBoardState, DownloadLive } from "@umt/contracts";
|
||||
import { consolePath } from "~/components/console/nav.ts";
|
||||
import { recordPath } from "~/components/console/record-sheet.tsx";
|
||||
import { reasonLine } from "~/lib/reasons.ts";
|
||||
import { formatBytes } from "~/lib/utils.ts";
|
||||
|
||||
@@ -49,7 +49,7 @@ export function organizeState(
|
||||
const rec = t.organize;
|
||||
if (t.managed === false && !rec && t.status !== "importing" && t.status !== "imported") return null;
|
||||
// 有问题的整理在整理记录详情里就地处理(待处理中心已取消)
|
||||
const to = rec ? consolePath("organize", rec.recordId) : null;
|
||||
const to = rec ? recordPath("organize", rec.recordId) : null;
|
||||
if (rec?.status === "succeeded" || (t.status === "imported" && rec?.status !== "failed"))
|
||||
return { label: "已整理", tone: "success", to, hint: null };
|
||||
if (rec?.status === "failed") return { label: "整理失败", tone: "destructive", to, hint: reasonHint(rec.reason) };
|
||||
|
||||
@@ -1,27 +1,23 @@
|
||||
import { keepPreviousData, useInfiniteQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { cursorPage, Task, type TaskKind, type TaskStatus } from "@umt/contracts";
|
||||
import { ListTodo, RotateCcw, Square } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { RotateCcw, Square } from "lucide-react";
|
||||
import { Link } from "react-router";
|
||||
import { toast } from "sonner";
|
||||
import { apiMutate, apiParsed, cleanParams } from "~/api/parse.ts";
|
||||
import { type DataColumn, DataTable } from "~/components/console/data-table.tsx";
|
||||
import { DetailSection, DetailSheet } from "~/components/console/detail-sheet.tsx";
|
||||
import { FilterBar, FilterSelect } from "~/components/console/filter-bar.tsx";
|
||||
import { apiMutate } from "~/api/parse.ts";
|
||||
import { DetailSection } from "~/components/console/detail-sheet.tsx";
|
||||
import { KvList } from "~/components/console/kv-list.tsx";
|
||||
import { consolePath } from "~/components/console/nav.ts";
|
||||
import { recordPath, taskPath } from "~/components/console/record-sheet.tsx";
|
||||
import { StatusBadge } from "~/components/console/status-badge.tsx";
|
||||
import { useQueryState } from "~/components/console/use-query-state.ts";
|
||||
import { Button } from "~/components/ui/button.tsx";
|
||||
import { relTime } from "~/components/workbench/release-fields.ts";
|
||||
import { errorMessage, TTL_SECOND } from "~/lib/api.ts";
|
||||
import { errorMessage } from "~/lib/api.ts";
|
||||
import { actorText } from "~/lib/labels.ts";
|
||||
import { formatDateTime } from "~/lib/utils.ts";
|
||||
|
||||
// 业务任务(/tasks):引擎只负责推进,task 表是面向用户的投影;取消只停后续步骤,重试只对失败任务。
|
||||
// 引擎运行只在详情里给链接,引擎面板在系统组。
|
||||
// 旧业务任务(task 表)的展示零件:引擎只负责推进,task 表是面向用户的投影;取消只停后续步骤,重试只对失败任务。
|
||||
// 只剩日志页任务抽屉在打开旧任务 id 时用(components/tasks/legacy-task.tsx)。
|
||||
|
||||
const TaskPage = cursorPage(Task);
|
||||
const _TaskPage = cursorPage(Task);
|
||||
|
||||
export const TASK_KIND_LABEL: Record<TaskKind, string> = {
|
||||
ingestFeed: "抓取 RSS",
|
||||
@@ -71,15 +67,15 @@ export function subjectLink(t: Pick<Task, "subjectType" | "subjectId">): string
|
||||
if (!t.subjectId) return null;
|
||||
switch (t.subjectType) {
|
||||
case "download_task":
|
||||
return consolePath("downloads", t.subjectId);
|
||||
return recordPath("downloads", t.subjectId);
|
||||
case "acquisition_plan":
|
||||
return `${consolePath("downloads")}?plan=${encodeURIComponent(t.subjectId)}`;
|
||||
case "organization_record":
|
||||
return consolePath("organize", t.subjectId);
|
||||
return recordPath("organize", t.subjectId);
|
||||
case "media_entity":
|
||||
return consolePath("library", t.subjectId);
|
||||
case "site":
|
||||
return consolePath("sites", t.subjectId);
|
||||
return recordPath("sites", t.subjectId);
|
||||
case "feed_source":
|
||||
// RSS 属于站点(IA-2):按 ?feed= 查所属站点后跳到站点的 RSS Tab
|
||||
return `${consolePath("sources")}?feed=${encodeURIComponent(t.subjectId)}`;
|
||||
@@ -147,130 +143,6 @@ export function TaskActions({ t, size = "sm" }: { t: Task; size?: "sm" | "xs" })
|
||||
return null;
|
||||
}
|
||||
|
||||
export function BusinessTasks() {
|
||||
const f = useQueryState(["kind", "status"] as const);
|
||||
const { kind, status } = f.values;
|
||||
const [openId, setOpenId] = useState<string | null>(null);
|
||||
const list = useInfiniteQuery({
|
||||
queryKey: ["tasks", "list", kind, status],
|
||||
initialPageParam: undefined as string | undefined,
|
||||
placeholderData: keepPreviousData,
|
||||
queryFn: ({ pageParam, signal }) =>
|
||||
apiParsed(TaskPage, "/api/v1/tasks", {
|
||||
params: cleanParams({ kind, status, cursor: pageParam, limit: 50 }),
|
||||
signal,
|
||||
}),
|
||||
getNextPageParam: (last) => last.nextCursor ?? undefined,
|
||||
refetchInterval: (q) =>
|
||||
q.state.data?.pages.some((p) => p.items.some((t) => ACTIVE_TASK.includes(t.status))) ? 5 * TTL_SECOND : false,
|
||||
});
|
||||
const rows = list.data?.pages.flatMap((p) => p.items);
|
||||
const open = rows?.find((t) => t.id === openId) ?? null;
|
||||
|
||||
const columns: DataColumn<Task>[] = [
|
||||
{
|
||||
key: "kind",
|
||||
header: "任务",
|
||||
cell: (t) => (
|
||||
<div className="min-w-0">
|
||||
<p className="font-medium text-foreground">{TASK_KIND_LABEL[t.kind] ?? t.kind}</p>
|
||||
<p className="truncate text-meta text-muted-foreground">{subjectText(t)}</p>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: "status",
|
||||
header: "状态",
|
||||
cell: (t) => (
|
||||
<div className="flex flex-col items-start gap-1">
|
||||
<StatusBadge tone={TASK_STATUS[t.status].tone}>{TASK_STATUS[t.status].label}</StatusBadge>
|
||||
{t.waitReason ? <span className="text-micro text-muted-foreground">{t.waitReason}</span> : null}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: "attempts",
|
||||
header: "尝试",
|
||||
hideBelow: "md",
|
||||
align: "right",
|
||||
cell: (t) => (
|
||||
<span className="tabular-nums">
|
||||
{t.attempts}/{t.maxAttempts}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: "by",
|
||||
header: "触发",
|
||||
hideBelow: "lg",
|
||||
cell: (t) => <span className="text-muted-foreground">{actorText(t.triggeredBy)}</span>,
|
||||
},
|
||||
{
|
||||
key: "at",
|
||||
header: "创建",
|
||||
hideBelow: "sm",
|
||||
cell: (t) => <span className="whitespace-nowrap text-muted-foreground">{relTime(t.createdAt)}</span>,
|
||||
},
|
||||
{ key: "ops", header: "", align: "right", cell: (t) => <TaskActions t={t} size="xs" /> },
|
||||
];
|
||||
|
||||
return (
|
||||
<>
|
||||
<FilterBar onReset={f.active ? f.reset : undefined}>
|
||||
<FilterSelect
|
||||
label="类型"
|
||||
value={kind}
|
||||
onChange={(v) => f.set("kind", v)}
|
||||
options={Object.entries(TASK_KIND_LABEL).map(([value, label]) => ({ value, label }))}
|
||||
/>
|
||||
<FilterSelect
|
||||
label="状态"
|
||||
value={status}
|
||||
onChange={(v) => f.set("status", v)}
|
||||
options={Object.entries(TASK_STATUS).map(([value, v]) => ({ value, label: v.label }))}
|
||||
/>
|
||||
</FilterBar>
|
||||
<DataTable
|
||||
paginationKey={JSON.stringify(f.values)}
|
||||
columns={columns}
|
||||
rows={rows}
|
||||
rowKey={(t) => t.id}
|
||||
loading={list.isPending}
|
||||
error={list.error}
|
||||
onRetry={() => void list.refetch()}
|
||||
onRowClick={(t) => setOpenId(t.id)}
|
||||
selectedKey={openId}
|
||||
hasMore={list.hasNextPage}
|
||||
onLoadMore={() => void list.fetchNextPage()}
|
||||
loadingMore={list.isFetchingNextPage}
|
||||
empty={{
|
||||
icon: ListTodo,
|
||||
title: f.active ? "没有符合筛选的任务" : "还没有后台任务",
|
||||
description: f.active ? undefined : "提交下载、核验整理、清理缓存、文件核对等任务会出现在这里。",
|
||||
}}
|
||||
/>
|
||||
<DetailSheet
|
||||
open={!!open}
|
||||
onOpenChange={(o) => !o && setOpenId(null)}
|
||||
title={open ? (TASK_KIND_LABEL[open.kind] ?? open.kind) : ""}
|
||||
description={open ? <TaskStatusLine t={open} /> : undefined}
|
||||
footer={
|
||||
open ? (
|
||||
<>
|
||||
<TaskActions t={open} />
|
||||
<Button asChild size="sm">
|
||||
<Link to={consolePath("tasks", open.id)}>打开详情页</Link>
|
||||
</Button>
|
||||
</>
|
||||
) : null
|
||||
}
|
||||
>
|
||||
{open ? <TaskSummary t={open} /> : null}
|
||||
</DetailSheet>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function TaskStatusLine({ t }: { t: Task }) {
|
||||
return (
|
||||
<span className="flex flex-wrap items-center gap-1.5">
|
||||
@@ -280,7 +152,7 @@ export function TaskStatusLine({ t }: { t: Task }) {
|
||||
);
|
||||
}
|
||||
|
||||
/** 概况 + 关联对象(抽屉与详情页共用) */
|
||||
/** 概况 + 关联对象 */
|
||||
export function TaskSummary({ t }: { t: Task }) {
|
||||
const href = subjectLink(t);
|
||||
const err = t.lastError
|
||||
@@ -322,7 +194,7 @@ export function TaskSummary({ t }: { t: Task }) {
|
||||
{
|
||||
label: "上级任务",
|
||||
value: t.parentTaskId ? (
|
||||
<Link to={consolePath("tasks", t.parentTaskId)} className="font-mono underline underline-offset-4">
|
||||
<Link to={taskPath(t.parentTaskId)} className="font-mono underline underline-offset-4">
|
||||
{t.parentTaskId.slice(0, 8)}
|
||||
</Link>
|
||||
) : null,
|
||||
@@ -330,7 +202,7 @@ export function TaskSummary({ t }: { t: Task }) {
|
||||
{
|
||||
label: "引擎运行",
|
||||
value: t.engineRunId ? (
|
||||
<Link to={consolePath("tasks", t.engineRunId)} className="font-mono underline underline-offset-4">
|
||||
<Link to={taskPath(t.engineRunId)} className="font-mono underline underline-offset-4">
|
||||
{t.engineRunId.slice(0, 12)}
|
||||
</Link>
|
||||
) : null,
|
||||
|
||||
@@ -6,7 +6,8 @@ import { useCacheCleanup, useCacheVolumes } from "~/api/downloads.ts";
|
||||
import { downloaders } from "~/api/instances.ts";
|
||||
import { ConfirmDialog } from "~/components/console/confirm-dialog.tsx";
|
||||
import { ErrorState, LoadingState } from "~/components/console/empty-state.tsx";
|
||||
import { consolePath, settingsPath } from "~/components/console/nav.ts";
|
||||
import { settingsPath } from "~/components/console/nav.ts";
|
||||
import { taskPath } from "~/components/console/record-sheet.tsx";
|
||||
import { StatusBadge } from "~/components/console/status-badge.tsx";
|
||||
import { TechInfo } from "~/components/console/tech-info.tsx";
|
||||
import { Button } from "~/components/ui/button.tsx";
|
||||
@@ -125,7 +126,7 @@ export function CacheVolumes() {
|
||||
cleanup.mutateAsync(undefined).then(
|
||||
(r) => {
|
||||
toast.success("清理已排队");
|
||||
navigate(consolePath("tasks", r.taskId));
|
||||
navigate(taskPath(r.taskId));
|
||||
},
|
||||
(e) => toast.error(errorMessage(e)),
|
||||
)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { DownloadLive, DownloadTask } from "@umt/contracts";
|
||||
import { Bot, FolderInput, Pause, Play, ShieldAlert } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { Link } from "react-router";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
DOWNLOAD_STATUS_LABEL,
|
||||
@@ -17,6 +16,7 @@ import { openAgentDrawer } from "~/components/agent/agent-store.ts";
|
||||
import { DetailSection } from "~/components/console/detail-sheet.tsx";
|
||||
import { JsonView } from "~/components/console/json-view.tsx";
|
||||
import { KvList } from "~/components/console/kv-list.tsx";
|
||||
import { RecordLink } from "~/components/console/record-sheet.tsx";
|
||||
import { StatusBadge } from "~/components/console/status-badge.tsx";
|
||||
import { TechInfo } from "~/components/console/tech-info.tsx";
|
||||
import { OrganizeWizard } from "~/components/organize-wizard/organize-wizard.tsx";
|
||||
@@ -144,9 +144,9 @@ export function DownloadDetail({ task, live }: { task: DownloadTask; live?: Down
|
||||
{importFailed ? (
|
||||
<p className="rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-caption text-destructive">
|
||||
整理失败:{reasonLine(importFailed.reason)}。
|
||||
<Link to={`/console/organize/${importFailed.id}`} className="ml-1 underline underline-offset-4">
|
||||
<RecordLink page="organize" id={importFailed.id} className="ml-1 underline underline-offset-4">
|
||||
去整理记录处理
|
||||
</Link>
|
||||
</RecordLink>
|
||||
</p>
|
||||
) : null}
|
||||
{task.noProgressSince ? (
|
||||
|
||||
Reference in new issue
Block a user