fix monaco-editor.

This commit is contained in:
2023-04-03 20:03:53 +08:00
parent 8478c15e55
commit 597a5ee267
3 changed files with 15 additions and 13 deletions

View File

@@ -1,16 +1,18 @@
import loader, { Monaco } from "@monaco-editor/loader"
import { isLowVersion, protocol } from "~/utils/functions"
import * as monaco0301 from "monaco-editor"
import { isLowVersion } from "~/utils/functions"
export const monaco = ref<Monaco>()
export async function init() {
const version = isLowVersion ? "0.30.1" : "0.36.1"
loader.config({
paths: {
vs: `${protocol}://cdn.staticfile.org/monaco-editor/${version}/min/vs`,
},
"vs/nls": { availableLanguages: { "*": "zh-cn" } },
})
if (isLowVersion) {
loader.config({ monaco: monaco0301 })
} else {
loader.config({
paths: { vs: "https://cdn.staticfile.org/monaco-editor/0.36.1/min/vs" },
"vs/nls": { availableLanguages: { "*": "zh-cn" } },
})
}
const [m, light, dark] = await Promise.all([
loader.init(),