fix(server): fix messages in data-wrapping (#3485)

This commit is contained in:
Junyi 2024-02-03 10:37:28 +08:00 committed by GitHub
parent 33edd78531
commit 237c4aa084
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,30 +31,29 @@ export function dataWrapping() {
ctx.body = { ctx.body = {
data: ctx.body, data: ctx.body,
}; };
return; } else {
} if (ctx.body) {
const { rows, ...meta } = ctx.body;
if (ctx.body) { if (rows) {
const { rows, ...meta } = ctx.body; ctx.body = {
data: rows,
meta,
};
} else {
ctx.body = {
data: ctx.body,
};
if (rows) { if (ctx.bodyMeta) {
ctx.body = { ctx.body.meta = ctx.bodyMeta;
data: rows, }
meta, }
}; } else if (ctx.action) {
} else {
ctx.body = { ctx.body = {
data: ctx.body, data: ctx.body,
}; };
if (ctx.bodyMeta) {
ctx.body.meta = ctx.bodyMeta;
}
} }
} else if (ctx.action) {
ctx.body = {
data: ctx.body,
};
} }
if (ctx.body && ctx.state.messages?.length) { if (ctx.body && ctx.state.messages?.length) {