chore: lazy load sub app in share collection (#1569)
This commit is contained in:
parent
3cf06be893
commit
2de165c1eb
@ -99,7 +99,7 @@ pgOnly()('collection sync', () => {
|
||||
|
||||
const sub1 = await mainApp.appManager.getApplication('sub1');
|
||||
|
||||
const getSub1MapRecord = async (app) => {
|
||||
const getSubAppMapRecord = async (app) => {
|
||||
return await app.db.getRepository('applicationPlugins').findOne({
|
||||
filter: {
|
||||
name: 'map',
|
||||
@ -107,10 +107,10 @@ pgOnly()('collection sync', () => {
|
||||
});
|
||||
};
|
||||
|
||||
expect((await getSub1MapRecord(sub1)).get('enabled')).toBeFalsy();
|
||||
expect((await getSubAppMapRecord(sub1)).get('enabled')).toBeFalsy();
|
||||
await mainApp.pm.enable('map');
|
||||
|
||||
expect((await getSub1MapRecord(sub1)).get('enabled')).toBeTruthy();
|
||||
expect((await getSubAppMapRecord(sub1)).get('enabled')).toBeTruthy();
|
||||
|
||||
await mainApp.db.getRepository('applications').create({
|
||||
values: {
|
||||
@ -119,7 +119,7 @@ pgOnly()('collection sync', () => {
|
||||
});
|
||||
|
||||
const sub2 = await mainApp.appManager.getApplication('sub2');
|
||||
expect((await getSub1MapRecord(sub2)).get('enabled')).toBeTruthy();
|
||||
expect((await getSubAppMapRecord(sub2)).get('enabled')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should not sync roles in sub app', async () => {
|
||||
|
@ -194,14 +194,6 @@ export class MultiAppShareCollectionPlugin extends Plugin {
|
||||
return;
|
||||
}
|
||||
|
||||
// 应用加载完之后,需要将子应用全部载入到内存中
|
||||
this.app.on('afterLoad', async () => {
|
||||
const subApplications = await this.db.getRepository('applications').find();
|
||||
for (const subApplication of subApplications) {
|
||||
await this.app.appManager.getApplication(subApplication.name);
|
||||
}
|
||||
});
|
||||
|
||||
this.app.on('beforeSubAppInstall', async ({ subApp }) => {
|
||||
const subAppPluginsCollection = subApp.db.getCollection('applicationPlugins');
|
||||
const mainAppPluginsCollection = this.app.db.getCollection('applicationPlugins');
|
||||
|
Loading…
Reference in New Issue
Block a user