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:
1 parent
3fe3caa944
commit
11368813cc
16 files changed
+747
-388
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import { defineStore } from "pinia"
|
||||
import { useBreakpoints } from "shared/composables/breakpoints"
|
||||
import type { LANGUAGE, ProblemDetail } from "utils/types"
|
||||
import { problemEntryOf } from "oj/problem/composables/problemPageContext"
|
||||
|
||||
export const useProblemStore = defineStore("problem", () => {
|
||||
const problem = ref<ProblemDetail | null>(null)
|
||||
@@ -25,20 +27,46 @@ export const useProblemStore = defineStore("problem", () => {
|
||||
*/
|
||||
const failCount = computed(() => (problem.value?.myFailedCount ?? 0) + sessionFailCount.value)
|
||||
|
||||
const { isDesktop } = useBreakpoints()
|
||||
|
||||
/**
|
||||
* 这道题能不能画流程图。比赛里不给(入口差异表);题单里原来也不给,现在给了,画到 A/S
|
||||
* 算完成(设计文档第 3 节决定 4)。手机上不给:节点库是 HTML5 拖放,手机上拖不动。
|
||||
*/
|
||||
const canDraw = computed(
|
||||
() => !!problem.value?.allowFlowchart && problemEntryOf(route) !== "contest" && isDesktop.value,
|
||||
)
|
||||
|
||||
/**
|
||||
* 编辑器能切到的全部「语言」。流程图在内部仍是一门叫 Flowchart 的语言(提交、草稿、编辑器
|
||||
* 切换都按它分支),但界面上不再混在语言下拉里 —— 那是工具栏最左边的「写代码 / 画流程图」。
|
||||
*/
|
||||
const languages = computed<LANGUAGE[]>(() => {
|
||||
if (route.name === "problem" && problem.value?.allowFlowchart) {
|
||||
return ["Flowchart", ...problem.value.languages]
|
||||
}
|
||||
return problem.value?.languages ?? []
|
||||
const own = problem.value?.languages ?? []
|
||||
return canDraw.value ? ["Flowchart", ...own] : own
|
||||
})
|
||||
|
||||
/** 语言下拉里的:真正的编程语言 */
|
||||
const codeLanguages = computed(() => languages.value.filter((it) => it !== "Flowchart"))
|
||||
|
||||
/**
|
||||
* 请编辑器换语言,并读回那门语言的草稿(没有就是模板)。只有编辑器(ProblemEditor)知道
|
||||
* 草稿存在哪,所以这里只留一个请求,由它接住 —— 结果页签里的「照着它写代码」不在编辑器里。
|
||||
*/
|
||||
const languageRequest = ref<LANGUAGE | null>(null)
|
||||
function switchLanguage(language: LANGUAGE) {
|
||||
languageRequest.value = language
|
||||
}
|
||||
|
||||
/**
|
||||
* 这道题收不收当前语言,不收就退到它支持的第一种(SQL 题只有 "SQL",硬编码的
|
||||
* Python 会被后端拒绝)。编辑器每次载入代码之前都要过一遍:草稿的键里带着语言,
|
||||
* 先载入再改语言,编辑器里摆的就是另一种语言的模板。
|
||||
*/
|
||||
function supportedLanguage(current: LANGUAGE): LANGUAGE {
|
||||
return languages.value.includes(current) ? current : (languages.value[0] ?? "Python")
|
||||
if (languages.value.includes(current)) return current
|
||||
// 兜底落在编程语言上:languages 的第一项可能是 Flowchart,不能默认把人扔到画布上
|
||||
return codeLanguages.value[0] ?? languages.value[0] ?? "Python"
|
||||
}
|
||||
|
||||
function incrementFailCount() {
|
||||
@@ -55,7 +83,11 @@ export const useProblemStore = defineStore("problem", () => {
|
||||
return {
|
||||
problem,
|
||||
failCount,
|
||||
canDraw,
|
||||
languages,
|
||||
codeLanguages,
|
||||
languageRequest,
|
||||
switchLanguage,
|
||||
supportedLanguage,
|
||||
incrementFailCount,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user