mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core&ui: contest navigation improvements
This commit is contained in:
5 files changed
+12
-7
No files matched your search
@@ -9,7 +9,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@hydrooj/utils": "workspace:^",
|
||||
"@koa/router": "^15.1.0",
|
||||
"@koa/router": "^15.1.1",
|
||||
"@mongodb-js/saslprep": "^1.4.4",
|
||||
"emoji-regex": "^10.6.0",
|
||||
"fs-extra": "^11.3.2",
|
||||
|
||||
@@ -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}`;
|
||||
|
||||
@@ -64,6 +64,9 @@ for key, value in $contest-color
|
||||
padding-bottom: 0.5rem;
|
||||
width: rem(180px);
|
||||
|
||||
+mobile()
|
||||
display: none;
|
||||
|
||||
> a
|
||||
text-decoration: none;
|
||||
background-color: transparent;
|
||||
|
||||
@@ -63,15 +63,16 @@
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{%- if not tdoc or tdoc.pids|length > 1 -%}
|
||||
{%- if tdoc -%}
|
||||
{{ utils.getAlphabeticId(tdoc.pids.indexOf(pdoc.docId)) }}
|
||||
{%- elif pdoc.pid and pdoc.pid.includes('-') -%}
|
||||
{{ pdoc.pid.split('-').join('#') }}
|
||||
{%- else -%}
|
||||
#{{ pdoc.pid|default(pdoc.docId) }}
|
||||
{%- endif -%}. {{ pdoc.title }}
|
||||
{%- endif -%}. {% endif %}{{ pdoc.title }}
|
||||
</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">
|
||||
{% for pid in tdoc.pids -%}
|
||||
{% set status = tsdoc.detail[pid].status %}
|
||||
|
||||
Reference in new issue
Block a user