mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix system_setting to update codeLang list
This commit is contained in:
1 parent
e7780c56bb
commit
be0b90dcd4
8 files changed
+23
-10
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/hydrojudge",
|
"name": "@hydrooj/hydrojudge",
|
||||||
"bin": "bin/hydrojudge.js",
|
"bin": "bin/hydrojudge.js",
|
||||||
"version": "2.4.10",
|
"version": "2.4.11",
|
||||||
"os": [
|
"os": [
|
||||||
"linux"
|
"linux"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -226,7 +226,6 @@ async function postInit() {
|
|||||||
this.config,
|
this.config,
|
||||||
{ next: this.next },
|
{ next: this.next },
|
||||||
);
|
);
|
||||||
console.log(this.config);
|
|
||||||
this.stat.judge = new Date();
|
this.stat.judge = new Date();
|
||||||
await judge[this.config.type || 'default'].judge(this);
|
await judge[this.config.type || 'default'].judge(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.20.17",
|
"version": "2.20.18",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -155,7 +155,6 @@ class DomainPermissionHandler extends ManageHandler {
|
|||||||
const roles = {};
|
const roles = {};
|
||||||
delete this.request.body.csrfToken;
|
delete this.request.body.csrfToken;
|
||||||
for (const role in this.request.body) {
|
for (const role in this.request.body) {
|
||||||
console.log(role, this.request.body[role]);
|
|
||||||
const perms = this.request.body[role] instanceof Array
|
const perms = this.request.body[role] instanceof Array
|
||||||
? this.request.body[role]
|
? this.request.body[role]
|
||||||
: [this.request.body[role]];
|
: [this.request.body[role]];
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
import { Udoc } from '../interface';
|
import { Udoc } from '../interface';
|
||||||
|
|
||||||
/* Why nocheck?
|
/*
|
||||||
|
* Why nocheck?
|
||||||
* BitInt requires at least ES2020, but we can't use it as
|
* BitInt requires at least ES2020, but we can't use it as
|
||||||
* NodeJS doesn't support some of this new features.
|
* NodeJS doesn't support some of this new features.
|
||||||
* e.g.: object?.property
|
* e.g.: object?.property
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ bus.once('app/started', async () => {
|
|||||||
|
|
||||||
bus.on('system/setting', (args) => {
|
bus.on('system/setting', (args) => {
|
||||||
if (!args.lang?.texts) return;
|
if (!args.lang?.texts) return;
|
||||||
SETTINGS_BY_KEY['lang.texts'].value = args.lang.texts;
|
SETTINGS_BY_KEY['codeLang'].range = args.lang.texts;
|
||||||
});
|
});
|
||||||
|
|
||||||
global.Hydro.model.setting = {
|
global.Hydro.model.setting = {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import sockjs from 'sockjs';
|
|||||||
import type { SetOption } from 'cookies';
|
import type { SetOption } from 'cookies';
|
||||||
import serialize, { SerializeJSOptions } from 'serialize-javascript';
|
import serialize, { SerializeJSOptions } from 'serialize-javascript';
|
||||||
import { argv } from 'yargs';
|
import { argv } from 'yargs';
|
||||||
import { lrucache } from '../utils';
|
import { errorMessage, lrucache } from '../utils';
|
||||||
import { User, DomainDoc } from '../interface';
|
import { User, DomainDoc } from '../interface';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import {
|
import {
|
||||||
@@ -478,7 +478,8 @@ export class Handler extends HandlerCommon {
|
|||||||
if (!this.response.body) return;
|
if (!this.response.body) return;
|
||||||
try {
|
try {
|
||||||
await this.renderBody();
|
await this.renderBody();
|
||||||
} catch (error) {
|
} catch (err) {
|
||||||
|
const error = errorMessage(err);
|
||||||
this.response.status = error instanceof UserFacingError ? error.code : 500;
|
this.response.status = error instanceof UserFacingError ? error.code : 500;
|
||||||
if (this.request.json) this.response.body = { error };
|
if (this.request.json) this.response.body = { error };
|
||||||
else {
|
else {
|
||||||
@@ -576,7 +577,7 @@ export class Handler extends HandlerCommon {
|
|||||||
this.response.status = error instanceof UserFacingError ? error.code : 500;
|
this.response.status = error instanceof UserFacingError ? error.code : 500;
|
||||||
this.response.template = error instanceof UserFacingError ? 'error.html' : 'bsod.html';
|
this.response.template = error instanceof UserFacingError ? 'error.html' : 'bsod.html';
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
error: { message: error.msg(), params: error.params, stack: error.stack },
|
error: { message: error.msg(), params: error.params, stack: errorMessage(error.stack) },
|
||||||
};
|
};
|
||||||
await this.finish().catch(() => { });
|
await this.finish().catch(() => { });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { Duplex } from 'stream';
|
import { Duplex } from 'stream';
|
||||||
import cluster from 'cluster';
|
import cluster from 'cluster';
|
||||||
import path from 'path';
|
import path, { sep } from 'path';
|
||||||
import serialize from 'serialize-javascript';
|
import serialize from 'serialize-javascript';
|
||||||
import Lru from 'lru-cache';
|
import Lru from 'lru-cache';
|
||||||
import { ObjectID } from 'mongodb';
|
import { ObjectID } from 'mongodb';
|
||||||
@@ -266,3 +266,16 @@ export const log2 = (val: bigint | number) => {
|
|||||||
for (let i = 0; ; i++) if (!(val >> i)) return i - 1;
|
for (let i = 0; ; i++) if (!(val >> i)) return i - 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function errorMessage(err: Error | string) {
|
||||||
|
const t = typeof err === 'string' ? err : err.stack;
|
||||||
|
const q = t.split('\n');
|
||||||
|
for (let i = 0; i < q.length; i++) {
|
||||||
|
if (!q[i].startsWith(' at')) continue;
|
||||||
|
if (q[i].includes(`${sep}@hydrooj${sep}`)) q[i] = q[i].split(`@hydrooj${sep}`)[1];
|
||||||
|
else if (q[i].includes(`${sep}hydrooj${sep}`)) q[i] = `hydrooj${sep}${q[i].split(`hydrooj/${sep}`)[1]}`;
|
||||||
|
}
|
||||||
|
if (typeof err === 'string') return q.join('\n');
|
||||||
|
err.stack = q.join('\n');
|
||||||
|
return err;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user