题目页换题是同一个组件复用、只换路由参数,几处只在创建时读一次的状态就停在了上一道题: - 例子:新题下面摆着旧题的例子,「测试」也拿旧例子比对 - 语言:下拉选项不跟着变,也不回退——从 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
@@ -185,17 +185,20 @@ const handleMenuSelect = (key: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
const languageOptions: DropdownOption[] = languages.value.map((it) => ({
|
||||
label: () =>
|
||||
h(NFlex, { align: "center" }, () => [
|
||||
h(Icon, {
|
||||
icon: ICON_SET[it],
|
||||
width: 16,
|
||||
}),
|
||||
LANGUAGE_SHOW_VALUE[it],
|
||||
]),
|
||||
value: it,
|
||||
}))
|
||||
// computed:换题时组件复用,选项得跟着新题的语言走
|
||||
const languageOptions = computed<DropdownOption[]>(() =>
|
||||
languages.value.map((it) => ({
|
||||
label: () =>
|
||||
h(NFlex, { align: "center" }, () => [
|
||||
h(Icon, {
|
||||
icon: ICON_SET[it],
|
||||
width: 16,
|
||||
}),
|
||||
LANGUAGE_SHOW_VALUE[it],
|
||||
]),
|
||||
value: it,
|
||||
})),
|
||||
)
|
||||
|
||||
const copy = async () => {
|
||||
const success = await copyToClipboard(codeStore.code.value)
|
||||
@@ -247,12 +250,7 @@ const goEdit = () => {
|
||||
window.open(router.resolve(url).href, "_blank")
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (!languages.value.includes(codeStore.code.language)) {
|
||||
// 回退到题目支持的第一种语言(如 SQL 题只有 "SQL",硬编码 Python 会被后端拒绝)
|
||||
codeStore.code.language = languages.value[0] ?? "Python"
|
||||
}
|
||||
})
|
||||
// 语言回退不在这里做:它得排在载入草稿之前,见 problem store 的 supportedLanguage
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in new issue
Block a user