mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: 支持限制题目的提交语言
This commit is contained in:
1 parent
f33d440b68
commit
75429bb43b
10 files changed
+44
-25
No files matched your search
@@ -78,6 +78,11 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool
|
||||
}
|
||||
|
||||
render() {
|
||||
const LANGS = {};
|
||||
for (const key in window.LANGS) {
|
||||
if (UiContext.pdoc.config.langs && !UiContext.pdoc.config.langs.includes(key)) continue;
|
||||
LANGS[key] = window.LANGS[key];
|
||||
}
|
||||
return (
|
||||
<Toolbar>
|
||||
<ToolbarButton
|
||||
@@ -136,7 +141,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool
|
||||
value={this.props.editorLang}
|
||||
onChange={(ev) => this.props.setEditorLanguage(ev.target.value)}
|
||||
>
|
||||
{_.map(window.LANGS, (val, key) => (
|
||||
{_.map(LANGS, (val, key) => (
|
||||
<option value={key} key={key}>{val.display}</option>
|
||||
))}
|
||||
</select>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.8.25",
|
||||
"version": "4.8.26",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
@@ -15,12 +15,13 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit'],
|
||||
$('#codelang-main-select').on('change', function () {
|
||||
const options = {};
|
||||
for (const key in window.LANGS) {
|
||||
if (UiContext.pdocConfig.langs && !UiContext.pdocConfig.langs.includes(key)) continue;
|
||||
if (key.startsWith(`${this.value}.`) && key !== this.value) options[key] = window.LANGS[key].display;
|
||||
}
|
||||
if (Object.keys(options).length > 1) {
|
||||
setOptions($('#codelang-sub-select'), options);
|
||||
$('#codelang-sub-container').show();
|
||||
$('[name="codeLang"]').val($('#codelang-sub-container').val());
|
||||
$('[name="codeLang"]').val($('#codelang-sub-select').val());
|
||||
} else {
|
||||
$('#codelang-sub-container').hide();
|
||||
$('[name="codeLang"]').val(this.value);
|
||||
@@ -31,6 +32,7 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit'],
|
||||
});
|
||||
const main = {};
|
||||
for (const key in window.LANGS) {
|
||||
if (UiContext.pdocConfig.langs && !UiContext.pdocConfig.langs.includes(key)) continue;
|
||||
if (!key.includes('.')) main[key] = window.LANGS[key].display;
|
||||
}
|
||||
setOptions($('#codelang-main-select'), main);
|
||||
@@ -38,7 +40,8 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit'],
|
||||
if (current.includes('.')) {
|
||||
const [m, s] = current.split('.');
|
||||
$('#codelang-main-select').val(m);
|
||||
$('#codelang-sub-select').val(s).show();
|
||||
$('#codelang-sub-select').val(s);
|
||||
$('#codelang-sub-container').show();
|
||||
} else $('#codelang-main-select').val(current);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{% extends "layout/basic.html" %}
|
||||
{% block content %}
|
||||
{{ set(UiContext, 'pdocConfig', pdoc.config) }}
|
||||
<div class="row">
|
||||
<div class="medium-9 columns">
|
||||
{% if not tdoc or rdocs.length %}
|
||||
|
||||
Reference in new issue
Block a user