fps: 移除input参数

pull/56/head
undefined 4 years ago
parent 8d8ad69a98
commit 4652ce86ab

@ -1,7 +1,4 @@
# Hydro # Hydro
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhydro-dev%2FHydro.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhydro-dev%2FHydro?ref=badge_shield) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhydro-dev%2FHydro.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhydro-dev%2FHydro?ref=badge_shield)
Hydro是一个高效的信息学在线测评系统。特点易于部署且提供安装脚本轻量功能强大且易于扩展。 Hydro是一个高效的信息学在线测评系统。特点易于部署且提供安装脚本轻量功能强大且易于扩展。

@ -5,9 +5,7 @@ import fs from 'fs-extra';
import { filter } from 'lodash'; import { filter } from 'lodash';
import decodeHTML from 'decode-html'; import decodeHTML from 'decode-html';
import type { ProblemConfig } from 'hydrooj'; import type { ProblemConfig } from 'hydrooj';
import { import { Route, Handler } from 'hydrooj/dist/service/server';
Route, Handler, param, Types,
} from 'hydrooj/dist/service/server';
import { buildContent } from 'hydrooj/dist/lib/content'; import { buildContent } from 'hydrooj/dist/lib/content';
import { ProblemAdd } from 'hydrooj/dist/lib/ui'; import { ProblemAdd } from 'hydrooj/dist/lib/ui';
import * as solution from 'hydrooj/dist/model/solution'; import * as solution from 'hydrooj/dist/model/solution';
@ -61,9 +59,8 @@ class FpsProblemImportHandler extends Handler {
} }
} }
@param('input', Types.String, true) async post({ domainId }) {
async post(domainId: string, input: string) { if (!this.request.files.file) throw new ValidationError('file');
if (!input && !this.request.files.file) throw new ValidationError('file');
const tasks = []; const tasks = [];
if (this.request.files.file) { if (this.request.files.file) {
try { try {
@ -80,13 +77,9 @@ class FpsProblemImportHandler extends Handler {
} catch { } // eslint-disable-line no-empty } catch { } // eslint-disable-line no-empty
} }
} }
} else {
tasks.push(await xml2js.parseStringPromise(input));
} }
if (!tasks.length) throw new ValidationError('file'); if (!tasks.length) throw new ValidationError('file');
for (const task of tasks) { for (const task of tasks) await this.run(domainId, task);
await this.run(domainId, task);
}
this.response.redirect = this.url('problem_main'); this.response.redirect = this.url('problem_main');
} }
} }

@ -1,6 +1,6 @@
{ {
"name": "@hydrooj/fps-importer", "name": "@hydrooj/fps-importer",
"version": "1.1.5", "version": "1.1.6",
"description": "Import FPS problems", "description": "Import FPS problems",
"main": "package.json", "main": "package.json",
"repository": "https://github.com/hydro-dev/Hydro.git", "repository": "https://github.com/hydro-dev/Hydro.git",

Loading…
Cancel
Save