diff --git a/packages/ui-default/components/zipDownloader/index.js b/packages/ui-default/components/zipDownloader/index.js index e6b4de908..9daec9245 100644 --- a/packages/ui-default/components/zipDownloader/index.js +++ b/packages/ui-default/components/zipDownloader/index.js @@ -100,10 +100,21 @@ export async function downloadProblemSet(pids, name = 'Export') { nAccept: pdoc.nAccept, }), }); - targets.push({ - filename: `${pid}/problem.md`, - content: pdoc.content, - }); + try { + const c = JSON.parse(pdoc.content); + if (c instanceof Array || typeof c === 'string') throw new Error(); + for (const key of Object.keys(c)) { + targets.push({ + filename: `${pid}/problem_${key}.md`, + content: typeof c[key] === 'string' ? c[key] : JSON.stringify(c[key]), + }); + } + } catch (e) { + targets.push({ + filename: `${pid}/problem.md`, + content: pdoc.content, + }); + } let { links } = await request.post( `/d/${UiContext.domainId}/p/${pid}/files`, { operation: 'get_links', files: (pdoc.data || []).map((i) => i.name), type: 'testdata' }, diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index 4bfe9f1fa..6b308da19 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/ui-default", - "version": "4.32.13", + "version": "4.32.14", "author": "undefined ", "license": "AGPL-3.0", "main": "hydro.js",