mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
fps-import: handle images
This commit is contained in:
1 file changed
+9
-1
@@ -19,7 +19,7 @@ class FpsProblemImportHandler extends Handler {
|
||||
if (!result?.fps) throw new BadRequestError('Selected file is not a valid FPS problemset.');
|
||||
for (const p of result.fps.item) {
|
||||
const markdown = [p.description?.[0], p.input?.[0], p.output?.[0], p.hint?.[0]].some((i) => i?.includes('[md]'));
|
||||
const content = buildContent({
|
||||
let content = buildContent({
|
||||
description: p.description?.[0],
|
||||
input: p.input?.[0],
|
||||
output: p.output?.[0],
|
||||
@@ -62,6 +62,14 @@ class FpsProblemImportHandler extends Handler {
|
||||
addTestdata(p.test_input[2 * i + 1], `${i + 1}`, 'out');
|
||||
}
|
||||
}
|
||||
if (p.img?.length) {
|
||||
for (const img of p.img) {
|
||||
const filename = String.random(8) + img.src[0].split('/').pop().split('.').pop();
|
||||
tasks.push(ProblemModel.addAdditionalFile(domainId, pid, filename, Buffer.from(img.base64[0], 'base64')));
|
||||
content = content.replace(img.src[0], `file://${filename}`);
|
||||
}
|
||||
await ProblemModel.edit(domainId, pid, { content });
|
||||
}
|
||||
await Promise.all(tasks);
|
||||
if (p.solution) {
|
||||
let s = '';
|
||||
|
||||
Reference in new issue
Block a user