mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core&ui: contest: better navbar
This commit is contained in:
1 parent
e8b6459e01
commit
f52be39803
6 files changed
+49
-16
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "4.0.15",
|
"version": "4.0.16",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/plugin-api",
|
"main": "src/plugin-api",
|
||||||
"module": "src/plugin-api",
|
"module": "src/plugin-api",
|
||||||
|
|||||||
@@ -106,6 +106,36 @@ export class ContestDetailBaseHandler extends Handler {
|
|||||||
this.tsdoc.endAt = moment(this.tsdoc.startAt).add(this.tdoc.duration, 'hours').toDate();
|
this.tsdoc.endAt = moment(this.tsdoc.startAt).add(this.tdoc.duration, 'hours').toDate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@param('tid', Types.ObjectID, true)
|
||||||
|
async after(domainId: string, tid: ObjectID) {
|
||||||
|
if (!tid || this.request.json || !this.response.template || !contest.isOngoing(this.tdoc, this.tsdoc)) return;
|
||||||
|
const pdoc = 'pdoc' in this ? (this as any).pdoc : {};
|
||||||
|
this.response.body.overrideNav = [
|
||||||
|
{ name: 'homepage', args: { prefix: 'homepage' }, checker: () => true },
|
||||||
|
{
|
||||||
|
name: 'contest_detail',
|
||||||
|
displayName: this.tdoc.title,
|
||||||
|
args: { tid, prefix: 'contest_detail' },
|
||||||
|
checker: () => true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'contest_scoreboard',
|
||||||
|
args: { tid, prefix: 'contest_scoreboard' },
|
||||||
|
checker: () => contest.canShowScoreboard.call(this, this.tdoc, true),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'record_main',
|
||||||
|
args: { tid, prefix: 'record_main', query: contest.canShowRecord.call(this, this.tdoc, true) ? {} : { uidOrName: this.user._id } },
|
||||||
|
checker: () => contest.canShowSelfRecord.call(this, this.tdoc, true),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: `${String.fromCharCode(65 + this.tdoc.pids.indexOf(pdoc.docId))}. ${pdoc.title}`,
|
||||||
|
args: { query: { tid }, pid: pdoc.docId, prefix: 'contest_detail_problem' },
|
||||||
|
checker: () => 'pdoc' in this,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ContestDetailHandler extends ContestDetailBaseHandler {
|
export class ContestDetailHandler extends ContestDetailBaseHandler {
|
||||||
|
|||||||
@@ -35,17 +35,20 @@ export default (router, logger) => async (ctx: KoaContext, next) => {
|
|||||||
response.body = await ctx.renderHTML(name, args);
|
response.body = await ctx.renderHTML(name, args);
|
||||||
response.type = 'text/html';
|
response.type = 'text/html';
|
||||||
};
|
};
|
||||||
ctx.getUrl = (name: string, kwargs: any = {}) => {
|
ctx.getUrl = (name: string, ...kwargsList: Record<string, any>[]) => {
|
||||||
|
if (name === '#') return '#';
|
||||||
let res = '#';
|
let res = '#';
|
||||||
const args: any = {};
|
const args: any = {};
|
||||||
const query: any = {};
|
const query: any = {};
|
||||||
for (const key in kwargs) {
|
for (const kwargs of kwargsList) {
|
||||||
if (kwargs[key] instanceof ObjectID) args[key] = kwargs[key].toHexString();
|
for (const key in kwargs) {
|
||||||
else args[key] = kwargs[key].toString().replace(/\//g, '%2F');
|
if (kwargs[key] instanceof ObjectID) args[key] = kwargs[key].toHexString();
|
||||||
}
|
else 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();
|
for (const key in kwargs.query || {}) {
|
||||||
else query[key] = kwargs.query[key].toString();
|
if (query[key] instanceof ObjectID) query[key] = kwargs.query[key].toHexString();
|
||||||
|
else query[key] = kwargs.query[key].toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const { anchor } = args;
|
const { anchor } = args;
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ async function handle(ctx: KoaContext, HandlerClass, checker) {
|
|||||||
...operation ? [
|
...operation ? [
|
||||||
`handler/before-operation/${name}`, 'handler/before-operation',
|
`handler/before-operation/${name}`, 'handler/before-operation',
|
||||||
`post${operation}`, 'log/__operationDone',
|
`post${operation}`, 'log/__operationDone',
|
||||||
] : [],
|
] : [], 'after',
|
||||||
`handler/after/${name}`, 'handler/after', 'cleanup',
|
`handler/after/${name}`, 'handler/after', 'cleanup',
|
||||||
`handler/finish/${name}`, 'handler/finish',
|
`handler/finish/${name}`, 'handler/finish',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.41.13",
|
"version": "4.41.14",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "index.ts",
|
"main": "index.ts",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{%- macro nav_item(target_name, target_args, target_prefix) -%}
|
{%- macro nav_item(item) -%}
|
||||||
<li class="nav__list-item">
|
<li class="nav__list-item">
|
||||||
<a href="{{ url(target_name, query=target_args.query(handler) if typeof(target_args.query) == 'function' else target_args.query or {}) }}" class="nav__item{% if page_name.startsWith(target_prefix) %} nav--active{% endif %}">
|
<a href="{{ url(item.name, item.args, query=item.args.query(handler) if typeof(item.args.query) == 'function' else item.args.query or {}) }}" class="nav__item{% if page_name.startsWith(item.args.prefix) %} nav--active{% endif %}">
|
||||||
{{ _(target_name) }}
|
{{ _(item.displayName or item.name) }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
@@ -10,8 +10,8 @@
|
|||||||
<div class="row"><div class="columns clearfix">
|
<div class="row"><div class="columns clearfix">
|
||||||
<ol class="nav__list nav__list--main clearfix">
|
<ol class="nav__list nav__list--main clearfix">
|
||||||
<li class="nav__list-item"><a href="/" class="nav__logo" style="background-size: 100% 100%;"> </a></li>
|
<li class="nav__list-item"><a href="/" class="nav__logo" style="background-size: 100% 100%;"> </a></li>
|
||||||
{%- for item in ui.getNodes('Nav') -%}{% if item.checker(handler) %}
|
{%- for item in overrideNav|default(ui.getNodes('Nav')) -%}{% if item.checker(handler) %}
|
||||||
{{ nav_item(item.name, item.args, item.args.prefix) }}
|
{{ nav_item(item) }}
|
||||||
{% endif %}{%- endfor -%}
|
{% endif %}{%- endfor -%}
|
||||||
</ol>
|
</ol>
|
||||||
<ol class="nav__list nav__list--secondary clearfix">
|
<ol class="nav__list nav__list--secondary clearfix">
|
||||||
|
|||||||
Reference in new issue
Block a user