From c7afb43d7859dc5fa2ece6bae0aac56cf9d68a97 Mon Sep 17 00:00:00 2001 From: yhf2000 <735961159@qq.com> Date: Fri, 20 Sep 2024 20:23:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=AB=98=E4=BA=AE=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../submission/Processing/Processing.tsx | 4 +- src/Type/ISubmission.ts | 56 +++++++++++++++---- 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/Component/submission/Processing/Processing.tsx b/src/Component/submission/Processing/Processing.tsx index ea24daf..17dc9dc 100644 --- a/src/Component/submission/Processing/Processing.tsx +++ b/src/Component/submission/Processing/Processing.tsx @@ -6,7 +6,7 @@ import {TestCaseProp} from "../TestCase"; import {connect} from "react-redux"; import {withRouter} from "react-router"; import { - langMap, + fileExtList2Lang, RunningResultType, RunningStateType, StateList, @@ -229,7 +229,7 @@ const Processing = (props: IProcessingProp & any) => { content: ( <> {!isValueEmpty(sf?.code) && sf?.judgeTemplateTitle !== undefined && ( - + )} {isValueEmpty(sf?.zipFileId) && isValueEmpty(sf?.code) && ( props.t("codeIsNotPublic") diff --git a/src/Type/ISubmission.ts b/src/Type/ISubmission.ts index de2c0ae..4244b68 100644 --- a/src/Type/ISubmission.ts +++ b/src/Type/ISubmission.ts @@ -1,3 +1,5 @@ +import {JudgeTemplate} from "./IProblem"; + export type TestCaseType = "Pending" | "Running" | "Accepted" | "WrongAnswer" | "TimeLimitExceeded" | "MemoryLimitExceeded" | @@ -51,17 +53,38 @@ export const StateList = "PresentationError", "SystemError", "Queueing", "Compiling", "Judging", "End", "Cancelled"] -export const langMap: any = { - "C++11": "cpp", - "C++14": "cpp", - "C++17": "cpp", - "C++20": "cpp", - "C11": "c", - "Java8": "java", - "Java11": "java", - "Python3.6": "python", - "Python3.11": "python", - "cpp11": "cpp" +// export const langMap: any = { +// "C++11": "cpp", +// "C++14": "cpp", +// "C++17": "cpp", +// "C++20": "cpp", +// "C11": "c", +// "Java8": "java", +// "Java11": "java", +// "Python3.6": "python", +// "Python3.11": "python", +// "cpp11": "cpp" +// } + +export const ext2lang: any = { + "cpp": "cpp", ".cpp": "cpp", + "cc": "cpp", ".cc": "cpp", + "c++": "cpp", ".c++": "cpp", + "c": "c", ".c": "c", + "java": "java", ".java": "java", + "py": "python", ".py": "python", + "py3": "python", ".py3": "python", + "py2": "python", ".py2": "python", +} + +export const fileExtList2Lang: any = (extList: string[]) => { + // 找到第一个合法的语言 + for (let ext of extList) { + if (ext2lang[ext]) { + return ext2lang[ext] + } + } + return "cpp" } export interface checkPointType { @@ -71,6 +94,14 @@ export interface checkPointType { Memory: number } +export interface JudgeTemplateType { + id: string + type: number + title: string + comment: string + acceptFileExtensions: string[] +} + export interface submissionInfoType { timeLimit?: number memoryLimit?: number @@ -88,6 +119,7 @@ export interface submissionInfoType { judgeTemplateId: string judgeTemplateTitle: string judgeTemplateType: number + judgeTemplate: JudgeTemplateType problemCode: string problemId: string problemTitle: string @@ -139,5 +171,5 @@ export interface SubmissionState { TopSubmissionId?: string TopSubmissionInfo?: TopSubmissionInfoType SubmissionModalVis: boolean - submissionListInfo: {[key: string]: any} + submissionListInfo: { [key: string]: any } }