diff --git a/src/oj/problem/components/ProblemContent.vue b/src/oj/problem/components/ProblemContent.vue index f9e1f29..10c4af0 100644 --- a/src/oj/problem/components/ProblemContent.vue +++ b/src/oj/problem/components/ProblemContent.vue @@ -12,6 +12,7 @@ import { useDark } from "@vueuse/core" import { MdPreview } from "md-editor-v3" import "md-editor-v3/lib/preview.css" import { getSimilarProblems } from "oj/api" +import SQLDataTable from "./SQLDataTable.vue" type Sample = Problem["samples"][number] & { id: number @@ -30,6 +31,18 @@ const { problem } = storeToRefs(problemStore) const problemSetId = computed(() => route.params.problemSetId) +// SQL 题:隐藏输入/输出/例子,改为渲染数据表与期望结果 +const isSQL = computed(() => !!problem.value?.sql_config) +const sqlDisplay = computed(() => problem.value?.sql_display ?? null) +const sqlExpectedQuery = computed(() => { + const exp = sqlDisplay.value?.expected + return exp && "columns" in exp ? exp : null +}) +const sqlChangedTables = computed(() => { + const exp = sqlDisplay.value?.expected + return exp && "changed_tables" in exp ? exp.changed_tables : [] +}) + const router = useRouter() // 相似题目推荐 @@ -269,29 +282,79 @@ function type(status: ProblemStatus) { :theme="isDark ? 'dark' : 'light'" /> -

- - - 输入 - -

- + + +

@@ -334,50 +397,52 @@ function type(status: ProblemStatus) {

-
- -

- - - 例子 {{ index + 1 }} - -

- +
+ +

+ + + 例子 {{ index + 1 }} + +

+ + {{ label(sample.status, sample.loading) }} + +
+ - {{ label(sample.status, sample.loading) }} - - - - - -
{{ sample.input }}
-
- - -
{{ sample.output }}
-
- -
{{ sample.msg }}
-
-
-
+ + +
{{ sample.input }}
+
+ + +
{{ sample.output }}
+
+ +
{{ sample.msg }}
+
+ +
+

@@ -470,4 +535,16 @@ function type(status: ProblemStatus) { font-size: 13px; opacity: 0.65; } + +.sqlTableName { + font-weight: 600; + margin: 8px 0 4px; + font-family: "Monaco"; +} + +.sqlNote { + font-size: 13px; + opacity: 0.65; + margin: 0 0 8px; +} diff --git a/src/oj/problem/components/SQLDataTable.vue b/src/oj/problem/components/SQLDataTable.vue new file mode 100644 index 0000000..8330664 --- /dev/null +++ b/src/oj/problem/components/SQLDataTable.vue @@ -0,0 +1,60 @@ + + + + + diff --git a/src/utils/types.ts b/src/utils/types.ts index f1b1e67..b6d8598 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -34,10 +34,7 @@ export interface Profile { } export type UserAdminType = - | "Regular User" - | "Student Admin" - | "Teacher Admin" - | "Super Admin" + "Regular User" | "Student Admin" | "Teacher Admin" | "Super Admin" export interface User { id: number @@ -72,23 +69,37 @@ export interface SQLConfig { order_sensitive: boolean } +export interface SQLDisplayColumn { + name: string + type?: string +} + +export interface SQLDisplayTable { + name: string + columns: SQLDisplayColumn[] + rows: (string | number | null)[][] + total_rows: number + truncated: boolean + dropped?: boolean +} + +export interface SQLDisplay { + tables: SQLDisplayTable[] + expected: + | { + columns: string[] + rows: (string | number | null)[][] + total_rows: number + truncated: boolean + } + | { changed_tables: SQLDisplayTable[] } +} + export type LANGUAGE_SHOW_LABEL = (typeof LANGUAGE_SHOW_VALUE)[keyof typeof LANGUAGE_SHOW_VALUE] export type SUBMISSION_RESULT = - | -2 - | -1 - | 0 - | 1 - | 2 - | 3 - | 4 - | 5 - | 6 - | 7 - | 8 - | 9 - | 10 + -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 export type ProblemStatus = "passed" | "failed" | "not_test" @@ -173,6 +184,9 @@ export interface Problem { // SQL 题配置(非 SQL 题为 null) sql_config?: SQLConfig | null + + // SQL 题展示数据(后端保存题目时自动生成) + sql_display?: SQLDisplay | null } export type AdminProblem = Problem & AlterProblem @@ -664,13 +678,7 @@ export interface ExerciseGroupData { } export type ExerciseType = - | "mcq" - | "sort" - | "fill" - | "match" - | "predict" - | "debug" - | "group" + "mcq" | "sort" | "fill" | "match" | "predict" | "debug" | "group" export interface Exercise { id: number