feat: plugin-disable-pm-add-online (#2918)

This commit is contained in:
chenos 2023-10-26 16:13:59 +08:00 committed by GitHub
parent a1c425f733
commit 568b12a537
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,2 @@
/node_modules
/src

View File

@ -0,0 +1,2 @@
export * from './dist/client';
export { default } from './dist/client';

View File

@ -0,0 +1 @@
module.exports = require('./dist/client/index.js');

View File

@ -0,0 +1,11 @@
{
"name": "@nocobase/plugin-disable-pm-add",
"version": "0.14.0-alpha.7",
"main": "./dist/server/index.js",
"peerDependencies": {
"@nocobase/client": "0.x",
"@nocobase/server": "0.x",
"@nocobase/test": "0.x"
},
"gitHead": "ee5825377d8bec05f968a8365a0cdcd49878ada6"
}

View File

@ -0,0 +1,2 @@
export * from './dist/server';
export { default } from './dist/server';

View File

@ -0,0 +1 @@
module.exports = require('./dist/server/index.js');

View File

@ -0,0 +1,7 @@
import { Plugin } from '@nocobase/client';
class PluginDisablePmAddClient extends Plugin {
async load() {}
}
export default PluginDisablePmAddClient;

View File

@ -0,0 +1,2 @@
export * from './server';
export { default } from './server';

View File

@ -0,0 +1,27 @@
import { InstallOptions, Plugin } from '@nocobase/server';
export class PluginDisablePmAddServer extends Plugin {
beforeLoad() {
// TODO
}
async load() {
this.app.resourcer.use(async (ctx, next) => {
const { resourceName, actionName } = ctx.action;
if (resourceName === 'pm' && actionName === 'add') {
ctx.throw(403, 'The current environment does not allow adding plugins online');
}
await next();
});
}
async disable() {
// this.app.resourcer.removeResource('testHello');
}
async install(options: InstallOptions) {
// TODO
}
}
export default PluginDisablePmAddServer;