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