From 17582e9351882c46216e47f17e59ec168f945926 Mon Sep 17 00:00:00 2001 From: chenos Date: Sun, 3 Nov 2024 17:09:12 +0800 Subject: [PATCH] fix(multi-app-manager): sub-app asynchronous quick start (#5571) --- .../src/server/server.ts | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-multi-app-manager/src/server/server.ts b/packages/plugins/@nocobase/plugin-multi-app-manager/src/server/server.ts index fb627fdf2d..769b302baf 100644 --- a/packages/plugins/@nocobase/plugin-multi-app-manager/src/server/server.ts +++ b/packages/plugins/@nocobase/plugin-multi-app-manager/src/server/server.ts @@ -13,7 +13,10 @@ import lodash from 'lodash'; import path from 'path'; import { ApplicationModel } from '../server'; -export type AppDbCreator = (app: Application, options?: Transactionable & { context?: any }) => Promise; +export type AppDbCreator = ( + app: Application, + options?: Transactionable & { context?: any; applicationModel?: ApplicationModel }, +) => Promise; export type AppOptionsFactory = (appName: string, mainApp: Application) => any; export type SubAppUpgradeHandler = (mainApp: Application) => Promise; @@ -189,17 +192,22 @@ export class PluginMultiAppManagerServer extends Plugin { appOptionsFactory: this.appOptionsFactory, }); - // create database - await this.appDbCreator(subApp, { - transaction, - context: options.context, - }); + const quickstart = async () => { + // create database + await this.appDbCreator(subApp, { + transaction, + applicationModel: model, + context: options.context, + }); - const startPromise = subApp.runCommand('start', '--quickstart'); + const startPromise = subApp.runCommand('start', '--quickstart'); - if (options?.context?.waitSubAppInstall) { - await startPromise; - } + if (options?.context?.waitSubAppInstall) { + await startPromise; + } + }; + + quickstart(); }, );