From c22fc6f5d4f9f29b080f9be558e9fc6ed750fe74 Mon Sep 17 00:00:00 2001 From: ChengLei Shao Date: Wed, 3 Apr 2024 09:17:20 +0800 Subject: [PATCH] fix: list data undefined error (#3905) * fix: list data undefined error * chore: typo --- .../src/server/middlewares/with-acl-meta.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-acl/src/server/middlewares/with-acl-meta.ts b/packages/plugins/@nocobase/plugin-acl/src/server/middlewares/with-acl-meta.ts index 5af8e929d7..687c71c3be 100644 --- a/packages/plugins/@nocobase/plugin-acl/src/server/middlewares/with-acl-meta.ts +++ b/packages/plugins/@nocobase/plugin-acl/src/server/middlewares/with-acl-meta.ts @@ -37,8 +37,19 @@ function createWithACLMetaMiddleware() { // @ts-ignore const primaryKeyField = Model.primaryKeyField || Model.primaryKeyAttribute; - const dataPath = ctx.body?.rows ? 'body.rows' : 'body'; - let listData = lodash.get(ctx, dataPath); + let listData; + + if (ctx.body?.data) { + listData = ctx.data; + } else if (ctx.body?.rows) { + listData = ctx.body.rows; + } else if (ctx.body) { + listData = ctx.body; + } + + if (!listData) { + return; + } if (actionName == 'get') { listData = lodash.castArray(listData);