From 3f96c9c6502243b06efd4bb34a189e72e3a5557c Mon Sep 17 00:00:00 2001
From: yearning <10538594+wangweifeng1999@user.noreply.gitee.com>
Date: 星期一, 28 九月 2026 19:24:55 +0800
Subject: [PATCH] 复制项目
---
frontend/src/layout/AppBreadcrumb.tsx | 72 ++++++++++++++++++++++++++++++++++++
1 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/frontend/src/layout/AppBreadcrumb.tsx b/frontend/src/layout/AppBreadcrumb.tsx
new file mode 100644
index 0000000..eddfdc9
--- /dev/null
+++ b/frontend/src/layout/AppBreadcrumb.tsx
@@ -0,0 +1,72 @@
+import { Breadcrumb, Button } from "antd";
+import { ArrowLeftOutlined, HomeOutlined } from "@ant-design/icons";
+import { Link, matchPath, useLocation, useNavigate } from "react-router-dom";
+import type { ReactNode } from "react";
+import { readScoreListQuery, scoresListPath } from "../scoreQueryParams";
+
+type Crumb = { title: ReactNode; key: string };
+
+function buildCrumbs(pathname: string, search: string): Crumb[] {
+ const home: Crumb = {
+ key: "home",
+ title: (
+ <Link to="/scores">
+ <HomeOutlined style={{ marginRight: 4 }} />
+ 棣栭〉
+ </Link>
+ ),
+ };
+
+ if (matchPath("/scores", pathname)) {
+ return [home, { key: "scores", title: "鎴愮哗鏌ヨ" }];
+ }
+
+ if (matchPath("/attempts/:attemptId", pathname)) {
+ const scoresTo = scoresListPath(readScoreListQuery(search));
+ return [
+ home,
+ { key: "scores", title: <Link to={scoresTo}>鎴愮哗鏌ヨ</Link> },
+ { key: "attempt", title: "绛斿嵎璇︽儏" },
+ ];
+ }
+
+ if (matchPath("/admin/import", pathname)) {
+ return [home, { key: "admin-import", title: "鏁版嵁瀵煎叆" }];
+ }
+
+ if (matchPath("/admin/graders", pathname)) {
+ return [home, { key: "admin-graders", title: "鑰冭瘎鍛樼鐞�" }];
+ }
+
+ if (matchPath("/admin/settings", pathname)) {
+ return [home, { key: "admin-settings", title: "绯荤粺璁剧疆" }];
+ }
+
+ return [home];
+}
+
+export default function AppBreadcrumb() {
+ const { pathname, search } = useLocation();
+ const navigate = useNavigate();
+ const crumbs = buildCrumbs(pathname, search);
+ const onAttempt = Boolean(matchPath("/attempts/:attemptId", pathname));
+
+ return (
+ <div className="app-breadcrumb-row">
+ {onAttempt && (
+ <Button
+ type="link"
+ className="app-breadcrumb__back"
+ icon={<ArrowLeftOutlined />}
+ onClick={() => navigate(scoresListPath(readScoreListQuery(search)))}
+ >
+ 杩斿洖
+ </Button>
+ )}
+ <Breadcrumb
+ className="app-breadcrumb"
+ items={crumbs.map((c) => ({ key: c.key, title: c.title }))}
+ />
+ </div>
+ );
+}
--
Gitblit v1.8.0