mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core&ui: language selection bug fix
This commit is contained in:
1 parent
f1b1c89bf1
commit
ff0d172dd3
7 files changed
+36
-23
No files matched your search
+22
-20
@@ -2,7 +2,6 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const dir = path.dirname(path.dirname(require.resolve('@types/node/package.json')));
|
||||
const files = fs.readdirSync(dir);
|
||||
|
||||
const compilerOptionsBase = {
|
||||
target: 'es2020',
|
||||
@@ -17,7 +16,7 @@ const compilerOptionsBase = {
|
||||
// emitDecoratorMetadata: true,
|
||||
noEmit: true,
|
||||
incremental: true,
|
||||
types: files.filter((i) => !['sharedworker', 'serviceworker'].includes(i)),
|
||||
types: fs.readdirSync(dir).filter((i) => !['sharedworker', 'serviceworker'].includes(i)),
|
||||
};
|
||||
const config = {
|
||||
compilerOptions: compilerOptionsBase,
|
||||
@@ -69,24 +68,27 @@ fs.writeFileSync(path.resolve(process.cwd(), 'packages', 'ui-default', 'tsconfig
|
||||
},
|
||||
}));
|
||||
|
||||
const packages = fs.readdirSync(path.resolve(process.cwd(), 'packages'));
|
||||
for (const package of packages) {
|
||||
if (package === 'ui-default') continue;
|
||||
const basedir = path.resolve(process.cwd(), 'packages', package);
|
||||
const files = fs.readdirSync(basedir);
|
||||
if (!files.includes('src') && !files.map((n) => n.split('.')[1]).includes('ts') && package !== 'utils') continue;
|
||||
if (package !== 'hydrooj') config.references.push({ path: `packages/${package}` });
|
||||
fs.writeFileSync(
|
||||
path.resolve(basedir, 'tsconfig.json'),
|
||||
files.includes('src') ? JSON.stringify(configSrc) : JSON.stringify(configFlat),
|
||||
);
|
||||
if (files.includes('src')) {
|
||||
const inner = fs.readdirSync(path.resolve(basedir, 'src'));
|
||||
for (const file of inner) {
|
||||
if (!fs.statSync(path.resolve(basedir, 'src', file)).isFile()) continue;
|
||||
const name = file.split('.')[0];
|
||||
if (['handler', 'service', 'lib', 'model', 'script'].includes(name)) {
|
||||
fs.writeFileSync(path.resolve(basedir, `${name}.js`), `module.exports = require('./src/${name}');\n`);
|
||||
for (const type of ['packages', 'plugins']) {
|
||||
const packages = fs.readdirSync(path.resolve(process.cwd(), type));
|
||||
for (const package of packages) {
|
||||
if (package === 'ui-default') continue;
|
||||
const basedir = path.resolve(process.cwd(), type, package);
|
||||
if (!fs.statSync(basedir).isDirectory()) continue;
|
||||
const files = fs.readdirSync(basedir);
|
||||
if (!files.includes('src') && !files.map((n) => n.split('.')[1]).includes('ts') && package !== 'utils') continue;
|
||||
if (package !== 'hydrooj') config.references.push({ path: `${type}/${package}` });
|
||||
fs.writeFileSync(
|
||||
path.resolve(basedir, 'tsconfig.json'),
|
||||
files.includes('src') ? JSON.stringify(configSrc) : JSON.stringify(configFlat),
|
||||
);
|
||||
if (files.includes('src')) {
|
||||
const inner = fs.readdirSync(path.resolve(basedir, 'src'));
|
||||
for (const file of inner) {
|
||||
if (!fs.statSync(path.resolve(basedir, 'src', file)).isFile()) continue;
|
||||
const name = file.split('.')[0];
|
||||
if (['handler', 'service', 'lib', 'model', 'script'].includes(name)) {
|
||||
fs.writeFileSync(path.resolve(basedir, `${name}.js`), `module.exports = require('./src/${name}');\n`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.17.4",
|
||||
"version": "3.17.5",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -349,6 +349,8 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
|
||||
const p = this.pdoc.config.subType;
|
||||
const dl = [p, ...Object.keys(setting.langs).filter((i) => i.startsWith(`${p}.`))];
|
||||
baseLangs = dl;
|
||||
} else if (['objective', 'submit_answer'].includes(this.pdoc.config.type)) {
|
||||
baseLangs = ['_'];
|
||||
} else {
|
||||
baseLangs = Object.keys(setting.langs).filter((i) => !setting.langs[i].remote);
|
||||
}
|
||||
@@ -478,7 +480,11 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
|
||||
|
||||
async get() {
|
||||
this.response.template = 'problem_submit.html';
|
||||
const langRange = (typeof this.pdoc.config === 'object' && this.pdoc.config.langs)
|
||||
? Object.fromEntries(this.pdoc.config.langs.map((i) => [i, setting.langs[i]?.display || i]))
|
||||
: setting.SETTINGS_BY_KEY.codeLang.range;
|
||||
this.response.body = {
|
||||
langRange,
|
||||
pdoc: this.pdoc,
|
||||
udoc: this.udoc,
|
||||
title: this.pdoc.title,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.40.3",
|
||||
"version": "4.40.4",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
@@ -3,6 +3,7 @@ import $ from 'jquery';
|
||||
import yaml from 'js-yaml';
|
||||
import React from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import Notification from 'vj/components/notification';
|
||||
import { downloadProblemSet } from 'vj/components/zipDownloader';
|
||||
import { NamedPage } from 'vj/misc/Page';
|
||||
import delay from 'vj/utils/delay';
|
||||
|
||||
@@ -5,6 +5,10 @@ import getAvailableLangs from 'vj/utils/availableLangs';
|
||||
|
||||
const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', 'homework_detail_problem_submit'], async () => {
|
||||
const { config } = UiContext.pdoc;
|
||||
if (config.type === 'submit_answer') {
|
||||
$('[name="lang"]').val('_');
|
||||
return;
|
||||
}
|
||||
const availableLangs = getAvailableLangs(config.langs);
|
||||
const mainLangs = {};
|
||||
const preferences = [($('[name="lang"]').val() as string) || ''];
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<div class="hasjs--hide">
|
||||
{{ form.form_select({
|
||||
label:'Code language',
|
||||
options:model.setting.SETTINGS_BY_KEY['codeLang'].range,
|
||||
options:langRange,
|
||||
name:'lang',
|
||||
value:handler.user.codeLang
|
||||
}) }}
|
||||
|
||||
Reference in new issue
Block a user