feat(流程图): 「写代码 / 画流程图」变成工具栏上的切换,AI 的评分和历次分数挪进结果页签,题单里也能画

- 流程图题的工具栏最左边是「写代码 / 画流程图」。原来流程图藏在语言下拉里,叫一个名叫
  Flowchart 的「语言」;画完一道题之后它还被记成语言偏好,下一道能画的题一打开就是画布
- 「交给 AI 点评」交完切到「结果」页签:评的时候写着「AI 正在看你的图」、画布照样能改;
  评完是分数、评语、改进建议、四项得分,顶上一排历次分数,点哪次看哪次。
  原来是提交按钮旁一个 1000px 的弹框,盖住画布,翻历次评分要一页一页点
- 画到 A / S:给「照着它写代码 →」,题单里 1.5 秒后回题单(和代码通过一样),
  课堂条当场标成做完;只在这一页上刚评完的那次才算,进页面读到以前的 A 不跳
- 「把这一版载回画布」只在画布和那一版不一样时出现;载回、进页面读回草稿后都缩放到装下整张图
- 题单入口能画流程图了(原来只有题库入口能画),题单里的代码草稿、流程图草稿各存一份,
  加入题单之前写的、画的不会一进题单就摆在编辑器里
- 手机上不给「画流程图」(节点库是拖放,手机上拖不动),题面里以前画好的那张照样看得到

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-09-28 18:19:16 +08:00
1 parent 3fe3caa944
commit 11368813cc
16 files changed
+747 -388

No files matched your search

@@ -11,6 +11,7 @@ import type { LANGUAGE } from "utils/types"
import { beginEditTrace, editTraceExtensions } from "oj/problem/utils/editTrace"
import { errorMarkExtensions } from "oj/problem/utils/errorMark"
import EditorToolbar from "./EditorToolbar.vue"
import { useFlowchartStore } from "oj/store/flowchart"
const FlowchartEditor = defineAsyncComponent(
() => import("shared/components/FlowchartEditor/index.vue"),
@@ -84,8 +85,16 @@ const { isDesktop } = useBreakpoints()
const editorExtensions = [...editTraceExtensions, ...errorMarkExtensions]
const contestID = route.params.contestID || null
const storageKey = computed(
() => `problem_${problem.value!._id}_contest_${contestID}_lang_${codeStore.code.language}`,
const problemSetId = route.params.problemSetId || null
/**
* 本地草稿的键。题单入口单独一份:原来题库和题单共用 `problem_题号_contest_null_语言`,
* 加入题单之前在题库里写对的代码,一进题单就摆在编辑器里(设计文档第 11 节 4)。
* 键的最后一段必须是语言,changeLanguage 靠它判断草稿是不是这门语言的。
*/
const storageKey = computed(() =>
problemSetId
? `problem_${problem.value!._id}_problemset_${problemSetId}_lang_${codeStore.code.language}`
: `problem_${problem.value!._id}_contest_${contestID}_lang_${codeStore.code.language}`,
)
const editorHeight = computed(() =>
@@ -130,7 +139,28 @@ const changeLanguage = (v: LANGUAGE) => {
)
}
// 提供FlowchartEditor的ref给子组件
/**
* 换语言的请求:工具栏的「写代码 / 画流程图」、结果页签里的「照着它写代码」。
* 和语言下拉走同一条路(存语言偏好 → 读那门语言的草稿)。
*/
watch(
() => problemStore.languageRequest,
(language) => {
if (!language) return
problemStore.languageRequest = null
if (language === codeStore.code.language) return
codeStore.setLanguage(language)
changeLanguage(language)
},
)
// 流程图编辑器交给 store:结果页签(在左栏,不在编辑器底下)要拿当前画布比一比、
// 把旧版本载回去。子组件 SubmitFlowchart 还是从 inject 拿
const flowchartStore = useFlowchartStore()
watch(flowchartEditorRef, (editor) => flowchartStore.attachEditor(editor ?? null), {
immediate: true,
})
onBeforeUnmount(() => flowchartStore.attachEditor(null))
provide("flowchartEditorRef", flowchartEditorRef)
</script>