mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-04 05:08:42 +08:00
fix: dynamic action params
This commit is contained in:
parent
7fcce0943a
commit
a342c30175
@ -12,6 +12,8 @@ const sync = {
|
||||
},
|
||||
};
|
||||
|
||||
console.log('process.env.NOCOBASE_ENV', process.env.NOCOBASE_ENV);
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const api = Api.create({
|
||||
@ -35,7 +37,7 @@ const api = Api.create({
|
||||
},
|
||||
});
|
||||
|
||||
api.resourcer.use(async (ctx, next) => {
|
||||
api.resourcer.use(async (ctx: actions.Context, next) => {
|
||||
const { resourceName } = ctx.action.params;
|
||||
const table = ctx.db.getTable(resourceName);
|
||||
// ctx.state.developerMode = {[Op.not]: null};
|
||||
@ -43,6 +45,17 @@ api.resourcer.use(async (ctx, next) => {
|
||||
if (table && table.hasField('developerMode') && ctx.state.developerMode === false) {
|
||||
ctx.action.setParam('filter.developerMode', ctx.state.developerMode);
|
||||
}
|
||||
if (table) {
|
||||
const except = [];
|
||||
for (const [name, field] of table.getFields()) {
|
||||
if (field.options.hidden) {
|
||||
except.push(field.options.name);
|
||||
}
|
||||
}
|
||||
if (except.length) {
|
||||
ctx.action.setParam('fields.except', except);
|
||||
}
|
||||
}
|
||||
await next();
|
||||
});
|
||||
api.resourcer.use(associated);
|
||||
|
Loading…
Reference in New Issue
Block a user