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 = {
data: ctx.body,
};
return;
}
} else {
if (ctx.body) {
const { rows, ...meta } = ctx.body;
if (ctx.body) {
const { rows, ...meta } = ctx.body;
if (rows) {
ctx.body = {
data: rows,
meta,
};
} else {
ctx.body = {
data: ctx.body,
};
if (rows) {
ctx.body = {
data: rows,
meta,
};
} else {
if (ctx.bodyMeta) {
ctx.body.meta = ctx.bodyMeta;
}
}
} else if (ctx.action) {
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) {