题目页换题是同一个组件复用、只换路由参数,几处只在创建时读一次的状态就停在了上一道题: - 例子:新题下面摆着旧题的例子,「测试」也拿旧例子比对 - 语言:下拉选项不跟着变,也不回退——从 Python 题跳到 SQL 题,语言停在 Python,提交必被拒 - 比赛 / 题单的编辑器只在挂载时载入一次代码 - 流程图:分数按钮、评分弹框、「我的流程图」还是上一道题的,上一道题还没评完的那次会挂到新题上 语言回退挪进 problem store 的 supportedLanguage(),两个编辑器在载入草稿之前调用, 保证先定语言再读这门语言的草稿。没有用给整块加 key 强制重新挂载的办法:课堂协作的 绑定依赖组件复用,重挂载会让协作中切题的老师语言恢复不了。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
71670e609b
commit
1b149a4f3f
7 files changed
+101
-32
No files matched your search
@@ -88,14 +88,25 @@ const hasTriedButNotPassed = computed(() => {
|
||||
)
|
||||
})
|
||||
|
||||
const samples = ref<Sample[]>(
|
||||
problem.value!.samples.map((sample, index) => ({
|
||||
function freshSamples(): Sample[] {
|
||||
return (problem.value?.samples ?? []).map((sample, index) => ({
|
||||
...sample,
|
||||
id: index,
|
||||
msg: "",
|
||||
status: "not_test",
|
||||
loading: false,
|
||||
})),
|
||||
}))
|
||||
}
|
||||
|
||||
const samples = ref<Sample[]>(freshSamples())
|
||||
|
||||
// 题目页换题是同一个组件复用(顶栏题号直达、「下一题」、相似题都是只换路由参数),
|
||||
// 不跟着重建的话,新题下面摆的还是上一道题的例子,「测试」也拿旧例子去比
|
||||
watch(
|
||||
() => problem.value?._id,
|
||||
() => {
|
||||
samples.value = freshSamples()
|
||||
},
|
||||
)
|
||||
|
||||
// 文案和配色分类都由后端生成 —— 原来这里有一份 NODE_TARGET_LABELS +
|
||||
@@ -116,7 +127,10 @@ async function test(sample: Sample, index: number) {
|
||||
}
|
||||
return sample
|
||||
})
|
||||
const problemId = problem.value?._id
|
||||
const res = await createTestSubmission(codeStore.code, sample.input)
|
||||
// 跑的这一会儿换了题:结果是上一道题的例子的,按下标写进去就串到新题上了
|
||||
if (problem.value?._id !== problemId) return
|
||||
samples.value = samples.value.map((sample) => {
|
||||
if (sample.id === index) {
|
||||
const status = res.status === 3 && res.output.trim() === sample.output ? "passed" : "failed"
|
||||
@@ -133,6 +147,7 @@ async function test(sample: Sample, index: number) {
|
||||
|
||||
const id = setTimeout(() => {
|
||||
clearTimeout(id)
|
||||
if (problem.value?._id !== problemId) return
|
||||
samples.value = samples.value.map((sample) => {
|
||||
if (sample.id === index) {
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user