From fbe98c455b7ef91f043157dc7de8133db36895bc Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Sat, 4 Jul 2026 23:45:54 -0600 Subject: [PATCH] feat: add sql to LANGUAGE type, Judge0 mapping, and code cache --- src/composables/code.ts | 3 ++- src/templates.ts | 4 ++++ src/types.ts | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/composables/code.ts b/src/composables/code.ts index f5d31f2..eed49a4 100644 --- a/src/composables/code.ts +++ b/src/composables/code.ts @@ -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] diff --git a/src/templates.ts b/src/templates.ts index a1ac002..ab981b4 100644 --- a/src/templates.ts +++ b/src/templates.ts @@ -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, } diff --git a/src/types.ts b/src/types.ts index 8e49633..fd5cb59 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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