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

+1 -1
View File
@@ -9,7 +9,7 @@
}, },
"dependencies": { "dependencies": {
"@hydrooj/utils": "workspace:^", "@hydrooj/utils": "workspace:^",
"@koa/router": "^15.1.0", "@koa/router": "^15.1.1",
"@mongodb-js/saslprep": "^1.4.4", "@mongodb-js/saslprep": "^1.4.4",
"emoji-regex": "^10.6.0", "emoji-regex": "^10.6.0",
"fs-extra": "^11.3.2", "fs-extra": "^11.3.2",
+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);
canViewCode ||= this.user.hasPerm(PERM.PERM_READ_RECORD_CODE_ACCEPT) && self?.status === STATUS.STATUS_ACCEPTED; canViewCode ||= this.user.hasPerm(PERM.PERM_READ_RECORD_CODE_ACCEPT) && self?.status === STATUS.STATUS_ACCEPTED;
if (this.tdoc) { 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); canViewCode ||= this.user.own(this.tdoc);
if (this.tdoc.allowViewCode && contest.isDone(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); } else if (pdoc && !problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
if (!canViewCode) { if (!canViewCode) {
rdoc.code = ''; rdoc.code = '';
+2 -1
View File
@@ -135,7 +135,7 @@ export async function apply(ctx: Context) {
for (const kwargs of kwargsList) { for (const kwargs of kwargsList) {
for (const key in kwargs) { for (const key in kwargs) {
if (kwargs[key] instanceof ObjectId) args[key] = kwargs[key].toHexString(); 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 || {}) { for (const key in kwargs.query || {}) {
if (query[key] instanceof ObjectId) query[key] = kwargs.query[key].toHexString(); 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)) ? (!host.includes(this.request.host))
: this.request.host !== host) : this.request.host !== host)
)) withDomainId ||= domainId; )) withDomainId ||= domainId;
delete args.query;
res = server.router.url(name, args, { query }).toString(); res = server.router.url(name, args, { query }).toString();
if (anchor) res = `${res}#${anchor}`; if (anchor) res = `${res}#${anchor}`;
if (withDomainId) res = `/d/${withDomainId}${res}`; if (withDomainId) res = `/d/${withDomainId}${res}`;
@@ -64,6 +64,9 @@ for key, value in $contest-color
padding-bottom: 0.5rem; padding-bottom: 0.5rem;
width: rem(180px); width: rem(180px);
+mobile()
display: none;
> a > a
text-decoration: none; text-decoration: none;
background-color: transparent; background-color: transparent;
@@ -63,15 +63,16 @@
</button> </button>
</form> </form>
{% endif %} {% endif %}
{%- if not tdoc or tdoc.pids|length > 1 -%}
{%- if tdoc -%} {%- if tdoc -%}
{{ utils.getAlphabeticId(tdoc.pids.indexOf(pdoc.docId)) }} {{ utils.getAlphabeticId(tdoc.pids.indexOf(pdoc.docId)) }}
{%- elif pdoc.pid and pdoc.pid.includes('-') -%} {%- elif pdoc.pid and pdoc.pid.includes('-') -%}
{{ pdoc.pid.split('-').join('#') }} {{ pdoc.pid.split('-').join('#') }}
{%- else -%} {%- else -%}
#{{ pdoc.pid|default(pdoc.docId) }} #{{ pdoc.pid|default(pdoc.docId) }}
{%- endif -%}. {{ pdoc.title }} {%- endif -%}. {% endif %}{{ pdoc.title }}
</h1> </h1>
{% if tdoc and tdoc.pids|length <= 26 %} {% if tdoc and tdoc.pids|length <= 26 and tdoc.pids|length > 1 %}
<div class="section__tools contest-problems"> <div class="section__tools contest-problems">
{% for pid in tdoc.pids -%} {% for pid in tdoc.pids -%}
{% set status = tsdoc.detail[pid].status %} {% set status = tsdoc.detail[pid].status %}