mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2026-11-24 03:37:47 +08:00
refactor(desktop): 页面切换统一走 INavigationService
侧栏原先是在 MainWindow.axaml.cs 里用一个针对 ListBox.SelectedIndex 的 switch 接起来的,直接调 App.Services.GetRequiredService<...> 从 code-behind 赋页面。 NavigationService 存在、已注册,却从没被用过。 后果:首页的深层链接无法改变侧栏选中项;新增一个页面要同时改 view model 和 code-behind;每个页面即使该是单例也会被重新构造。 现在: - INavigationService 增加 NavigateRoot<T>(),用于"跳到顶层页面"(清空回退栈), 与已有的 NavigateTo<T>()、GoBack() 并存。 - MainWindowViewModel 订阅 NavigationChanged,把当前 view model 反映射成侧栏 索引,因此从首页卡片跳转时侧栏高亮会跟着走。 - MainWindow.axaml.cs 基本清空;ListBox 绑索引,导航由 view model 发起。 这个提交里两处对话框服务的新增是给后面页面用的: - ShowFilesPickerAsync —— 多选,解密页需要 - ShowQrCodeLoginDialogAsync —— 把网易云二维码对话框作为模态窗口承载 - ShowMessageAsync 补进接口。它早已实现、也早已被调用,只是没写进契约。
This commit is contained in:
1 parent
9cda87dbfe
commit
216ea4e0c4
8 files changed
+239
-46
No files matched your search
@@ -1,9 +1,23 @@
|
||||
using ZonyLrcTools.Desktop.ViewModels;
|
||||
|
||||
namespace ZonyLrcTools.Desktop.Services;
|
||||
|
||||
public interface IDialogService
|
||||
{
|
||||
Task<string?> ShowFolderPickerAsync(string title);
|
||||
|
||||
Task<string?> ShowFilePickerAsync(string title, string[]? filters = null);
|
||||
|
||||
Task<IReadOnlyList<string>> ShowFilesPickerAsync(string title, string[]? filters = null);
|
||||
|
||||
Task<bool> ShowConfirmDialogAsync(string title, string message);
|
||||
|
||||
Task ShowMessageAsync(string title, string message);
|
||||
|
||||
/// <summary>
|
||||
/// Open the NetEase QR-code login dialog as a modal child of the main window.
|
||||
/// The returned task completes when the user or the login flow closes it; callers that
|
||||
/// only want the dialog on screen can ignore it.
|
||||
/// </summary>
|
||||
Task ShowQrCodeLoginDialogAsync(QrCodeLoginViewModel viewModel);
|
||||
}
|
||||
Reference in new issue
Block a user