fix
Some checks failed
Deploy / build-and-deploy (push) Has been cancelled

This commit is contained in:
2025-10-21 23:03:25 +08:00
parent cfeac2cdaa
commit 64eeffd041

View File

@@ -1,16 +1,31 @@
<script lang="ts" setup>
import type { SelectOption } from "naive-ui"
import { h } from "vue"
import { h, computed, watch } from "vue"
import { code } from "../composables/code"
import { isMobile } from "../composables/breakpoints"
const LANGS = [
const LANGS = computed(() => {
const allLangs = [
["python", "Python"],
["turtle", "海龟绘图"],
["c", "C 语言"],
["cpp", "C++"],
]
]
if (isMobile.value) {
return allLangs.filter(([lang]) => lang !== "turtle")
}
return allLangs
})
const languages: SelectOption[] = LANGS.map((it) => ({
// 如果当前在移动端且语言是海龟绘图,自动切换到 Python
watch(isMobile, (mobile) => {
if (mobile && code.language === "turtle") {
code.language = "python"
}
})
const languages = computed<SelectOption[]>(() =>
LANGS.value.map((it) => ({
value: it[0],
label: () => [
h("img", {
@@ -24,7 +39,8 @@ const languages: SelectOption[] = LANGS.map((it) => ({
}),
it[1],
],
}))
})),
)
</script>
<template>
<n-select