mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 17:46:28 +08:00
bug fixes
This commit is contained in:
9 files changed
+51
-25
No files matched your search
@@ -42,7 +42,7 @@ class I18nService extends Service {
|
||||
if (languages[0]?.startsWith('en')) {
|
||||
// For most use cases, source text equals to translated text in English.
|
||||
// So if it doesn't exist, we should use the original text instead of fallback.
|
||||
return this.get(str, languages[0]) || this.get(str, 'en') || this.toString();
|
||||
return this.get(str, languages[0]) || this.get(str, 'en') || str.toString();
|
||||
}
|
||||
for (const language of languages.filter(Boolean)) {
|
||||
const curr = this.get(str, language) || this.get(str, language.split('_')[0])
|
||||
|
||||
@@ -388,7 +388,7 @@ const oi = buildContestRule({
|
||||
score: tsddict[pid]?.score,
|
||||
};
|
||||
if (tsddict[pid]?.status === STATUS.STATUS_ACCEPTED) {
|
||||
if (tsddict[pid].rid.getTimestamp().getTime() - (tsdoc.startAt.getTime() || tdoc.beginAt.getTime())) {
|
||||
if (tsddict[pid].rid.getTimestamp().getTime() - (tsdoc.startAt || tdoc.beginAt).getTime() === meta?.first?.[pid]) {
|
||||
node.style = 'background-color: rgb(217, 240, 199);';
|
||||
}
|
||||
}
|
||||
@@ -403,9 +403,9 @@ const oi = buildContestRule({
|
||||
const psdict = {};
|
||||
const first = {};
|
||||
for (const [, tsdoc] of rankedTsdocs) {
|
||||
for (const [pid, detail] of Object.entries(tsdoc.detail)) {
|
||||
for (const [pid, detail] of Object.entries(tsdoc.detail || {})) {
|
||||
if (detail.status !== STATUS.STATUS_ACCEPTED) continue;
|
||||
const time = detail.rid.getTimestamp().getTime() - (tsdoc.startAt.getTime() || tdoc.beginAt.getTime());
|
||||
const time = detail.rid.getTimestamp().getTime() - (tsdoc.startAt || tdoc.beginAt).getTime();
|
||||
if (!first[pid] || first[pid] > time) first[pid] = time;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,15 +222,22 @@ export async function apply(ctx: Context) {
|
||||
}
|
||||
},
|
||||
});
|
||||
server.wsHandlerMixin((s) => ({
|
||||
server.wsHandlerMixin({
|
||||
async onerror(err: HydroError) {
|
||||
if (![NotFoundError, PrivilegeError, PermissionError].some((i) => err instanceof i) || this.user?._id !== 0) {
|
||||
logger.error(`Path:${this.request.path}, User:${this.user?._id}(${this.user?.uname})`);
|
||||
logger.error(err);
|
||||
}
|
||||
await s.onerror(err);
|
||||
if (err instanceof UserFacingError) err.stack = this.request.path;
|
||||
this.send({
|
||||
error: {
|
||||
name: err.name,
|
||||
params: err.params || [],
|
||||
},
|
||||
});
|
||||
this.close(4000, err.toString());
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
||||
on('handler/create', async (h) => {
|
||||
h.user = h.context.HydroContext.user as any;
|
||||
|
||||
Reference in new issue
Block a user