tachybase_todo/packages/plugin-system-settings/src/plugin.ts
ChengLei Shao 81978711e4
featPlugin multiple apps (#248)
* feat: multiple apps plugin

* feat: multipleAppManager in Application

* stage

* fix: export error

* test: multiple app

* application model

* feat: create application with plugins

* load and install after sub application created

* create subApp database beforeInstall

* sub apps listen to main app start & stop events

* refactor: getPluginName as package name

* feat: load apps on mainApp starts

* fix: test

* feat: beforeGetApplication event

* fix: test

* fix: test with sqlite memory database

* test: lazyLoad application

* fix: test with sqlite memory

* chore: clone database collection & promise.all
2022-03-28 22:01:10 +08:00

39 lines
931 B
TypeScript

import { skip } from '@nocobase/acl';
import { Plugin } from '@nocobase/server';
import { resolve } from 'path';
export class SystemSettingsPlugin extends Plugin {
async install() {
await this.db.getRepository('systemSettings').create({
values: {
title: 'NocoBase',
logo: {
title: 'nocobase-logo',
filename: '682e5ad037dd02a0fe4800a3e91c283b.png',
extname: '.png',
mimetype: 'image/png',
url: 'https://nocobase.oss-cn-beijing.aliyuncs.com/682e5ad037dd02a0fe4800a3e91c283b.png',
},
},
});
}
async load() {
await this.app.db.import({
directory: resolve(__dirname, 'collections'),
});
this.app.acl.use(
skip({
resourceName: 'systemSettings',
actionName: 'get',
}),
);
}
getName(): string {
return this.getPackageName(__dirname);
}
}
export default SystemSettingsPlugin;