mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core&ui: contest navigation improvements
This commit is contained in:
5 files changed
+12
-7
No files matched your search
@@ -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 = '';
|
||||
|
||||
@@ -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}`;
|
||||
|
||||
Reference in new issue
Block a user