core: optimize problem_list pjax

This commit is contained in:
undefined committed 2022-08-18 21:57:46 +08:00
1 parent 48564767ca
commit 594e97194b
1 file changed
+3 -5
+3 -5
View File
@@ -139,7 +139,8 @@ const defaultSearch = async (domainId: string, q: string, options?: ProblemSearc
export class ProblemMainHandler extends Handler {
@param('page', Types.PositiveInt, true)
@param('q', Types.Content, true)
async get(domainId: string, page = 1, q = '') {
@param('pjax', Types.Boolean)
async get(domainId: string, page = 1, q = '', pjax = false) {
this.response.template = 'problem_main.html';
// eslint-disable-next-line @typescript-eslint/no-shadow
const query = buildQuery(this.user);
@@ -203,7 +204,7 @@ export class ProblemMainHandler extends Handler {
).then((res) => Object.assign(psdict, res))),
);
}
if (this.request.json) {
if (pjax) {
this.response.body = {
title: this.renderTitle(this.translate('problem_main')),
fragments: (await Promise.all([
@@ -213,9 +214,6 @@ export class ProblemMainHandler extends Handler {
this.renderHTML('partials/problem_stat.html', { pcount, pcountRelation }),
this.renderHTML('partials/problem_lucky.html', { qs: q }),
])).map((i) => ({ html: i })),
raw: {
page, pcount, ppcount, pdocs, psdict, category,
},
};
} else {
this.response.body = {