feat: add sql to LANGUAGE type, Judge0 mapping, and code cache
This commit is contained in:
@@ -19,6 +19,7 @@ const cache: Cache = {
|
||||
c: useStorage("code_c", sources["c"]),
|
||||
cpp: useStorage("code_cpp", sources["cpp"]),
|
||||
turtle: useStorage("code_turtle", sources["turtle"]),
|
||||
sql: useStorage("code_sql", sources["sql"]),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -71,7 +72,7 @@ export async function init() {
|
||||
if (base64) {
|
||||
try {
|
||||
const data = JSON.parse(atou(base64))
|
||||
const lang = ["python", "c", "cpp", "turtle"].includes(data.lang)
|
||||
const lang = ["python", "c", "cpp", "turtle", "sql"].includes(data.lang)
|
||||
? (data.lang as LANGUAGE)
|
||||
: defaultLanguage
|
||||
const sharedCode = data.code ?? sources[lang]
|
||||
|
||||
@@ -17,11 +17,14 @@ for i in range(4):
|
||||
|
||||
turtle.done()`
|
||||
|
||||
const sqlSource = "-- 在这里编写你的 SQL 语句\n"
|
||||
|
||||
export const languageToId: { [key in string]: number } = {
|
||||
c: 50,
|
||||
cpp: 54,
|
||||
java: 62,
|
||||
python: 71,
|
||||
sql: 82,
|
||||
}
|
||||
|
||||
export const sources = {
|
||||
@@ -30,4 +33,5 @@ export const sources = {
|
||||
java: javaSource,
|
||||
python: pythonSource,
|
||||
turtle: turtleSource,
|
||||
sql: sqlSource,
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { RemovableRef } from "@vueuse/core"
|
||||
|
||||
export type LANGUAGE = "c" | "python" | "cpp" | "turtle"
|
||||
export type LANGUAGE = "c" | "python" | "cpp" | "turtle" | "sql"
|
||||
|
||||
export interface Code {
|
||||
value: string
|
||||
|
||||
Reference in New Issue
Block a user