fix monaco-editor.
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import loader, { Monaco } from "@monaco-editor/loader"
|
||||
import { isLowVersion, protocol } 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: "https://cdn.staticfile.org/monaco-editor/0.36.1/min/vs" },
|
||||
paths: {
|
||||
vs: `${protocol}://cdn.staticfile.org/monaco-editor/${version}/min/vs`,
|
||||
},
|
||||
"vs/nls": { availableLanguages: { "*": "zh-cn" } },
|
||||
})
|
||||
|
||||
|
||||
@@ -152,3 +152,12 @@ export function decode(bytes?: string) {
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
function getChromeVersion() {
|
||||
var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)
|
||||
return raw ? parseInt(raw[2], 10) : 0
|
||||
}
|
||||
|
||||
export const isLowVersion = getChromeVersion() < 80
|
||||
|
||||
export const protocol = isLowVersion ? "http" : "https"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import axios from "axios"
|
||||
import { DEAD_RESULTS } from "./constants"
|
||||
import { decode, encode } from "./functions"
|
||||
import { decode, encode, protocol } from "./functions"
|
||||
import { Code } from "./types"
|
||||
|
||||
const http = axios.create({ baseURL: "https://judge0api.hyyz.izhai.net" })
|
||||
const http = axios.create({ baseURL: `${protocol}://judge0api.hyyz.izhai.net` })
|
||||
|
||||
export async function createTestSubmission(code: Code, input: string) {
|
||||
const encodedCode = encode(code.value)
|
||||
|
||||
Reference in New Issue
Block a user