mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: optimize problem_list pjax
This commit is contained in:
1 parent
48564767ca
commit
594e97194b
1 file changed
+3
-5
@@ -139,7 +139,8 @@ const defaultSearch = async (domainId: string, q: string, options?: ProblemSearc
|
|||||||
export class ProblemMainHandler extends Handler {
|
export class ProblemMainHandler extends Handler {
|
||||||
@param('page', Types.PositiveInt, true)
|
@param('page', Types.PositiveInt, true)
|
||||||
@param('q', Types.Content, 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';
|
this.response.template = 'problem_main.html';
|
||||||
// eslint-disable-next-line @typescript-eslint/no-shadow
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
||||||
const query = buildQuery(this.user);
|
const query = buildQuery(this.user);
|
||||||
@@ -203,7 +204,7 @@ export class ProblemMainHandler extends Handler {
|
|||||||
).then((res) => Object.assign(psdict, res))),
|
).then((res) => Object.assign(psdict, res))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.request.json) {
|
if (pjax) {
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
title: this.renderTitle(this.translate('problem_main')),
|
title: this.renderTitle(this.translate('problem_main')),
|
||||||
fragments: (await Promise.all([
|
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_stat.html', { pcount, pcountRelation }),
|
||||||
this.renderHTML('partials/problem_lucky.html', { qs: q }),
|
this.renderHTML('partials/problem_lucky.html', { qs: q }),
|
||||||
])).map((i) => ({ html: i })),
|
])).map((i) => ({ html: i })),
|
||||||
raw: {
|
|
||||||
page, pcount, ppcount, pdocs, psdict, category,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
|
|||||||
Reference in new issue
Block a user