新增中文补全
Some checks failed
Deploy / build-and-deploy (push) Has been cancelled

This commit is contained in:
2026-01-06 21:41:57 +08:00
parent 6eb7c1e07c
commit d6eb666a83
4 changed files with 1166 additions and 207 deletions

View File

@@ -3,12 +3,14 @@ import { cpp } from "@codemirror/lang-cpp"
import { python } from "@codemirror/lang-python"
import { EditorState } from "@codemirror/state"
import { EditorView } from "@codemirror/view"
import { autocompletion } from "@codemirror/autocomplete"
import { Icon } from "@iconify/vue"
import { useDark } from "@vueuse/core"
import { computed, ref, watch } from "vue"
import { Codemirror } from "vue-codemirror"
import { oneDark } from "../themes/oneDark"
import { smoothy } from "../themes/smoothy"
import { enhanceCompletion } from "../extensions/autocompletion"
import { LANGUAGE } from "../types"
interface Props {
@@ -51,13 +53,18 @@ watch(
},
)
const lang = computed(() => {
const langExtension = computed(() => {
if (props.language === "python" || props.language === "turtle") {
return python()
}
return cpp()
})
const enhanceAutoCompletion = computed(() => {
console.log(props.language)
return autocompletion({ override: [enhanceCompletion(props.language)] })
})
function onChange(v: string) {
emit("update:modelValue", v)
}
@@ -79,7 +86,12 @@ function onReady(payload: {
<Codemirror
v-model="code"
indentWithTab
:extensions="[styleTheme, lang, isDark ? oneDark : smoothy]"
:extensions="[
styleTheme,
langExtension,
enhanceAutoCompletion,
isDark ? oneDark : smoothy,
]"
:disabled="props.readonly"
:tabSize="4"
:placeholder="props.placeholder"