diff --git a/src/components/Login.vue b/src/components/Login.vue index 36aada9..2142d82 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -31,6 +31,7 @@ type="password" v-model:value="studentPassword" name="password" + @keyup.enter="submitStudent" />
- - 出题人:{{ challengeAuthor || "未设置" }} - + + + 出题人:{{ challengeAuthor || "未设置" }} + + + 看示例 + +
([]) const historyRefreshKey = ref(0) +const exampleCode = ref<{ html: string; css: string; js: string } | null>(null) const assetBaseUrl = computed( () => `/media/tasks/challenge/${challengeDisplay.value}/`, @@ -201,6 +211,15 @@ async function loadChallenge() { ]) taskId.value = data.task_ptr challengeAuthor.value = data.author_name ?? "" + if (data.example_html || data.example_css || data.example_js) { + exampleCode.value = { + html: data.example_html ?? "", + css: data.example_css ?? "", + js: data.example_js ?? "", + } + } else { + exampleCode.value = null + } challengeContent.value = await marked.parse(data.content, { async: true, renderer: challengeRenderer, @@ -234,6 +253,13 @@ function edit() { }) } +function previewExample() { + if (!exampleCode.value) return + html.value = exampleCode.value.html + css.value = exampleCode.value.css + js.value = exampleCode.value.js +} + function clearAll() { html.value = "" css.value = "" diff --git a/src/pages/ChallengeEditor.vue b/src/pages/ChallengeEditor.vue index 084173a..ed13eaa 100644 --- a/src/pages/ChallengeEditor.vue +++ b/src/pages/ChallengeEditor.vue @@ -76,11 +76,20 @@ - + + + + 示例代码 + + + + + + + HTML · {{ splitResult.html.length }} 字符 + CSS · {{ splitResult.css.length }} 字符 + JS · {{ splitResult.js.length }} 字符 + +