tachybase_todo/packages/plugins/multi-app-manager/src/server/models/application.ts

29 lines
830 B
TypeScript
Raw Normal View History

import { Model, Transactionable } from '@nocobase/database';
import { Application } from '@nocobase/server';
import { AppOptionsFactory } from '../server';
export interface registerAppOptions extends Transactionable {
skipInstall?: boolean;
appOptionsFactory: AppOptionsFactory;
}
export class ApplicationModel extends Model {
registerToMainApp(mainApp: Application, options: registerAppOptions) {
const appName = this.get('name') as string;
const appOptions = (this.get('options') as any) || {};
const subAppOptions = {
...options.appOptionsFactory(appName, mainApp),
...appOptions,
2023-02-16 09:46:23 +08:00
name: appName,
};
const subApp = new Application(subAppOptions);
mainApp.appManager.addSubApp(subApp);
2022-04-30 23:41:01 +08:00
console.log(`register application ${appName} to main app`);
return subApp;
}
}