mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
ui: download problem fix
This commit is contained in:
1 parent
f54cf8a9ba
commit
dbf51849d5
5 files changed
+23
-15
No files matched your search
+2
-2
@@ -19,9 +19,9 @@
|
||||
"jest": "node build/jest",
|
||||
"typedoc": "cross-env NODE_OPTIONS=--max_old_space_size=8192 typedoc",
|
||||
"debug:all": "node --async-stack-traces --trace-deprecation --enable-source-maps build/start --debug --template",
|
||||
"debug": "node --async-stack-traces --trace-deprecation --enable-source-maps node_modules/.bin/hydrooj --debug --template",
|
||||
"debug": "node --async-stack-traces --trace-deprecation --enable-source-maps node_modules/hydrooj/bin/hydrooj --debug --template",
|
||||
"start:all": "node build/start",
|
||||
"start": "node node_modules/.bin/hydrooj",
|
||||
"start": "node_modules/.bin/hydrooj",
|
||||
"clean": "zsh -c \"rm -rf tsconfig.build.tsbuildinfo ./packages/*/tsconfig.tsbuildinfo ./packages/*/dist ./.coverage\""
|
||||
},
|
||||
"version": "1.0.0",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { dump } from 'js-yaml';
|
||||
import * as streamsaver from 'streamsaver';
|
||||
import { createZipStream } from 'vj/utils/zip';
|
||||
import pipeStream from 'vj/utils/pipeStream';
|
||||
import i18n from 'vj/utils/i18n';
|
||||
@@ -13,14 +14,13 @@ function onBeforeUnload(e) {
|
||||
}
|
||||
e.returnValue = '';
|
||||
}
|
||||
if (window.location.protocol === 'https:'
|
||||
|| window.location.protocol === 'chrome-extension:'
|
||||
|| window.location.hostname === 'localhost') {
|
||||
streamsaver.mitm = '/streamsaver/mitm.html';
|
||||
}
|
||||
|
||||
export default async function download(name, targets) {
|
||||
const streamsaver = await import('streamsaver');
|
||||
if (window.location.protocol === 'https:'
|
||||
|| window.location.protocol === 'chrome-extension:'
|
||||
|| window.location.hostname === 'localhost') {
|
||||
streamsaver.mitm = '/streamsaver/mitm.html';
|
||||
}
|
||||
if (!window.WritableStream) {
|
||||
window.WritableStream = (await import('web-streams-polyfill/dist/ponyfill.es6')).WritableStream;
|
||||
streamsaver.WritableStream = window.WritableStream;
|
||||
@@ -66,19 +66,19 @@ export async function downloadProblemSet(pids) {
|
||||
const targets = [];
|
||||
for (const pid of pids) {
|
||||
const { pdoc } = await request.get(`/d/${UiContext.domainId}/p/${pid}`);
|
||||
targets.push({ filename: `/d/${UiContext.domainId}/p/${pid}/problem.yaml`, content: dump(pdoc) });
|
||||
targets.push({ filename: `${pid}/problem.yaml`, content: dump(pdoc) });
|
||||
let { links } = await request.post(
|
||||
`/d/${UiContext.domainId}/p/${pid}/files`,
|
||||
{ operation: 'get_links', files: pdoc.data.map((i) => i.name), type: 'testdata' }
|
||||
);
|
||||
for (const filename of Object.keys(links)) {
|
||||
targets.push({ filename: `/d/${UiContext.domainId}/p/${pid}/testdata/${filename}`, url: links[filename] });
|
||||
targets.push({ filename: `${pid}/testdata/${filename}`, url: links[filename] });
|
||||
}
|
||||
({ links } = await request.post(`/d/${UiContext.domainId}/p/${pid}/files`, {
|
||||
operation: 'get_links', files: pdoc.additional_file.map((i) => i.name), type: 'additional_file',
|
||||
}));
|
||||
for (const filename of Object.keys(links)) {
|
||||
targets.push({ filename: `/d/${UiContext.domainId}/p/${pid}/additional_file/${filename}`, url: links[filename] });
|
||||
targets.push({ filename: `${pid}/additional_file/${filename}`, url: links[filename] });
|
||||
}
|
||||
}
|
||||
await download('Export.zip', targets);
|
||||
|
||||
@@ -254,16 +254,18 @@ small, figcaption
|
||||
&:not(.user-profile-name)
|
||||
color: $primary-color
|
||||
|
||||
.typo p, .typo dl, .typo form, .typo hr, .typo table
|
||||
.typo dl, .typo form, .typo hr, .typo table
|
||||
padding-top: 0.3em
|
||||
padding-bottom: 0.3em
|
||||
|
||||
.typo li, .typo ol
|
||||
padding-top: 0.2em
|
||||
padding-bottom: 0.2em
|
||||
padding-top: 0.1em
|
||||
padding-bottom: 0.1em
|
||||
line-height: 1.25
|
||||
|
||||
.typo p
|
||||
padding-top: 0.17em
|
||||
padding-bottom: 0.17em
|
||||
line-height: 1.5
|
||||
font-size: inherit
|
||||
|
||||
|
||||
@@ -226,6 +226,12 @@ const page = new NamedPage(['problem_main', 'problem_category'], () => {
|
||||
ev.preventDefault();
|
||||
updateSelection();
|
||||
});
|
||||
$(document).on('click', 'a.pager__item', (ev) => {
|
||||
ev.preventDefault();
|
||||
pjax.request({ url: $(ev.currentTarget).attr('href') }).then(() => {
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export default page;
|
||||
@@ -37,7 +37,7 @@
|
||||
{{ _('Unhide Selected') }}
|
||||
</a>
|
||||
<a href="javascript:;" class="menu__link display-mode-hide" name="download_selected_problems">
|
||||
<span class="icon icon-delete"></span>
|
||||
<span class="icon icon-download"></span>
|
||||
{{ _('Download Selected') }}
|
||||
</a>
|
||||
<a href="javascript:;" class="menu__link display-mode-hide" name="remove_selected_problems">
|
||||
|
||||
Reference in new issue
Block a user