@@ -7,46 +7,33 @@ TBD - created by archiving change enhance-navigation-view. Update Purpose after
77The framework SHALL provide an ` INavigationService ` abstraction that enables programmatic navigation with interception capabilities across all hosts.
88
99#### Scenario: Navigate to a registered view
10- - ** WHEN** a module calls ` NavigateToAsync(navigationKey) `
11- - ** THEN** the navigation service resolves the target view/viewmodel
12- - ** AND** the content area displays the corresponding view
10+ - ** WHEN** 模块调用 ` NavigateToAsync(navigationKey) `
11+ - ** THEN** 导航服务基于稳定 ` navigationKey ` 解析目标(而不是运行时全域扫描 Type)
12+ - ** AND** 解析结果包含:所属模块、目标 View(或 Route)、目标 ViewModel、实例生命周期策略
13+ - ** AND** 内容区域显示对应 View
1314
1415#### Scenario: Navigate with typed ViewModel
15- - ** WHEN** a module calls ` NavigateToAsync<TViewModel>() `
16- - ** THEN** the navigation service resolves TViewModel
17- - ** AND** creates or retrieves the view instance based on lifecycle settings
18- - ** AND** the content area displays the view
16+ - ** WHEN** 模块调用 ` NavigateToAsync<TViewModel>() `
17+ - ** THEN** 导航服务通过注册表/约定映射解析 ` TViewModel ` 对应的 ` navigationKey `
18+ - ** AND** 导航行为与 ` NavigateToAsync(navigationKey) ` 等价
1919
2020#### Scenario: Navigation exposes current state
21- - ** WHEN** navigation completes successfully
22- - ** THEN** ` CurrentNavigationKey ` reflects the active navigation target
23- - ** AND** the ` Navigated ` event is raised with navigation details
21+ - ** WHEN** 导航成功完成
22+ - ** THEN** ` CurrentNavigationKey ` 反映当前激活的 ` navigationKey `
23+ - ** AND** ` Navigated ` event MUST 被触发,且包含 ` FromKey/ToKey ` 与可选的 ` View/ViewModel ` 实例
2424
2525### Requirement: Navigation Guards
2626The framework SHALL support registration of navigation guards that can intercept and conditionally prevent navigation.
2727
2828#### Scenario: Guard prevents navigation from current page
29- - ** WHEN** user triggers navigation to a new page
30- - ** AND** a registered guard's ` CanNavigateFromAsync ` returns false
31- - ** THEN** the navigation is cancelled
32- - ** AND** the current view remains displayed
33- - ** AND** no ` Navigated ` event is raised
29+ - ** WHEN** 用户触发从 A 到 B 的导航
30+ - ** AND** 任一 guard 的 ` CanNavigateFromAsync ` 返回 false
31+ - ** THEN** 导航取消,当前视图保持不变
3432
3533#### Scenario: Guard prevents navigation to target page
36- - ** WHEN** user triggers navigation to a new page
37- - ** AND** a registered guard's ` CanNavigateToAsync ` returns false
38- - ** THEN** the navigation is cancelled
39- - ** AND** the current view remains displayed
40-
41- #### Scenario: Multiple guards are evaluated
42- - ** WHEN** multiple guards are registered
43- - ** THEN** all guards are evaluated sequentially
44- - ** AND** navigation proceeds only if all guards return true
45-
46- #### Scenario: Guard receives navigation context
47- - ** WHEN** a guard is invoked
48- - ** THEN** it receives ` NavigationContext ` containing source key, target key, and options
49- - ** AND** can make decisions based on this context
34+ - ** WHEN** 用户触发从 A 到 B 的导航
35+ - ** AND** 任一 guard 的 ` CanNavigateToAsync ` 返回 false
36+ - ** THEN** 导航取消,当前视图保持不变
5037
5138### Requirement: Page Instance Lifecycle
5239The framework SHALL support configurable page instance modes that control whether views are reused or recreated on each navigation.
@@ -325,3 +312,45 @@ Home 主页 SHALL 提供"快速创建模块"入口,方便用户快速开始开
325312- ** THEN** 打开模块创建向导对话框
326313- ** OR** 跳转到模块开发文档页面(如果向导未实现)
327314
315+ ### Requirement: ViewModel Navigation Lifecycle
316+ The framework SHALL provide ViewModel-level navigation interception and lifecycle hooks that can be overridden without extra registration code.
317+
318+ #### Scenario: ViewModel can intercept NavigateFrom
319+ - ** GIVEN** 当前 ViewModel 支持导航拦截(通过继承基类或实现接口)
320+ - ** WHEN** 从当前页面导航到新页面
321+ - ** THEN** 框架调用 ` CanNavigateFromAsync(context) `
322+ - ** AND** 若返回 false,则导航被取消
323+
324+ #### Scenario: ViewModel can intercept NavigateTo
325+ - ** GIVEN** 目标 ViewModel 支持导航拦截(通过继承基类或实现接口)
326+ - ** WHEN** 导航到目标页面
327+ - ** THEN** 框架调用 ` CanNavigateToAsync(context) `
328+ - ** AND** 若返回 false,则导航被取消且不改变当前页面
329+
330+ #### Scenario: ViewModel receives lifecycle callbacks
331+ - ** WHEN** 导航从 A 切换到 B 成功完成
332+ - ** THEN** 框架调用 A 的 ` OnNavigatedFromAsync(context) `
333+ - ** AND** 调用 B 的 ` OnNavigatedToAsync(context) ` (包含参数)
334+
335+ ### Requirement: Hierarchical Menu Navigation
336+ Navigation menus SHALL support a two-level hierarchy where module menus are top-level and view menus are second-level when the module contains multiple views.
337+
338+ #### Scenario: Single-view module shows only module menu
339+ - ** GIVEN** 某模块仅包含 1 个 View(可导航页面)
340+ - ** AND** 该 View 仍声明了 View 级菜单元数据
341+ - ** WHEN** 导航菜单渲染
342+ - ** THEN** 主导航仅显示模块级菜单项(名称来自模块级菜单声明)
343+ - ** AND** 不显示二级 View 菜单
344+
345+ #### Scenario: Multi-view module shows module menu and view children
346+ - ** GIVEN** 某模块包含多个 View(可导航页面)
347+ - ** WHEN** 导航菜单渲染
348+ - ** THEN** 主导航显示模块级菜单项(名称来自模块级菜单声明)
349+ - ** AND** 该菜单项包含二级子项,每个子项名称来自对应 View 的菜单声明
350+
351+ #### Scenario: Multi-view module parent menu expands only
352+ - ** GIVEN** 某模块包含多个 View(可导航页面)
353+ - ** WHEN** 用户点击模块级父菜单项
354+ - ** THEN** 菜单仅展开/收起以显示/隐藏子菜单
355+ - ** AND** 不触发导航(父菜单项不包含可导航的 ` NavigationKey ` )
356+
0 commit comments