mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core&ui: use langConfig.hidden for remote problems
This commit is contained in:
1 parent
73b1a04bd0
commit
d60f31c427
10 files changed
+28
-27
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@hydrooj/hydrojudge",
|
||||
"bin": "bin/hydrojudge.js",
|
||||
"version": "2.14.6",
|
||||
"version": "2.14.7",
|
||||
"main": "package.json",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
|
||||
@@ -44,6 +44,7 @@ int main(){
|
||||
time_limit_rate: 1,
|
||||
domain: [],
|
||||
key: '',
|
||||
hidden: false,
|
||||
}),
|
||||
tmpdir: path.resolve(getConfig('tmp_dir'), 'sysinfo'),
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.8.6",
|
||||
"version": "3.8.7",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -4,6 +4,7 @@ import os from 'os';
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import yaml from 'js-yaml';
|
||||
import i18n from '../lib/i18n';
|
||||
import { Logger } from '../logger';
|
||||
import * as bus from '../service/bus';
|
||||
|
||||
@@ -75,7 +76,7 @@ export async function locale(pending: string[], fail: string[]) {
|
||||
const content = fs.readFileSync(path.resolve(p, file)).toString();
|
||||
locales[file.split('.')[0]] = yaml.load(content);
|
||||
}
|
||||
global.Hydro.lib.i18n(locales);
|
||||
i18n(locales);
|
||||
logger.info('Locale init: %s', i);
|
||||
} catch (e) {
|
||||
fail.push(i);
|
||||
|
||||
@@ -311,13 +311,17 @@ export class ProblemDetailHandler extends ProblemHandler {
|
||||
if (!ddoc || !pdoc) throw new ProblemNotFoundError(this.pdoc.reference.domainId, this.pdoc.reference.pid);
|
||||
this.pdoc.config = pdoc.config;
|
||||
}
|
||||
if (ddoc.langs && typeof this.pdoc.config !== 'string') {
|
||||
const dl = ddoc.langs.split(',').map((i) => i.trim()).filter((i) => i);
|
||||
this.pdoc.config.langs = intersection(this.pdoc.config.langs || dl, dl);
|
||||
}
|
||||
if (this.domain.langs && typeof this.pdoc.config !== 'string') {
|
||||
const dl = this.domain.langs.split(',').map((i) => i.trim()).filter((i) => i);
|
||||
this.pdoc.config.langs = intersection(this.pdoc.config.langs || dl, dl);
|
||||
if (typeof this.pdoc.config !== 'string') {
|
||||
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);
|
||||
}
|
||||
await bus.serial('problem/get', this.pdoc, this);
|
||||
[this.psdoc, this.udoc] = await Promise.all([
|
||||
|
||||
@@ -68,11 +68,10 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
|
||||
const LANGS = {};
|
||||
const prefix = new Set(Object.keys(window.LANGS).filter((i) => i.includes('.')).map((i) => i.split('.')[0]));
|
||||
const domainId = UiContext.pdoc.reference?.domainId || UiContext.pdoc.domainId;
|
||||
for (const key in window.LANGS) {
|
||||
if (prefix.has(key)) continue;
|
||||
if (UiContext.pdoc.config.langs && !UiContext.pdoc.config.langs.includes(key)) continue;
|
||||
if (window.LANGS[key].domain && !window.LANGS[key].domain.includes(domainId)) continue;
|
||||
if (window.LANGS[key].hidden && !UiContext.pdoc.config.langs?.includes(key)) continue;
|
||||
LANGS[key] = window.LANGS[key];
|
||||
}
|
||||
const keys = Object.keys(LANGS);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.33.5",
|
||||
"version": "4.33.6",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
@@ -9,13 +9,12 @@ function setOptions($el, options) {
|
||||
|
||||
const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', 'homework_detail_problem_submit'], async () => {
|
||||
const { config } = UiContext.pdoc;
|
||||
const domainId = UiContext.pdoc.reference?.domainId || UiContext.pdoc.domainId;
|
||||
|
||||
function onChangeMain(update = true) {
|
||||
const options = {};
|
||||
for (const key in window.LANGS) {
|
||||
if (config.langs && !config.langs.includes(key)) continue;
|
||||
if (window.LANGS[key].domain && !window.LANGS[key].domain.includes(domainId)) continue;
|
||||
if (window.LANGS[key].hidden && !config.langs?.includes(key)) continue;
|
||||
if (key.startsWith(`${this.value}.`) && key !== this.value) options[key] = window.LANGS[key].display;
|
||||
}
|
||||
setOptions($('#codelang-sub-select'), options);
|
||||
@@ -31,7 +30,7 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', '
|
||||
const main = {};
|
||||
for (const key in window.LANGS) {
|
||||
if (config.langs && !config.langs.filter((i) => i === key || i.startsWith(`${key}.`)).length) continue;
|
||||
if (window.LANGS[key].domain && !window.LANGS[key].domain.includes(domainId)) continue;
|
||||
if (window.LANGS[key].hidden && !config.langs?.includes(key)) continue;
|
||||
if (!key.includes('.')) main[key] = window.LANGS[key].display;
|
||||
else {
|
||||
const a = key.split('.')[0];
|
||||
@@ -39,6 +38,7 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', '
|
||||
}
|
||||
}
|
||||
setOptions($('#codelang-main-select'), main);
|
||||
if (Object.keys(main).length === 1) $('#codelang-main-container').hide();
|
||||
|
||||
const current = $('[name="lang"]').val();
|
||||
if (current.includes('.')) {
|
||||
|
||||
@@ -10,8 +10,8 @@ export interface LangConfig {
|
||||
domain: string[];
|
||||
display: string;
|
||||
target?: string;
|
||||
sub?: LangConfig[];
|
||||
key: string;
|
||||
hidden: boolean;
|
||||
}
|
||||
|
||||
export function parseLang(config: string): Record<string, LangConfig> {
|
||||
@@ -23,13 +23,8 @@ export function parseLang(config: string): Record<string, LangConfig> {
|
||||
if (key.includes('.')) {
|
||||
const base = key.split('.')[0];
|
||||
const baseCfg = file[base];
|
||||
if (baseCfg) {
|
||||
for (const bkey in baseCfg) {
|
||||
if (bkey === 'sub') continue;
|
||||
if (!(bkey in entry)) entry[bkey] = baseCfg[bkey];
|
||||
}
|
||||
if (baseCfg.sub) baseCfg.sub.push(entry);
|
||||
else baseCfg.sub = [entry];
|
||||
for (const bkey in baseCfg || {}) {
|
||||
if (!(bkey in entry)) entry[bkey] = baseCfg[bkey];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,6 +36,7 @@ export function parseLang(config: string): Record<string, LangConfig> {
|
||||
entry.code_file = entry.code_file || `foo.${key}`;
|
||||
entry.execute = entry.execute || '/w/foo';
|
||||
entry.key = key;
|
||||
entry.hidden = entry.hidden || false;
|
||||
}
|
||||
return file;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/utils",
|
||||
"version": "1.1.14",
|
||||
"version": "1.1.15",
|
||||
"description": "hydrooj utils",
|
||||
"main": "package.json",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
@@ -8,11 +8,11 @@
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"preferUnplugged": true,
|
||||
"dependencies": {
|
||||
"fs-extra": "^10.0.0",
|
||||
"fs-extra": "^10.0.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"moment": "^2.29.1",
|
||||
"mongodb": "^3.7.3",
|
||||
"systeminformation": "^5.11.3"
|
||||
"systeminformation": "^5.11.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
|
||||
Reference in new issue
Block a user