mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add paginator keys
This commit is contained in:
7 files changed
+21
-23
No files matched your search
@@ -9,6 +9,7 @@ import Body from 'koa-body';
|
||||
import Compress from 'koa-compress';
|
||||
import proxy from 'koa-proxies';
|
||||
import cache from 'koa-static-cache';
|
||||
import type { FindCursor } from 'mongodb';
|
||||
import WebSocket from 'ws';
|
||||
import { Counter, isClass, parseMemoryMB } from '@hydrooj/utils/lib/utils';
|
||||
import { Context, Service } from '../context';
|
||||
@@ -18,6 +19,7 @@ import {
|
||||
PrivilegeError, UserFacingError,
|
||||
} from '../error';
|
||||
import { DomainDoc } from '../interface';
|
||||
import paginate from '../lib/paginate';
|
||||
import serializer from '../lib/serializer';
|
||||
import { Types } from '../lib/validator';
|
||||
import { Logger } from '../logger';
|
||||
@@ -150,6 +152,10 @@ export class HandlerCommon {
|
||||
await opcount.inc(op, id, periodSecs, maxOperations);
|
||||
}
|
||||
|
||||
paginate<T>(cursor: FindCursor<T>, page: number, key: string) {
|
||||
return paginate(cursor, page, this.ctx.setting.get(`pagination.${key}`));
|
||||
}
|
||||
|
||||
renderTitle(str: string) {
|
||||
const name = this.domain?.ui?.name || system.get('server.name');
|
||||
if (this.UiContext.extraTitleContent) return `${this.translate(str)} - ${this.UiContext.extraTitleContent} - ${name}`;
|
||||
|
||||
Reference in new issue
Block a user