修复 Tab 导航栈路径绑定,确保子页面 push 后立即响应。

直接观察 RouterPath 并绑定 NavigationStack,移除未使用的 AppTab/AppRouter 辅助 API。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-29 11:45:34 +08:00
parent 8e34a45d50
commit d310d26293
5 changed files with 24 additions and 32 deletions

View File

@ -141,7 +141,17 @@ private struct TabNavigationStackHost: View {
let tab: AppTab
var body: some View {
NavigationStack(path: appRouter.binding(for: tab)) {
TabNavigationStackContent(tab: tab, router: appRouter.router(for: tab))
}
}
/// Tab RouterPath
private struct TabNavigationStackContent: View {
let tab: AppTab
@ObservedObject var router: RouterPath
var body: some View {
NavigationStack(path: $router.path) {
tab.rootView
.navigationTitle(tab.title)
.navigationDestination(for: AppRoute.self) { route in
@ -149,7 +159,7 @@ private struct TabNavigationStackHost: View {
.toolbar(route.hidesTabBarWhenPushed ? .hidden : .visible, for: .tabBar)
}
}
.environmentObject(appRouter.router(for: tab))
.environmentObject(router)
}
}