mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 05:46:00 +00:00
feat: demo env disable create/update/destroy actions
This commit is contained in:
parent
b6e41a6e45
commit
988b265bb8
@ -119,6 +119,26 @@ api.registerPlugin('plugin-file-manager', [path.resolve(__dirname, '../../../plu
|
||||
|
||||
(async () => {
|
||||
await api.loadPlugins();
|
||||
|
||||
api.resourcer.use(async (ctx, next) => {
|
||||
if (process.env.NOCOBASE_ENV !== 'demo') {
|
||||
return next();
|
||||
}
|
||||
const currentUser = ctx.state.currentUser;
|
||||
if (currentUser && currentUser.username === 'admin') {
|
||||
return next();
|
||||
}
|
||||
const { actionName } = ctx.action.params;
|
||||
if (['create', 'update', 'destroy'].includes(actionName)) {
|
||||
ctx.body = {
|
||||
data: {},
|
||||
meta: {},
|
||||
};
|
||||
return;
|
||||
}
|
||||
await next();
|
||||
});
|
||||
|
||||
await api.database.getModel('collections').load({skipExisting: true});
|
||||
api.listen(process.env.HTTP_PORT, () => {
|
||||
console.log(`http://localhost:${process.env.HTTP_PORT}/`);
|
||||
|
@ -18,7 +18,7 @@ export default async (ctx, next) => {
|
||||
const fields = await collection.getFields();
|
||||
const actions = await collection.getActions();
|
||||
const actionNames = view.options.actionNames||[];
|
||||
console.log(view.options);
|
||||
// console.log(view.options);
|
||||
if (view.type === 'table') {
|
||||
const defaultTabs = await collection.getTabs({
|
||||
where: {
|
||||
|
@ -223,7 +223,7 @@ export default {
|
||||
interface: 'radio',
|
||||
type: 'virtual',
|
||||
name: 'defaultPerPage',
|
||||
title: '每页显示几行数据',
|
||||
title: '默认每页显示几行数据',
|
||||
defaultValue: 50,
|
||||
dataSource: [
|
||||
{label: '10', value: 10},
|
||||
|
@ -291,7 +291,7 @@ export default async (ctx, next) => {
|
||||
}
|
||||
if (field.get('interface') === 'subTable') {
|
||||
const children = await field.getChildren();
|
||||
console.log(children);
|
||||
// console.log(children);
|
||||
for (const child of children) {
|
||||
if (!['subTable', 'linkTo', 'attachment', 'updatedBy', 'createdBy'].includes(child.get('interface'))) {
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user