mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +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",
|
"name": "hydrooj",
|
||||||
"version": "3.14.14",
|
"version": "3.14.15",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -324,16 +324,19 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
|
|||||||
this.pdoc.config = pdoc.config;
|
this.pdoc.config = pdoc.config;
|
||||||
}
|
}
|
||||||
if (typeof this.pdoc.config !== 'string') {
|
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 = [];
|
const t = [];
|
||||||
if (this.pdoc.config.langs) t.push(this.pdoc.config.langs);
|
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 (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.domain.langs) t.push(this.domain.langs.split(',').map((i) => i.trim()).filter((i) => i));
|
||||||
if (this.pdoc.config.type === 'remote_judge') {
|
if (t.length) this.pdoc.config.langs = intersection(baseLangs, ...t);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
await bus.serial('problem/get', this.pdoc, this);
|
await bus.serial('problem/get', this.pdoc, this);
|
||||||
[this.psdoc, this.udoc] = await Promise.all([
|
[this.psdoc, this.udoc] = await Promise.all([
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.38.15",
|
"version": "4.38.16",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
@@ -56,19 +56,21 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', '
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="medium-5 columns form__item end">
|
{Object.keys(mainLangs).length > 1 && (
|
||||||
<label>
|
<div className="medium-5 columns form__item end">
|
||||||
{i18n('Code language')}
|
<label>
|
||||||
<div className="select-container">
|
{i18n('Code language')}
|
||||||
<select value={main} onChange={(ev) => setMain(ev.target.value)} className="select">
|
<div className="select-container">
|
||||||
{Object.keys(mainLangs).map((key) => (
|
<select value={main} onChange={(ev) => setMain(ev.target.value)} className="select">
|
||||||
<option key={key} value={key}>{mainLangs[key]}</option>
|
{Object.keys(mainLangs).map((key) => (
|
||||||
))}
|
<option key={key} value={key}>{mainLangs[key]}</option>
|
||||||
</select>
|
))}
|
||||||
</div>
|
</select>
|
||||||
</label>
|
</div>
|
||||||
</div>
|
</label>
|
||||||
{Object.keys(options).length > 1 && (
|
</div>
|
||||||
|
)}
|
||||||
|
{(Object.keys(options).length > 1 || Object.keys(mainLangs).length === 1) && (
|
||||||
<div className="medium-5 columns form__item end">
|
<div className="medium-5 columns form__item end">
|
||||||
<label>
|
<label>
|
||||||
{i18n('Code language')}
|
{i18n('Code language')}
|
||||||
|
|||||||
Reference in new issue
Block a user