refactor(multiple): 优化多个 React Native 宿主的加载逻辑
- 修改 MultipleReactActivityDelegate 中的 loadApp 方法,使用动态传递的 mainComponentName - 在 BuzActivity 中添加处理 React Host 生命周期状态的注释代码 -调整 MainApplication 中的 JS 主模块名和 Bundle 资源名的获取逻辑 - 修改 package.json 中 common bundle 的构建配置,关闭压缩并开启缓存重置
这个提交包含在:
父节点
054077f19d
当前提交
205e4e8680
@ -32,7 +32,14 @@ class BuzActivity : ReactActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
AppManager.addActivity(this)
|
||||
Toast.makeText(this, "BuzActivity:" + NavigationHelper.routerName, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this, "BuzActivity:" + NavigationHelper.routerName, Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
// if (reactHost.lifecycleState != LifecycleState.RESUMED) {
|
||||
// reactHost.onHostResume(this)
|
||||
// }
|
||||
// Handler(Looper.getMainLooper()).post {
|
||||
// reactHost.reload("Requested by CodeUpdater")
|
||||
// }
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
||||
@ -23,20 +23,23 @@ class MainApplication : Application(), ReactApplication {
|
||||
add(NavigationPackage())
|
||||
}
|
||||
|
||||
//
|
||||
// override fun getJSMainModuleName(): String =
|
||||
// if (getUseDeveloperSupport()) "index" else "commom"
|
||||
//
|
||||
// override fun getBundleAssetName(): String? =
|
||||
// if (getUseDeveloperSupport()) "index.android.bundle" else null
|
||||
override fun getJSMainModuleName(): String =
|
||||
if (getUseDeveloperSupport()) "index" else "commom"
|
||||
|
||||
override fun getBundleAssetName(): String? =
|
||||
if (getUseDeveloperSupport()) "index.android.bundle" else null
|
||||
|
||||
//
|
||||
// override fun getJSBundleFile(): String? = if (getUseDeveloperSupport()) {
|
||||
// super.getJSBundleFile()
|
||||
// } else {
|
||||
// FileHelper.getFilePath("common.android.bundle", this@MainApplication, "bundles")
|
||||
// }
|
||||
override fun getJSBundleFile(): String =
|
||||
override fun getJSBundleFile(): String? = if (getUseDeveloperSupport()) {
|
||||
null
|
||||
} else {
|
||||
FileHelper.getFilePath("common.android.bundle", this@MainApplication, "bundles")
|
||||
}
|
||||
|
||||
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ class MultipleReactActivityDelegate(
|
||||
),
|
||||
)
|
||||
|
||||
this.loadApp("app")
|
||||
this.loadApp(mainComponentName)
|
||||
} else {
|
||||
this.mReactDelegate =
|
||||
object : ReactDelegate(
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户