(#45) Optimize Modular loading performance

This commit is contained in:
2022-01-20 11:52:10 +08:00
parent cf4dd727c5
commit 87f4d220e5
4 changed files with 55 additions and 10 deletions
+21
View File
@@ -491,6 +491,27 @@ class Manager<WXC extends AnyWXContext = AnyWXContext> {
})
}
/**
* 异步页面加载
*
* *注意*
* 页面模块加载后,必须手动执行 loadAllModule
* loadAllModule Modular 才会真正的被加载
* 模块加载后可以处理逻辑绑定
*/
public static async PageAsync(): Promise<{
manager: Manager<AnyWXContext>,
query: Record<string, string | undefined>
}> {
return new Promise((solve) => {
Page({
async onLoad(query) {
let manager = new Manager(this);
await solve({ manager, query });
}
})
});
}
}
export { Manager, Modular, AnyWXContext, WXContext, ILifetime}