From 0b3ce76216f6e6e092fdf63220b56eb940bd4a99 Mon Sep 17 00:00:00 2001 From: chenyuan Date: Thu, 6 Aug 2026 17:55:40 +0800 Subject: [PATCH] fix: show comprehensive training in top navigation --- src/layout/components/Navbar.vue | 2 +- src/utils/studentTrainingNavigation.js | 12 ------------ tests/student-top-navigation.static.test.cjs | 16 ++++++++++++++++ tests/student-training-navigation-esm.test.mjs | 7 +------ 4 files changed, 18 insertions(+), 19 deletions(-) create mode 100644 tests/student-top-navigation.static.test.cjs diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index d613f4c..c799bfe 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -280,7 +280,7 @@ const roleList = computed(() => { const homeIndex = items.findIndex((item) => item.path === "/index"); return [ ...items.slice(0, homeIndex + 1), - studentTopTask.value, + { ...studentTopTask.value, name: studentTopTask.value.title }, ...items.slice(homeIndex + 1), ]; }); diff --git a/src/utils/studentTrainingNavigation.js b/src/utils/studentTrainingNavigation.js index 532f2a2..48c9b3f 100644 --- a/src/utils/studentTrainingNavigation.js +++ b/src/utils/studentTrainingNavigation.js @@ -47,18 +47,6 @@ export function buildStudentTaskSections(tasks = []) { path: taskPath(task.taskKey), }); }); - const comprehensiveTask = tasks.find((task) => task?.taskKey === COMPREHENSIVE_TASK_KEY); - if (comprehensiveTask) { - sections.set("综合实训", { - title: "综合实训", - children: [ - { - title: comprehensiveTask.taskName || "综合案例实训", - path: "/comprehensive/index", - }, - ], - }); - } return [...sections.values()]; } diff --git a/tests/student-top-navigation.static.test.cjs b/tests/student-top-navigation.static.test.cjs new file mode 100644 index 0000000..788a298 --- /dev/null +++ b/tests/student-top-navigation.static.test.cjs @@ -0,0 +1,16 @@ +const assert = require("assert"); +const fs = require("fs"); +const path = require("path"); + +const navbar = fs.readFileSync( + path.join(__dirname, "..", "src", "layout", "components", "Navbar.vue"), + "utf8" +); + +assert.match( + navbar, + /name:\s*studentTopTask\.value\.title/, + "student comprehensive navigation item must provide the name rendered by the top navigation" +); + +console.log("student top navigation static test passed"); diff --git a/tests/student-training-navigation-esm.test.mjs b/tests/student-training-navigation-esm.test.mjs index 0a47c27..4065ead 100644 --- a/tests/student-training-navigation-esm.test.mjs +++ b/tests/student-training-navigation-esm.test.mjs @@ -24,12 +24,7 @@ assert.deepEqual(buildStudentTaskSections([ projectName: "综合实训", sort: 99, }, -]), [ - { - title: "综合实训", - children: [{ title: "综合案例实训", path: "/comprehensive/index" }], - }, -]); +]), []); assert.deepEqual(getComprehensiveTopTask([{ taskKey: "comprehensive-case-training", taskName: "综合实训" }]), { title: "综合实训",