mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
添加上传fps文件的支持
This commit is contained in:
1 parent
327fec1fea
commit
7fc721676e
3 files changed
+14
-5
No files matched your search
@@ -85,16 +85,16 @@ class FpsProblemImportHandler extends Handler {
|
||||
testdata.addFile(`${i + 1}.in`, Buffer.from(p.test_input[i]));
|
||||
testdata.addFile(`${i + 1}.out`, Buffer.from(p.test_output[i]));
|
||||
}
|
||||
const file = path.resolve(os.tmpdir(), 'hydro', `${Math.random()}.zip`);
|
||||
const f = path.resolve(os.tmpdir(), 'hydro', `${Math.random()}.zip`);
|
||||
await new Promise((resolve, reject) => {
|
||||
testdata.writeZip(file, (err) => {
|
||||
testdata.writeZip(f, (err) => {
|
||||
if (err) reject(err);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
await problem.setTestdata(domainId, pid, file);
|
||||
await problem.setTestdata(domainId, pid, f);
|
||||
await problem.edit(domainId, pid, { html: true });
|
||||
await fs.unlink(file);
|
||||
await fs.unlink(f);
|
||||
}
|
||||
this.response.body = { count: result.fps.item.length };
|
||||
this.response.redirect = this.url('problem_main');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/fps-importer",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"description": "Import FPS problems",
|
||||
"main": "package.json",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
|
||||
@@ -21,6 +21,15 @@
|
||||
</button>
|
||||
</div></div>
|
||||
</form>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="csrfToken" value="{{ handler.csrfToken }}">
|
||||
<p>{{ _('Upload file') }}:
|
||||
<input type="text" name="title" value="FPS_IMPORT">
|
||||
<input type="text" name="redirect" value="{{ url('problem_import_fps') }}">
|
||||
<input type="file" name="file">
|
||||
<input type="submit" value="{{ _('Upload') }}" class="rounded primary button">
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user