core: 支持在题目中通过 file://name 索引至附加文件

This commit is contained in:
undefined committed 2021-01-08 13:03:35 +08:00
1 parent 99efc98d2d
commit 252a251ce4
7 files changed
+14 -34

No files matched your search

+8 -2
View File
@@ -190,7 +190,13 @@ export class ProblemDetailHandler extends ProblemHandler {
};
}
async get(...args: any[]) { } // eslint-disable-line
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async get(..._args: any[]) {
// Navigate to current additional file download
// e.g. ![img](a.jpg) will navigate to ![img](./pid/file/a.jpg)
this.response.body.pdoc.content = this.response.body.pdoc.content
.replace(/\(file:\/\//g, `(./${this.pdoc.docId}/file/`);
}
@param('pid', Types.UnsignedInt)
async postRejudge(domainId: string, pid: number) {
@@ -207,7 +213,7 @@ export class ProblemDetailHandler extends ProblemHandler {
export class ProblemExportHandler extends ProblemDetailHandler {
async get() {
const hasPerm = (this.user._id === this.pdoc.owner && this.user.hasPerm(PERM.PERM_READ_PROBLEM_DATA_SELF))
|| this.user.hasPerm(PERM.PERM_READ_PROBLEM_DATA_SELF);
|| this.user.hasPerm(PERM.PERM_READ_PROBLEM_DATA);
const pdoc = pick(this.pdoc, ['pid', 'acMsg', 'content', 'config', 'title', 'html', 'tag', 'category']);
const zip = new AdmZip();
if (hasPerm) {