From 67fcd119071deba7502da7afe07eb7eba5cb5784 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Tue, 20 Oct 2026 16:56:44 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E9=A2=98=E7=9B=AE):=20=E5=8F=82=E8=80=83?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=9B=BE=E4=B8=8D=E7=94=A8=E5=86=8D=E7=82=B9?= =?UTF-8?q?=E5=BC=80=EF=BC=8C=E6=91=8A=E5=9C=A8=E4=BE=8B=E5=AD=90=E5=90=8E?= =?UTF-8?q?=E9=9D=A2=EF=BC=8C=E7=94=BB=E6=B3=95=E5=92=8C=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E8=87=AA=E5=B7=B1=E7=94=BB=E7=9A=84=E5=9B=BE=E4=B8=80=E6=A0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原来折成一条「老师给的参考流程图」要点开,用 Mermaid 画、整张缩进左栏后字只剩十来像素。 现在默认摊开、放在例子后面(长图不把例子挤出第一屏),用画流程图那套排版和符号画 (FlowchartView,颜色形状和画布共用 paint.ts);只有手写 Mermaid 的老图照旧走 Mermaid。 出题页预览和说明文字一起改。 Co-Authored-By: Claude Opus 5.5 --- .../admin/problem/components/CodePreview.vue | 50 +++--- apps/web/src/admin/problem/detail.vue | 3 +- .../oj/problem/components/ProblemContent.vue | 117 ++++--------- .../FlowchartEditor/FlowchartView.vue | 163 ++++++++++++++++++ .../components/FlowchartEditor/index.vue | 39 +---- .../components/FlowchartEditor/paint.ts | 48 ++++++ 6 files changed, 278 insertions(+), 142 deletions(-) create mode 100644 apps/web/src/shared/components/FlowchartEditor/FlowchartView.vue create mode 100644 apps/web/src/shared/components/FlowchartEditor/paint.ts diff --git a/apps/web/src/admin/problem/components/CodePreview.vue b/apps/web/src/admin/problem/components/CodePreview.vue index fdd5ca3..19489f4 100644 --- a/apps/web/src/admin/problem/components/CodePreview.vue +++ b/apps/web/src/admin/problem/components/CodePreview.vue @@ -5,11 +5,15 @@ import { useMermaid } from "shared/composables/useMermaid" import { DIFFICULTY, SOURCES } from "utils/constants" import { getTagColor } from "utils/functions" import type { AstRules, BlankProblem, LANGUAGE } from "utils/types" +import type { FlowDoc } from "shared/components/FlowchartEditor/model" import type { AstCheckState, FlowchartMode, PreviewTab } from "./editorTypes" import type { TemplateParts } from "./codeTemplate" import { isBlankHtml } from "./problemForm" const CodeEditor = defineAsyncComponent(() => import("shared/components/CodeEditor.vue")) +const FlowchartView = defineAsyncComponent( + () => import("shared/components/FlowchartEditor/FlowchartView.vue"), +) /** * 编程题出题页的右栏:学生打开这道题看到的样子(设计稿「编程题出题页」B)。 @@ -35,6 +39,8 @@ const props = defineProps<{ astChecks: AstCheckState flowchartMode: FlowchartMode mermaidCode: string + /** 画布画的参考图;有就照学生题面那样画(FlowchartView),老题手写的 Mermaid 才走 mermaidCode */ + flowchartDoc: FlowDoc | null }>() const tab = defineModel("tab", { required: true }) @@ -84,6 +90,8 @@ const editorCode = computed(() => { // ---------------------------------------------------------------- 流程图 +const referenceDoc = computed(() => (props.flowchartDoc?.steps.length ? props.flowchartDoc : null)) + const container = useTemplateRef("chart") const { renderFlowchart, renderError, renderSuccess } = useMermaid() @@ -164,11 +172,6 @@ onMounted(() => nextTick(render)) - -

例子

@@ -188,6 +191,15 @@ onMounted(() => nextTick(render)) {{ bigData ? "在左边加一个例子" : "在左边的测试数据里勾几组「当例子」" }}

+ + @@ -361,19 +377,11 @@ onMounted(() => nextTick(render)) color: v-bind("theme.textColor3"); } -.fold { - display: flex; - align-items: center; - gap: 8px; - height: 38px; - padding: 0 12px; - border: 1px solid v-bind("theme.borderColor"); +/* 参考流程图:和学生题面(ProblemContent.vue)同一种浅灰底 */ +.reference { border-radius: 6px; - background: transparent; - font: inherit; - color: inherit; - text-align: left; - cursor: pointer; + background-color: rgba(128, 128, 128, 0.05); + padding: 16px 12px; } .exampleHead { diff --git a/apps/web/src/admin/problem/detail.vue b/apps/web/src/admin/problem/detail.vue index 645a68a..5a8b3c3 100644 --- a/apps/web/src/admin/problem/detail.vue +++ b/apps/web/src/admin/problem/detail.vue @@ -1211,7 +1211,7 @@ onMounted(async () => { 给学生看一张参考流程图 - 题面里多一条「老师给的参考流程图」,默认收着,学生点开才看 + 题面里例子下面摊开一张参考流程图