core: 修复pretest结果不回显的问题

This commit is contained in:
undefined committed 2021-01-14 13:39:33 +08:00
1 parent 25570d6275
commit cce3b3a745
6 files changed
+69 -39

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.15.18",
"version": "2.15.19",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",
-8
View File
@@ -295,9 +295,7 @@ export class ProblemPretestHandler extends ProblemDetailHandler {
export class ProblemPretestConnectionHandler extends ConnectionHandler {
pid: string;
domainId: string;
dispose: bus.Disposable;
@param('pid', Types.String)
@@ -316,12 +314,6 @@ export class ProblemPretestConnectionHandler extends ConnectionHandler {
|| rdoc.pid.toString() !== this.pid
|| rdoc.domainId !== this.domainId
) return;
rdoc.compilerTexts = [];
rdoc.judgeTexts = [];
// @ts-ignore
rdoc.testCases = rdoc.testCases.map((c) => ({
status: c.status,
}));
// TODO handle update
if (rdoc.contest) return;
this.send({ rdoc });
+2 -5
View File
@@ -1,5 +1,3 @@
import { Dictionary } from 'lodash';
const locales = {};
declare global {
@@ -43,7 +41,6 @@ String.prototype.rawformat = function rawFormat(object) {
};
String.prototype.translate = function translate(...languages: string[]) {
languages.push(global.Hydro.model.system.get('server.language'));
for (const language of languages) {
if (!language) continue;
const curr = (locales[language] || {})[this] || (locales[language.split('_')[0]] || {})[this];
@@ -52,9 +49,9 @@ String.prototype.translate = function translate(...languages: string[]) {
return this;
};
function load(data: Dictionary<string>) {
function load(data: Record<string, Record<string, string>>) {
for (const i in data) {
if (!locales[i]) locales[i] = data[i];
if (!locales[i]) locales[i] = { __id: i, ...data[i] };
else locales[i] = Object.assign(locales[i], data[i]);
}
}
+4 -9
View File
@@ -232,15 +232,10 @@ export namespace Time {
export const week = day * 7;
export function formatTimeShort(ms: number) {
const abs = Math.abs(ms);
if (abs >= day - hour / 2) {
return `${Math.round(ms / day)}d`;
} if (abs >= hour - minute / 2) {
return `${Math.round(ms / hour)}h`;
} if (abs >= minute - second / 2) {
return `${Math.round(ms / minute)}m`;
} if (abs >= second) {
return `${Math.round(ms / second)}s`;
}
if (abs >= day - hour / 2) return `${Math.round(ms / day)}d`;
if (abs >= hour - minute / 2) return `${Math.round(ms / hour)}h`;
if (abs >= minute - second / 2) return `${Math.round(ms / minute)}m`;
if (abs >= second) return `${Math.round(ms / second)}s`;
return `${ms}ms`;
}