mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: judge_config: add fast input case (#413)
Co-authored-by: undefined <i@undefined.moe>
This commit is contained in:
1 parent
b3e975cf38
commit
b7cdadc255
6 files changed
+48
-8
No files matched your search
@@ -233,6 +233,7 @@ const AutoComplete = forwardRef(function Impl<T>(props: AutoCompleteProps<T>, re
|
|||||||
setSelectedItems: (items) => {
|
setSelectedItems: (items) => {
|
||||||
setSelected(items);
|
setSelected(items);
|
||||||
setSelectedKeys(items.map((i) => itemKey(i)));
|
setSelectedKeys(items.map((i) => itemKey(i)));
|
||||||
|
if (!multi && inputRef.current) inputRef.current.value = items.map((i) => itemKey(i)).join(',');
|
||||||
},
|
},
|
||||||
getQuery: () => inputRef.current?.value,
|
getQuery: () => inputRef.current?.value,
|
||||||
setQuery: (query) => {
|
setQuery: (query) => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NumericInput, Tag } from '@blueprintjs/core';
|
|||||||
import { parseMemoryMB, parseTimeMS } from '@hydrooj/utils/lib/common';
|
import { parseMemoryMB, parseTimeMS } from '@hydrooj/utils/lib/common';
|
||||||
import type { SubtaskConfig } from 'hydrooj/src/interface';
|
import type { SubtaskConfig } from 'hydrooj/src/interface';
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
import React from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import i18n from 'vj/utils/i18n';
|
import i18n from 'vj/utils/i18n';
|
||||||
import FileSelectAutoComplete from '../autocomplete/components/FileSelectAutoComplete';
|
import FileSelectAutoComplete from '../autocomplete/components/FileSelectAutoComplete';
|
||||||
@@ -29,7 +29,40 @@ export function TestCaseEntry({ index, subindex }) {
|
|||||||
casesKey,
|
casesKey,
|
||||||
value,
|
value,
|
||||||
});
|
});
|
||||||
|
if ((casesKey === 'input' && (value as string).endsWith('.in') && !testcase.output)
|
||||||
|
|| (casesKey === 'output' && (value as string).endsWith('.out') && !testcase.input)) {
|
||||||
|
const filename = (value as string).substring(0, (value as string).lastIndexOf('.'));
|
||||||
|
if (!testcase.output && (Files.map((f) => f.name).includes(`${filename}.out`) || Files.map((f) => f.name).includes(`${filename}.ans`))) {
|
||||||
|
dispatch({
|
||||||
|
type: 'CONFIG_SUBTASK_UPDATE',
|
||||||
|
id: index,
|
||||||
|
key: 'cases-edit',
|
||||||
|
casesId: subindex,
|
||||||
|
casesKey: 'output',
|
||||||
|
value: Files.map((f) => f.name).includes(`${filename}.out`) ? `${filename}.out` : `${filename}.ans`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!testcase.input && Files.map((f) => f.name).includes(`${filename}.in`)) {
|
||||||
|
dispatch({
|
||||||
|
type: 'CONFIG_SUBTASK_UPDATE',
|
||||||
|
id: index,
|
||||||
|
key: 'cases-edit',
|
||||||
|
casesId: subindex,
|
||||||
|
casesKey: 'input',
|
||||||
|
value: `${filename}.in`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
const refs = {
|
||||||
|
input: useRef(),
|
||||||
|
output: useRef(),
|
||||||
|
};
|
||||||
|
for (const type of ['input', 'output']) {
|
||||||
|
useEffect(() => {
|
||||||
|
refs[type].current?.setSelectedItems(testcase[type] ? [testcase[type]] : []);
|
||||||
|
}, [testcase[type]]);
|
||||||
|
}
|
||||||
if (!testcase || Object.keys(testcase).length === 0) {
|
if (!testcase || Object.keys(testcase).length === 0) {
|
||||||
return (
|
return (
|
||||||
<tr><td colSpan={5}>{i18n('Failed to parse testcase.')}</td></tr>
|
<tr><td colSpan={5}>{i18n('Failed to parse testcase.')}</td></tr>
|
||||||
@@ -60,6 +93,7 @@ export function TestCaseEntry({ index, subindex }) {
|
|||||||
{['input', 'output'].map((t) => (
|
{['input', 'output'].map((t) => (
|
||||||
<td key={t}>
|
<td key={t}>
|
||||||
<FileSelectAutoComplete
|
<FileSelectAutoComplete
|
||||||
|
ref={refs[t]}
|
||||||
width="100%"
|
width="100%"
|
||||||
data={Files}
|
data={Files}
|
||||||
selectedKeys={[testcase[t]]}
|
selectedKeys={[testcase[t]]}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export default function reducer(state = { type: 'default', __loaded: false } as
|
|||||||
if (action.key.split('-')[0] === 'cases') {
|
if (action.key.split('-')[0] === 'cases') {
|
||||||
if (action.key === 'cases-add') subsubtasks.cases.push(action.value);
|
if (action.key === 'cases-add') subsubtasks.cases.push(action.value);
|
||||||
else if (action.key === 'cases-edit') {
|
else if (action.key === 'cases-edit') {
|
||||||
if (action.value === '') delete subsubtasks.cases[action.casesId][action.casesKey];
|
if (action.value === '' && !['input', 'output'].includes(action.casesKey)) delete subsubtasks.cases[action.casesId][action.casesKey];
|
||||||
else subsubtasks.cases[action.casesId][action.casesKey] = action.value;
|
else subsubtasks.cases[action.casesId][action.casesKey] = action.value;
|
||||||
} else if (action.key === 'cases-delete') {
|
} else if (action.key === 'cases-delete') {
|
||||||
subsubtasks.cases = subsubtasks.cases.filter((k, v) => v !== action.value);
|
subsubtasks.cases = subsubtasks.cases.filter((k, v) => v !== action.value);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/vjudge",
|
"name": "@hydrooj/vjudge",
|
||||||
"version": "1.5.0-next.6",
|
"version": "1.5.0-next.7",
|
||||||
"description": "Submit problems to remote oj",
|
"description": "Submit problems to remote oj",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export interface IBasicProvider {
|
|||||||
}>;
|
}>;
|
||||||
entryProblemLists?: string[];
|
entryProblemLists?: string[];
|
||||||
listProblem(page: number, resync: boolean, listId: string): Promise<string[]>;
|
listProblem(page: number, resync: boolean, listId: string): Promise<string[]>;
|
||||||
submitProblem(id: string, lang: string, code: string, info: any, next: any, end: any): Promise<string>;
|
submitProblem(id: string, lang: string, code: string, info: any, next: any, end: any): Promise<string | void>;
|
||||||
waitForSubmission(id: string, next: any, end: any): Promise<void>;
|
waitForSubmission(id: string, next: any, end: any): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,8 +89,6 @@ export default class LuoguProvider implements IBasicProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getProblem(id: string) {
|
async getProblem(id: string) {
|
||||||
logger.info(id);
|
|
||||||
// TODO
|
|
||||||
return {
|
return {
|
||||||
title: id,
|
title: id,
|
||||||
data: {},
|
data: {},
|
||||||
@@ -104,9 +102,16 @@ export default class LuoguProvider implements IBasicProvider {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
async submitProblem(id: string, lang: string, code: string, info) {
|
async submitProblem(id: string, lang: string, code: string, info, next, end) {
|
||||||
let enableO2 = 0;
|
let enableO2 = 0;
|
||||||
const comment = setting.langs[lang]?.comment;
|
const comment = setting.langs[lang]?.comment;
|
||||||
|
if (code.length < 10) {
|
||||||
|
end({ status: STATUS.STATUS_COMPILE_ERROR, message: 'Code too short' });
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!lang.startsWith('luogu.')) {
|
||||||
|
end({ status: STATUS.STATUS_COMPILE_ERROR, message: `Language not supported: ${lang}` });
|
||||||
|
}
|
||||||
if (comment) {
|
if (comment) {
|
||||||
const msg = `Hydro submission #${info.rid}@${new Date().toLocaleString()}`;
|
const msg = `Hydro submission #${info.rid}@${new Date().toLocaleString()}`;
|
||||||
if (typeof comment === 'string') code = `${comment} ${msg}\n${code}`;
|
if (typeof comment === 'string') code = `${comment} ${msg}\n${code}`;
|
||||||
@@ -116,7 +121,7 @@ export default class LuoguProvider implements IBasicProvider {
|
|||||||
enableO2 = 1;
|
enableO2 = 1;
|
||||||
lang = lang.slice(0, -2);
|
lang = lang.slice(0, -2);
|
||||||
}
|
}
|
||||||
lang = lang.includes('luogu.') ? lang.split('luogu.')[1] : '0';
|
lang = lang.split('luogu.')[1];
|
||||||
const result = await this.post(`/fe/api/problem/submit/${id}${this.account.query || ''}`)
|
const result = await this.post(`/fe/api/problem/submit/${id}${this.account.query || ''}`)
|
||||||
.set('referer', `https://www.luogu.com.cn/problem/${id}`)
|
.set('referer', `https://www.luogu.com.cn/problem/${id}`)
|
||||||
.send({
|
.send({
|
||||||
|
|||||||
Reference in new issue
Block a user