core: fix pjax page

This commit is contained in:
undefined committed 2022-11-30 15:36:01 +08:00
1 parent 4cead20f0f
commit a364519a2e
3 files changed
+7 -6

No files matched your search

@@ -21,7 +21,11 @@ export default (logger) => async (ctx: KoaContext, next) => {
response.body.url = response.redirect;
}
if (!response.type) {
if (
if (response.pjax && args.pjax) {
const html = await ctx.renderHTML(response.pjax, response.body);
response.body = { fragments: [{ html }] };
response.type = 'application/json';
} else if (
request.json || response.redirect
|| request.query.noTemplate || !response.template) {
// Send raw data
@@ -35,9 +39,6 @@ export default (logger) => async (ctx: KoaContext, next) => {
response.body = new SystemError('Serialize failure', e.message);
}
response.type = 'application/json';
} else if (response.pjax && args.pjax) {
const html = await ctx.renderHTML(response.pjax, response.body);
response.body = { fragments: [{ html }] };
} else if (response.template) {
const s = response.template.split('.');
let templateName = `${s[0]}.${args.domainId}.${s[1]}`;