mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-27 23:19:40 +08:00
feat(task-detail): 路由、面包屑与侧边栏配套
- App: 新增 /console/task/:taskId 路由 - page: BreadcrumbTaskProvider + 任务详情页动态面包屑 - nav-project: 未关联任务上限 3→5,侧边栏样式微调 Made-with: Cursor
This commit is contained in:
1 parent
ce8a698a67
commit
69b5a18933
3 files changed
+27
-11
No files matched your search
@@ -28,6 +28,7 @@ import PublicTaskPage from "./pages/public-task"
|
||||
import PostCreatePage from "./pages/post-create"
|
||||
import ProjectOverviewPage from "./pages/console/user/project/overview"
|
||||
import TaskDevelopPage from "./pages/console/user/task/task-dev"
|
||||
import TaskDetailPage from "./pages/console/user/task/task-detail"
|
||||
|
||||
function App() {
|
||||
return (
|
||||
@@ -46,6 +47,7 @@ function App() {
|
||||
<Route path="/console" element={<UserConsolePage />}>
|
||||
<Route index element={<Navigate to="/console/tasks" replace />} />
|
||||
<Route path="tasks" element={<TasksPage />} />
|
||||
<Route path="task/:taskId" element={<TaskDetailPage />} />
|
||||
<Route path="project/:projectId" element={<ProjectOverviewPage />} />
|
||||
<Route path="gitbot" element={<GitBotsPage />} />
|
||||
<Route path="ide" element={<IDEIDE />} />
|
||||
|
||||
@@ -25,7 +25,7 @@ import { cn } from "@/lib/utils"
|
||||
import { apiRequest } from "@/utils/requestUtils"
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"
|
||||
|
||||
const UNLINKED_TASKS_LIMIT = 3
|
||||
const UNLINKED_TASKS_LIMIT = 5
|
||||
const UNLINKED_TASKS_FETCH_SIZE = 50
|
||||
const STORAGE_KEY = "nav-project-expanded"
|
||||
const UNLINKED_KEY = "__unlinked__"
|
||||
@@ -196,7 +196,7 @@ export default function NavProject() {
|
||||
<SidebarMenuItem>
|
||||
<div
|
||||
className={cn(
|
||||
"flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
"flex w-full items-center gap-1 overflow-hidden rounded-md p-1 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
isUnlinkedActive && "bg-sidebar-accent font-medium text-sidebar-accent-foreground"
|
||||
)}
|
||||
>
|
||||
@@ -224,8 +224,8 @@ export default function NavProject() {
|
||||
</div>
|
||||
<CollapsibleContent>
|
||||
{unlinkedTasks.length > 0 && (
|
||||
<SidebarMenuSub>
|
||||
<SidebarMenuSubItem className="flex flex-col gap-1">
|
||||
<SidebarMenuSub className="ml-1 mr-0 border-none">
|
||||
<SidebarMenuSubItem className="flex flex-col">
|
||||
{unlinkedTasks.map((task: DomainProjectTask) => {
|
||||
const TaskIcon =
|
||||
task.status === "finished" || task.status === "error"
|
||||
@@ -276,7 +276,7 @@ export default function NavProject() {
|
||||
<SidebarMenuItem>
|
||||
<div
|
||||
className={cn(
|
||||
"group/project-row flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
"group/project-row flex w-full items-center gap-1 overflow-hidden rounded-md p-1 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
isProjectActive && "bg-sidebar-accent font-medium text-sidebar-accent-foreground"
|
||||
)}
|
||||
>
|
||||
@@ -317,8 +317,8 @@ export default function NavProject() {
|
||||
</Tooltip>
|
||||
</div>
|
||||
<CollapsibleContent>
|
||||
<SidebarMenuSub>
|
||||
<SidebarMenuSubItem className="flex flex-col gap-1">
|
||||
<SidebarMenuSub className="ml-1 mr-0 border-none">
|
||||
<SidebarMenuSubItem className="flex flex-col">
|
||||
{(project.tasks || []).map((task: DomainProjectTask) => {
|
||||
const TaskIcon =
|
||||
task.status === "finished" || task.status === "error"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { BreadcrumbTaskProvider, useBreadcrumbTask } from "@/components/console/breadcrumb-task-context"
|
||||
import { Fragment } from "react"
|
||||
import { Outlet, useLocation } from "react-router-dom"
|
||||
import UserSidebar from "@/components/console/nav/user-sidebar"
|
||||
@@ -25,8 +26,9 @@ import {
|
||||
HoverCardTrigger,
|
||||
} from "@/components/ui/hover-card"
|
||||
|
||||
export default function UserConsolePage() {
|
||||
function UserConsoleContent() {
|
||||
const location = useLocation()
|
||||
const { taskName } = useBreadcrumbTask() ?? { taskName: null }
|
||||
|
||||
const breadcrumbSegmentsMap: Record<
|
||||
string,
|
||||
@@ -57,12 +59,16 @@ export default function UserConsolePage() {
|
||||
|
||||
const normalizedPath =
|
||||
location.pathname !== "/" ? location.pathname.replace(/\/$/, "") : location.pathname
|
||||
|
||||
|
||||
// 动态路由的 breadcrumb:/console/task/:taskId(排除 develop)
|
||||
const taskDetailMatch = normalizedPath.match(/^\/console\/task\/(?!develop\/)(.+)$/)
|
||||
const breadcrumbSegments =
|
||||
breadcrumbSegmentsMap[normalizedPath] ?? [{ label: "用户控制台" }]
|
||||
breadcrumbSegmentsMap[normalizedPath] ??
|
||||
(taskDetailMatch
|
||||
? [{ label: "任务", href: "/console/tasks" }, { label: taskName ?? "未知任务名称" }]
|
||||
: [{ label: "用户控制台" }])
|
||||
|
||||
return (
|
||||
|
||||
<DataProvider>
|
||||
<SidebarProvider>
|
||||
<UserSidebar />
|
||||
@@ -141,3 +147,11 @@ export default function UserConsolePage() {
|
||||
</DataProvider>
|
||||
)
|
||||
}
|
||||
|
||||
export default function UserConsolePage() {
|
||||
return (
|
||||
<BreadcrumbTaskProvider>
|
||||
<UserConsoleContent />
|
||||
</BreadcrumbTaskProvider>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user