From 6faa6b1dabdd587f69dc9973ab7eb56a2eb6a477 Mon Sep 17 00:00:00 2001 From: chenyuan Date: Tue, 4 Aug 2026 15:50:51 +0800 Subject: [PATCH] fix: always show six training modules on student home --- src/views/student/index.vue | 12 +++++------- tests/student-home-new-modules.static.test.cjs | 6 +++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/views/student/index.vue b/src/views/student/index.vue index ec9c353..4c3aea5 100644 --- a/src/views/student/index.vue +++ b/src/views/student/index.vue @@ -29,7 +29,7 @@
- + @@ -69,7 +69,7 @@
-
+
{{ module.moduleName }} @@ -106,9 +106,7 @@ const MODULE_COLORS = ["#6958e7", "#3698ee", "#ffb83e", "#ff6f4a", "#45b982", "# let scoreChart; let progressChart; -const participatingModules = computed(() => - (report.value.modules || []).filter((module) => module && module.participating !== false) -); +const displayModules = computed(() => report.value.modules || []); const totalStudyMinutes = computed(() => Object.values(studyTime.value || {}).reduce((total, value) => total + (Number(value) || 0), 0) @@ -139,7 +137,7 @@ const renderScoreChart = () => { center: ["34%", "50%"], avoidLabelOverlap: true, label: { formatter: "{b}" }, - data: participatingModules.value.map((module, index) => ({ + data: displayModules.value.map((module, index) => ({ name: module.moduleName, value: Number(module.score) || 0, itemStyle: { color: moduleColor(index) } @@ -151,7 +149,7 @@ const renderScoreChart = () => { const renderProgressChart = () => { if (!progressChartRef.value) return; progressChart = progressChart || echarts.init(progressChartRef.value); - const modules = participatingModules.value; + const modules = displayModules.value; progressChart.setOption({ tooltip: { trigger: "axis", axisPointer: { type: "shadow" } }, legend: { top: 0, data: ["已完成", "待完成"] }, diff --git a/tests/student-home-new-modules.static.test.cjs b/tests/student-home-new-modules.static.test.cjs index 553c3c1..2a9cdbf 100644 --- a/tests/student-home-new-modules.static.test.cjs +++ b/tests/student-home-new-modules.static.test.cjs @@ -6,7 +6,11 @@ const root = path.resolve(__dirname, '..'); const page = fs.readFileSync(path.join(root, 'src/views/student/index.vue'), 'utf8'); assert(/getCurrentExperimentReport/.test(page)); -assert(/participatingModules/.test(page)); +assert(/const displayModules = computed\(\(\) => report\.value\.modules \|\| \[\]\);/.test(page)); +assert(/:data="displayModules"/.test(page)); +assert(/v-for="\(module, index\) in displayModules"/.test(page)); +assert((page.match(/displayModules\.value/g) || []).length >= 2); +assert(!/participatingModules/.test(page)); assert(/completedTaskCount/.test(page)); assert(/totalTaskCount/.test(page)); assert(/moduleName/.test(page));