core&ui: enhanced language selection (#390)

This commit is contained in:
undefined committed 2022-07-20 20:28:11 +08:00
1 parent d9972d6e97
commit 1c3ea21283
4 files changed
+26 -21

No files matched your search

+9 -6
View File
@@ -324,16 +324,19 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
this.pdoc.config = pdoc.config;
}
if (typeof this.pdoc.config !== 'string') {
let baseLangs;
if (this.pdoc.config.type === 'remote_judge') {
const p = this.pdoc.config.subType;
const dl = [p, ...Object.keys(setting.langs).filter((i) => i.startsWith(`${p}.`))];
baseLangs = dl;
} else {
baseLangs = Object.keys(setting.langs).filter((i) => !setting.langs[i].remote);
}
const t = [];
if (this.pdoc.config.langs) t.push(this.pdoc.config.langs);
if (ddoc.langs) t.push(ddoc.langs.split(',').map((i) => i.trim()).filter((i) => i));
if (this.domain.langs) t.push(this.domain.langs.split(',').map((i) => i.trim()).filter((i) => i));
if (this.pdoc.config.type === 'remote_judge') {
const p = this.pdoc.config.subType;
const dl = [p, ...Object.keys(setting.langs).filter((i) => i.startsWith(`${p}.`))];
t.push(dl);
}
if (t.length) this.pdoc.config.langs = intersection(...t);
if (t.length) this.pdoc.config.langs = intersection(baseLangs, ...t);
}
await bus.serial('problem/get', this.pdoc, this);
[this.psdoc, this.udoc] = await Promise.all([