mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core&ui: enhanced language selection (#390)
This commit is contained in:
1 parent
d9972d6e97
commit
1c3ea21283
4 files changed
+26
-21
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.14.14",
|
||||
"version": "3.14.15",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -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([
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.38.15",
|
||||
"version": "4.38.16",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
@@ -56,19 +56,21 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', '
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="medium-5 columns form__item end">
|
||||
<label>
|
||||
{i18n('Code language')}
|
||||
<div className="select-container">
|
||||
<select value={main} onChange={(ev) => setMain(ev.target.value)} className="select">
|
||||
{Object.keys(mainLangs).map((key) => (
|
||||
<option key={key} value={key}>{mainLangs[key]}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
{Object.keys(options).length > 1 && (
|
||||
{Object.keys(mainLangs).length > 1 && (
|
||||
<div className="medium-5 columns form__item end">
|
||||
<label>
|
||||
{i18n('Code language')}
|
||||
<div className="select-container">
|
||||
<select value={main} onChange={(ev) => setMain(ev.target.value)} className="select">
|
||||
{Object.keys(mainLangs).map((key) => (
|
||||
<option key={key} value={key}>{mainLangs[key]}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
)}
|
||||
{(Object.keys(options).length > 1 || Object.keys(mainLangs).length === 1) && (
|
||||
<div className="medium-5 columns form__item end">
|
||||
<label>
|
||||
{i18n('Code language')}
|
||||
|
||||
Reference in new issue
Block a user