core&ui: contest navigation improvements

This commit is contained in:
undefined committed 2025-12-21 20:37:10 +08:00
1 parent 5f1da6234e
commit 994132e51e
5 files changed
+12 -7

No files matched your search

+3 -3
View File
@@ -190,12 +190,12 @@ export class RecordDetailHandler extends ContestDetailBaseHandler {
canViewCode ||= this.user.hasPerm(PERM.PERM_READ_RECORD_CODE);
canViewCode ||= this.user.hasPerm(PERM.PERM_READ_RECORD_CODE_ACCEPT) && self?.status === STATUS.STATUS_ACCEPTED;
if (this.tdoc) {
const tsdoc = await contest.getStatus(domainId, this.tdoc.docId, this.user._id);
this.tsdoc = await contest.getStatus(domainId, this.tdoc.docId, this.user._id);
canViewCode ||= this.user.own(this.tdoc);
if (this.tdoc.allowViewCode && contest.isDone(this.tdoc)) {
canViewCode ||= tsdoc?.attend;
canViewCode ||= this.tsdoc?.attend;
}
if (!tsdoc?.attend && pdoc && !problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
if (!this.tsdoc?.attend && pdoc && !problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
} else if (pdoc && !problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
if (!canViewCode) {
rdoc.code = '';
+2 -1
View File
@@ -135,7 +135,7 @@ export async function apply(ctx: Context) {
for (const kwargs of kwargsList) {
for (const key in kwargs) {
if (kwargs[key] instanceof ObjectId) args[key] = kwargs[key].toHexString();
else args[key] = kwargs[key].toString().replace(/\//g, '%2F');
else if (key !== 'query') args[key] = kwargs[key].toString().replace(/\//g, '%2F');
}
for (const key in kwargs.query || {}) {
if (query[key] instanceof ObjectId) query[key] = kwargs.query[key].toHexString();
@@ -153,6 +153,7 @@ export async function apply(ctx: Context) {
? (!host.includes(this.request.host))
: this.request.host !== host)
)) withDomainId ||= domainId;
delete args.query;
res = server.router.url(name, args, { query }).toString();
if (anchor) res = `${res}#${anchor}`;
if (withDomainId) res = `/d/${withDomainId}${res}`;