fix(mobile): reset navigation stack when switching tab or searching

when it's a page view
This commit is contained in:
Tienson Qin
2025-12-02 11:42:06 +08:00
parent 5b52b68ae2
commit bf95e92ab2
4 changed files with 77 additions and 36 deletions

View File

@@ -134,6 +134,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UINavigationControllerDel
// MARK: Navigation operations
// ---------------------------------------------------------
private func emptyNavStack(path: String) {
let path = normalizedPath(path)
guard let nav = navController else { return }
ignoreRoutePopCount = 0
popSnapshotView?.removeFromSuperview()
popSnapshotView = nil
let vc = NativePageViewController(path: path, push: false)
pathStack = [path]
nav.setViewControllers([vc], animated: false)
SharedWebViewController.instance.clearPlaceholder()
SharedWebViewController.instance.attach(to: vc)
}
private func pushIfNeeded(path: String, animated: Bool) {
let path = normalizedPath(path)
guard let nav = navController else { return }
@@ -317,6 +333,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UINavigationControllerDel
let navigationType = (notification.userInfo?["navigationType"] as? String) ?? "push"
switch navigationType {
case "reset":
self.emptyNavStack(path: path)
case "replace":
self.replaceTop(path: path)