修复windows下路径的问题,添加设置项,完善翻译

This commit is contained in:
undefined committed 2020-07-16 12:27:29 +08:00
1 parent 5980080302
commit 6ad41dc2ae
29 files changed
+368 -278

No files matched your search

+1 -1
View File
@@ -280,7 +280,7 @@ class ContestProblemSubmitHandler extends ContestProblemHandler {
ttype: document.TYPE_CONTEST,
lang,
code,
});
}, true);
await contest.updateStatus(domainId, this.tdoc.docId, this.user._id, rid, this.pdoc.docId);
if (!this.canShowRecord(this.tdoc)) {
this.response.body = { tid };
+5 -6
View File
@@ -1,9 +1,7 @@
import { ObjectID } from 'mongodb';
import {
VerifyPasswordError, UserAlreadyExistError, InvalidTokenError,
NotFoundError,
UserNotFoundError,
PermissionError,
NotFoundError, UserNotFoundError, PermissionError,
} from '../error';
import * as bus from '../service/bus';
import {
@@ -321,7 +319,7 @@ class HomeMessagesHandler extends Handler {
const udoc = await user.getById('system', uid);
if (!udoc) throw new UserNotFoundError(uid);
if (udoc.gravatar) udoc.gravatar = misc.gravatar(udoc.gravatar);
const mdoc = await message.send(this.user._id, uid, content);
const mdoc = await message.send(this.user._id, uid, content, message.FLAG_UNREAD);
// TODO(twd2): improve here: projection
if (this.user._id !== uid) {
bus.publish(`user_message-${uid}`, { mdoc, udoc });
@@ -340,8 +338,9 @@ class HomeMessagesHandler extends Handler {
@param('messageId', Types.ObjectID)
async postRead(domainId: string, messageId: ObjectID) {
const msg = await message.get(messageId);
if ([msg.from, msg.to].includes(this.user._id)) await message.setFlag(messageId, message.FLAG_UNREAD);
else throw new PermissionError();
if ([msg.from, msg.to].includes(this.user._id)) {
await message.setFlag(messageId, message.FLAG_UNREAD);
} else throw new PermissionError();
this.back();
}
}
+1 -1
View File
@@ -182,7 +182,7 @@ class HomeworkDetailProblemSubmitHandler extends HomeworkDetailProblemHandler {
if (!this.tdoc.pids.includes(pid)) throw new ProblemNotFoundError(domainId, pid);
const rid = await record.add(domainId, {
pid, lang, code, uid: this.user._id, tid, hidden: true, ttype: document.TYPE_HOMEWORK,
});
}, true);
await contest.updateStatus(domainId, tid, this.user._id,
rid, pid, false, 0, document.TYPE_HOMEWORK);
this.response.body = { tid, rid };
+1 -1
View File
@@ -126,7 +126,7 @@ class PretestHandler extends Handler {
lang,
code,
hidden: true,
});
}, true);
this.response.body = { rid };
this.response.redirect = this.url('record_detail', { rid });
}
+8 -5
View File
@@ -6,7 +6,7 @@ import * as system from '../model/system';
import { STATUS, PRIV } from '../model/builtin';
import * as record from '../model/record';
import {
Route, Connection, Handler, ConnectionHandler,
Route, Connection, Handler, ConnectionHandler, param, Types,
} from '../service/server';
import { validate } from '../lib/validator';
import * as hpm from '../lib/hpm';
@@ -101,18 +101,21 @@ class SystemScriptHandler extends SystemHandler {
this.response.body.path.push(['manage_script', null]);
}
async post({ domainId, id, args = '{}' }) {
@param('id', Types.String)
@param('args', Types.String, true)
async post(domainId: string, id: string, args = '{}') {
if (!global.Hydro.script[id]) throw new ValidationError('id');
args = JSON.parse(args);
validate(global.Hydro.script[id].validate, args);
const rid = await record.add(domainId, {
pid: id,
pid: 1,
uid: this.user._id,
lang: null,
code: null,
status: STATUS.STATUS_JUDGING,
hidden: true,
}, false);
judge.next({ domainId, rid, message: `Running script: ${id}` });
async function report(data) {
judge.next({ domainId, rid, ...data });
}
@@ -125,13 +128,13 @@ class SystemScriptHandler extends SystemHandler {
domainId,
rid,
status: STATUS.STATUS_ACCEPTED,
judge_text: ret,
judge_text: ret.toString(),
judger: 1,
time_ms: time,
memory_kb: 0,
});
})
.catch((err) => {
.catch((err: Error) => {
const time = new Date().getTime() - start;
judge.end({
domainId,
+1 -1
View File
@@ -234,7 +234,7 @@ class ProblemPretestHandler extends ProblemDetailHandler {
this.limitRate('add_record', 60, 100);
const rid = await record.add(domainId, {
uid: this.user._id, lang, code, pid: this.pdoc.docId, input,
});
}, true);
await record.judge(domainId, rid);
this.response.body = { rid };
}