use composables.

This commit is contained in:
2023-01-14 20:47:26 +08:00
parent d3caa5438d
commit b568539610
17 changed files with 47 additions and 71 deletions

View File

@@ -2,7 +2,7 @@
import type * as Monaco from "monaco-editor"
import { LANGUAGE_VALUE } from "utils/constants"
import { LANGUAGE } from "utils/types"
import { isMobile } from "utils/breakpoints"
import { isMobile } from "~/shared/composables/breakpoints"
import { isDark } from "../composables/dark"
interface Props {
@@ -30,8 +30,7 @@ let editor: Monaco.editor.IStandaloneCodeEditor
onMounted(function () {
const model = window.monaco.editor.createModel(
props.value,
LANGUAGE_VALUE[props.language],
window.monaco.Uri.parse(`file:///root/${Date.now()}.${ext()}`)
LANGUAGE_VALUE[props.language]
)
editor = window.monaco.editor.create(monacoEditorRef.value, {
@@ -88,25 +87,6 @@ onMounted(function () {
onUnmounted(() => {
editor && editor.dispose()
})
function ext() {
switch (props.language) {
case "C":
return "c"
case "C++":
return "cpp"
case "Java":
return "java"
case "JavaScript":
return "js"
case "Python2":
return "py"
case "Python3":
return "py"
case "Golang":
return "go"
}
}
</script>
<template>
<div