mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
add option to use xcpcio as default scoreboard
This commit is contained in:
2 files changed
+11
-7
No files matched your search
@@ -378,11 +378,4 @@ export function apply(ctx: Context, config: ReturnType<typeof Config>) {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
ctx.on('handler/before/ContestScoreboard#get', (that) => {
|
||||
if (that.request.path.endsWith('/scoreboard')) {
|
||||
that.response.redirect = `${that.request.path}/xcpcio`;
|
||||
return 'cleanup';
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -91,6 +91,7 @@ export const name = 'scoreboard-xcpcio';
|
||||
export const Config = Schema.object({
|
||||
cacheTTL: Schema.number().default(0).description('Cache TTL in milliseconds'),
|
||||
cacheSize: Schema.number().default(100).description('Cache size'),
|
||||
asDefault: Schema.boolean().default(false).description('As default scoreboard'),
|
||||
});
|
||||
|
||||
export async function apply(ctx: Context, config: ReturnType<typeof Config>) {
|
||||
@@ -126,6 +127,16 @@ export async function apply(ctx: Context, config: ReturnType<typeof Config>) {
|
||||
});
|
||||
}
|
||||
|
||||
if (config.asDefault) {
|
||||
// eslint-disable-next-line consistent-return
|
||||
ctx.on('handler/before/ContestScoreboard#get', (that) => {
|
||||
if (that.request.path.endsWith('/scoreboard') && that.tdoc?.rule === 'acm') {
|
||||
that.response.redirect = `${that.request.path}/xcpcio`;
|
||||
return 'cleanup';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ctx.inject(['scoreboard'], ({ scoreboard }) => {
|
||||
scoreboard.addView('xcpcio', 'XCPCIO', {
|
||||
tdoc: 'tdoc',
|
||||
|
||||
Reference in new issue
Block a user