mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: 支持自定义导出文件名
This commit is contained in:
1 parent
cdbbee8180
commit
0273bfe198
13 files changed
+50
-32
No files matched your search
@@ -142,7 +142,7 @@ export interface SubtaskConfig {
|
||||
cases?: TestCaseConfig[],
|
||||
}
|
||||
|
||||
export interface ProblemConfig {
|
||||
export interface ProblemConfigFile {
|
||||
type?: ProblemType;
|
||||
score?: number;
|
||||
time?: string;
|
||||
@@ -159,6 +159,16 @@ export interface ProblemConfig {
|
||||
langs?: string[];
|
||||
}
|
||||
|
||||
export interface ProblemConfig {
|
||||
count: number;
|
||||
memoryMax: number;
|
||||
memoryMin: number;
|
||||
timeMax: number;
|
||||
timeMin: number;
|
||||
langs?: string[];
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface PlainContentNode {
|
||||
type: 'Plain',
|
||||
subType: 'html' | 'markdown',
|
||||
|
||||
@@ -1,24 +1,14 @@
|
||||
import readYamlCases from '@hydrooj/utils/lib/cases';
|
||||
import { load } from 'js-yaml';
|
||||
import type { ProblemConfig } from '../interface';
|
||||
import type { ProblemConfig, ProblemConfigFile } from '../interface';
|
||||
|
||||
interface ParseResult {
|
||||
count: number;
|
||||
memoryMax: number;
|
||||
memoryMin: number;
|
||||
timeMax: number;
|
||||
timeMin: number;
|
||||
langs?: string[];
|
||||
type: string;
|
||||
}
|
||||
|
||||
export async function parseConfig(config: string | ProblemConfig = {}) {
|
||||
let cfg: ProblemConfig = {};
|
||||
export async function parseConfig(config: string | ProblemConfigFile = {}) {
|
||||
let cfg: ProblemConfigFile = {};
|
||||
if (typeof config === 'string') {
|
||||
// TODO should validate here?
|
||||
cfg = await readYamlCases(load(config) as Record<string, any>);
|
||||
} else if (typeof config === 'object') cfg = await readYamlCases(config);
|
||||
const result: ParseResult = {
|
||||
const result: ProblemConfig = {
|
||||
count: 0,
|
||||
memoryMin: Number.MAX_SAFE_INTEGER,
|
||||
memoryMax: 0,
|
||||
|
||||
@@ -204,7 +204,7 @@ export class ProblemModel {
|
||||
for (const pdoc of pdocs) {
|
||||
try {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
pdoc.config = await parseConfig(pdoc.config);
|
||||
pdoc.config = await parseConfig(pdoc.config as string);
|
||||
} catch (e) {
|
||||
pdoc.config = `Cannot parse: ${e.message}`;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import moment from 'moment';
|
||||
import { STATUS } from './builtin';
|
||||
import task from './task';
|
||||
import problem from './problem';
|
||||
import { RecordDoc, ContestInfo, ProblemConfig } from '../interface';
|
||||
import { RecordDoc, ContestInfo, ProblemConfigFile } from '../interface';
|
||||
import { ArgMethod, buildProjection, Time } from '../utils';
|
||||
import { MaybeArray } from '../typeutils';
|
||||
import * as bus from '../service/bus';
|
||||
@@ -51,7 +51,7 @@ class RecordModel {
|
||||
};
|
||||
}
|
||||
|
||||
static async judge(domainId: string, rid: ObjectID, priority = 0, config: ProblemConfig = {}) {
|
||||
static async judge(domainId: string, rid: ObjectID, priority = 0, config: ProblemConfigFile = {}) {
|
||||
const rdoc = await RecordModel.get(domainId, rid);
|
||||
let data = [];
|
||||
if (rdoc.pid) {
|
||||
|
||||
Reference in new issue
Block a user