ui: domain.lang

This commit is contained in:
undefined committed 2021-06-21 13:40:13 +08:00
1 parent 680e3ccd32
commit 387bd5eb38
6 files changed
+12 -11

No files matched your search

@@ -99,7 +99,6 @@ const prismjsApiWrap = {
const astyle = language.match(/astyle-([a-z]+)/);
if (format && astyle && astyle[1]) {
const [success, result] = format($code.text(), `${UserContext.astyleOptions.trim()} mode=${astyle[1]}`);
console.log(success.result);
code.original = $code.text();
if (!success) Notification.error('Code format fail');
else $code.text(result);
@@ -84,6 +84,8 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool
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(UiContext.domainId)) continue;
if (UiContext.domain.langs && !`,${UiContext.domain.langs},`.includes(`,${key},`)) continue;
LANGS[key] = window.LANGS[key];
}
return (
+1 -1
View File
@@ -132,7 +132,7 @@ class RichMediaHandler extends Handler {
async renderProblem(domainId, payload) {
const cur = payload.domainId ? await user.getById(payload.domainId, this.user._id) : this.user;
let pdoc = cur.hasPerm(PERM.PERM_VIEW | PERM.PERM_VIEW_PROBLEM)
? await problem.get(domainId, payload.data) || problem.default
? await problem.get(domainId, payload.id) || problem.default
: problem.default;
if (pdoc.hidden && !cur.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN)) pdoc = problem.default;
return await this.renderHTML('partials/problem.html', { pdoc });
+2 -6
View File
@@ -21,12 +21,8 @@ export class Page {
}
isNameMatch(name) {
if (typeof this.name === 'string') {
return this.name === name;
}
if (this.name instanceof Array) {
return this.name.indexOf(name) !== -1;
}
if (typeof this.name === 'string') return this.name === name;
if (this.name instanceof Array) return this.name.includes(name);
return false;
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.11.33",
"version": "4.11.34",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",
@@ -26,7 +26,7 @@
"@blueprintjs/core": "^3.45.0",
"@blueprintjs/icons": "^3.26.1",
"@blueprintjs/select": "^3.16.4",
"@hydrooj/utils": "^1.0.20",
"@hydrooj/utils": "workspace:packages/utils",
"@types/json-schema": "^7.0.7",
"@types/katex": "^0.11.0",
"@undefined-moe/monaco-yaml": "^2.5.0",
@@ -7,7 +7,7 @@ function setOptions($el, options) {
});
}
const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', 'homework_detail_problem_submit'], async () => {
const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', 'homework_detail_problem_submit'], async (name) => {
$(document).on('click', '[name="problem-sidebar__show-category"]', (ev) => {
$(ev.currentTarget).hide();
$('[name="problem-sidebar__categories"]').show();
@@ -16,6 +16,8 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', '
const options = {};
for (const key in window.LANGS) {
if (UiContext.pdocConfig.langs && !UiContext.pdocConfig.langs.includes(key)) continue;
if (window.LANGS[key].domain && !window.LANGS[key].domain.includes(UiContext.domainId)) continue;
if (UiContext.domain.langs && !`,${UiContext.domain.langs},`.includes(`,${key},`)) continue;
if (key.startsWith(`${this.value}.`) && key !== this.value) options[key] = window.LANGS[key].display;
}
if (Object.keys(options).length > 1) {
@@ -31,6 +33,8 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', '
const prefix = new Set(Object.keys(window.LANGS).filter((i) => i.includes('.')).map((i) => i.split('.')[0]));
for (const key in window.LANGS) {
if (UiContext.pdocConfig.langs && !prefix.has(key) && !UiContext.pdocConfig.langs.includes(key)) continue;
if (window.LANGS[key].domain && !window.LANGS[key].domain.includes(UiContext.domainId)) continue;
if (UiContext.domain.langs && !`,${UiContext.domain.langs},`.includes(`,${key},`)) continue;
if (!key.includes('.')) main[key] = window.LANGS[key].display;
}
setOptions($('#codelang-main-select'), main);