mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 07:01:24 +00:00
!46087 元服务分包路由先更新路由表然后触发pushpath,修复概率性因时序导致的页面无法跳转问题
Merge pull request !46087 from 连漪/master
This commit is contained in:
commit
63ee943cda
@ -54,11 +54,6 @@ void NavigationRouteOhos::InitRouteMap()
|
||||
moduleInfos_ = bundleInfo.hapModuleInfos;
|
||||
}
|
||||
|
||||
void NavigationRouteOhos::OnPackageChange()
|
||||
{
|
||||
InitRouteMap();
|
||||
}
|
||||
|
||||
bool NavigationRouteOhos::GetRouteItem(const std::string& name, NG::RouteItem& info)
|
||||
{
|
||||
AppExecFwk::RouterItem routeItem;
|
||||
|
@ -43,13 +43,12 @@ public:
|
||||
int32_t LoadPage(const std::string& name) override;
|
||||
|
||||
bool IsNavigationItemExits(const std::string& name) override;
|
||||
|
||||
void OnPackageChange() override;
|
||||
|
||||
void InitRouteMap() override;
|
||||
|
||||
private:
|
||||
bool GetRouteItemFromBundle(const std::string& name, AppExecFwk::RouterItem& routeItem);
|
||||
int32_t LoadPageFromHapModule(const std::string& name);
|
||||
void InitRouteMap();
|
||||
sptr<AppExecFwk::IBundleMgr> GetBundleManager();
|
||||
AppExecFwk::RouterItem GetRouteItem(const std::string name);
|
||||
std::vector<AppExecFwk::RouterItem> allRouteItems_;
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
static int32_t SilentInstall(const std::string& moduleName, const std::function<void()>& callback,
|
||||
const std::function<void(int32_t, const std::string&)>& silentInstallErrorCallBack);
|
||||
static bool IsHspExist(const std::string& moduleName, const std::string& pathName);
|
||||
static void InitRouteMap();
|
||||
|
||||
private:
|
||||
static OHOS::sptr<OHOS::AppExecFwk::IBundleMgr> GetBundleManager();
|
||||
|
@ -26,6 +26,7 @@ class HspSilentInstallNapi {
|
||||
public:
|
||||
static napi_value SilentInstall(napi_env env, napi_callback_info info);
|
||||
static napi_value IsHspExist(napi_env env, napi_callback_info info);
|
||||
static napi_value InitRouteMap(napi_env env, napi_callback_info info);
|
||||
|
||||
private:
|
||||
struct CallbackData {
|
||||
|
@ -34,6 +34,7 @@ export class NavPushPathHelper {
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
navPushPathHelperApi.silentInstall(moduleName, () => {
|
||||
navPushPathHelperApi.initRouteMap();
|
||||
this.navPathStack_?.pushPath(info, optionParam);
|
||||
resolve();
|
||||
},
|
||||
@ -53,6 +54,7 @@ export class NavPushPathHelper {
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
navPushPathHelperApi.silentInstall(moduleName, () => {
|
||||
navPushPathHelperApi.initRouteMap();
|
||||
this.navPathStack_?.pushDestination(info, optionParam)
|
||||
.then(resolve).catch(reject);
|
||||
}, (error) => {
|
||||
@ -71,6 +73,7 @@ export class NavPushPathHelper {
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
navPushPathHelperApi.silentInstall(moduleName, () => {
|
||||
navPushPathHelperApi.initRouteMap();
|
||||
this.navPathStack_?.pushPathByName(name, param, onPop, optionParam);
|
||||
resolve();
|
||||
}, (error) => {
|
||||
@ -89,6 +92,7 @@ export class NavPushPathHelper {
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
navPushPathHelperApi.silentInstall(moduleName, () => {
|
||||
navPushPathHelperApi.initRouteMap();
|
||||
this.navPathStack_?.pushDestinationByName(name, param, onPop, optionParam)
|
||||
.then(resolve).catch(reject);
|
||||
}, (error) => {
|
||||
@ -107,6 +111,7 @@ export class NavPushPathHelper {
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
navPushPathHelperApi.silentInstall(moduleName, () => {
|
||||
navPushPathHelperApi.initRouteMap();
|
||||
this.navPathStack_?.replacePath(info, optionParam);
|
||||
resolve();
|
||||
}, (error) => {
|
||||
@ -125,6 +130,8 @@ export class NavPushPathHelper {
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
navPushPathHelperApi.silentInstall(moduleName, () => {
|
||||
hilog.info(0x3900, tag, `silentInstall success`);
|
||||
navPushPathHelperApi.initRouteMap();
|
||||
this.navPathStack_?.replacePathByName(name, param, optionParam);
|
||||
resolve();
|
||||
}, (error) => {
|
||||
|
@ -105,4 +105,13 @@ bool HspSilentInstall::IsHspExist(const std::string &moduleName, const std::stri
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void HspSilentInstall::InitRouteMap()
|
||||
{
|
||||
auto container = OHOS::Ace::Container::CurrentSafely();
|
||||
CHECK_NULL_VOID(container);
|
||||
auto navigationRoute = container->GetNavigationRoute();
|
||||
CHECK_NULL_VOID(navigationRoute);
|
||||
navigationRoute->InitRouteMap();
|
||||
}
|
||||
} // namespace OHOS::NavPushPathHelper
|
@ -56,6 +56,12 @@ napi_value HspSilentInstallNapi::IsHspExist(napi_env env, napi_callback_info inf
|
||||
return jsResult;
|
||||
}
|
||||
|
||||
napi_value HspSilentInstallNapi::InitRouteMap(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HspSilentInstall::InitRouteMap();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value HspSilentInstallNapi::SilentInstall(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value result = nullptr;
|
||||
|
@ -34,6 +34,7 @@ namespace OHOS::NavPushPathHelper {
|
||||
napi_property_descriptor desc[] = {
|
||||
DECLARE_NAPI_FUNCTION("silentInstall", HspSilentInstallNapi::SilentInstall),
|
||||
DECLARE_NAPI_FUNCTION("isHspExist", HspSilentInstallNapi::IsHspExist),
|
||||
DECLARE_NAPI_FUNCTION("initRouteMap", HspSilentInstallNapi::InitRouteMap),
|
||||
};
|
||||
NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc));
|
||||
return exports;
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "core/components_ng/pattern/navigation/navigation_declaration.h"
|
||||
#include "core/components_ng/pattern/navigation/navigation_pattern.h"
|
||||
#include "core/components_ng/pattern/navigation/navigation_title_util.h"
|
||||
#include "core/event/package/package_event_proxy.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
namespace {
|
||||
@ -1048,14 +1047,6 @@ void NavigationGroupNode::OnAttachToMainTree(bool recursive)
|
||||
if (!findNavdestination) {
|
||||
pipelineContext->AddNavigationNode(pageId, WeakClaim(this));
|
||||
}
|
||||
auto* eventProxy = PackageEventProxy::GetInstance();
|
||||
if (eventProxy) {
|
||||
auto container = OHOS::Ace::Container::CurrentSafely();
|
||||
CHECK_NULL_VOID(container);
|
||||
auto navigationRoute = container->GetNavigationRoute();
|
||||
CHECK_NULL_VOID(navigationRoute);
|
||||
eventProxy->Register(WeakClaim(AceType::RawPtr(navigationRoute)));
|
||||
}
|
||||
}
|
||||
|
||||
void NavigationGroupNode::FireHideNodeChange(NavDestinationLifecycle lifecycle)
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <map>
|
||||
#include "base/memory/ace_type.h"
|
||||
#include "base/memory/referenced.h"
|
||||
#include "core/event/package/package_change_listener.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
using NavigationLoadPageCallback = std::function<int32_t(
|
||||
@ -34,8 +33,8 @@ struct RouteItem {
|
||||
std::map<std::string, std::string> data;
|
||||
};
|
||||
|
||||
class ACE_EXPORT NavigationRoute : public PackageChangeListener {
|
||||
DECLARE_ACE_TYPE(NavigationRoute, PackageChangeListener);
|
||||
class ACE_EXPORT NavigationRoute : public AceType {
|
||||
DECLARE_ACE_TYPE(NavigationRoute, AceType);
|
||||
public:
|
||||
NavigationRoute() = default;
|
||||
~NavigationRoute() = default;
|
||||
@ -65,7 +64,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
void OnPackageChange() override {}
|
||||
virtual void InitRouteMap() {}
|
||||
|
||||
protected:
|
||||
NavigationLoadPageCallback callback_;
|
||||
|
Loading…
Reference in New Issue
Block a user