数据结构优化

This commit is contained in:
李琦
2026-01-20 08:58:44 +08:00
parent 34fe612aab
commit e7839795fb
10 changed files with 190 additions and 180 deletions

View File

@@ -26,7 +26,7 @@
<div class="flex items-center gap-4">
<CustomSelect
v-model="selectedLanguage"
:options="languageOptions.filter(opt => !opt.disabled)"
:options="languageOptions"
@update:modelValue="handleLanguageChange"
placeholder="选择语言"
style="width: 180px; font-family: monospace; font-size: 0.75rem;"
@@ -449,13 +449,15 @@ const getConsoleTemplate = (jsCode: string) => {
`
}
let runTimer: ReturnType<typeof setTimeout> | null = null
const handleCodeChange = () => {
highlightCode()
// 对于非 Web 语言(如 Python/React),不自动运行,等待用户点击 Run
if (['html', 'css', 'javascript'].includes(selectedLanguage.value)) {
// Debounce auto-run for lightweight languages
clearTimeout(window.runTimer)
window.runTimer = setTimeout(() => runCode(), 1000)
if (runTimer) clearTimeout(runTimer)
runTimer = setTimeout(() => runCode(), 1000)
}
}