From 8ded721f463ba7367dd4b24400283eb42cfda358 Mon Sep 17 00:00:00 2001 From: lincube Date: Mon, 23 Mar 2026 12:14:56 +0800 Subject: [PATCH] 0.7.6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 加入删除页面二次确认 --- LanMountainDesktop/Localization/en-US.json | 4 +++ LanMountainDesktop/Localization/zh-CN.json | 4 +++ .../Views/MainWindow.ComponentSystem.cs | 29 ++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/LanMountainDesktop/Localization/en-US.json b/LanMountainDesktop/Localization/en-US.json index 846b9b5..bef6c3b 100644 --- a/LanMountainDesktop/Localization/en-US.json +++ b/LanMountainDesktop/Localization/en-US.json @@ -959,6 +959,10 @@ "study.interrupt_density.unavailable": "--", "desktop.add_page": "Add page", "desktop.delete_page": "Delete page", + "desktop.delete_page_confirm.title": "Confirm Delete Page", + "desktop.delete_page_confirm.message": "Are you sure you want to delete the current page?\n\nThis will remove all components on this page and cannot be undone.", + "desktop.delete_page_confirm.primary": "Delete", + "desktop.delete_page_confirm.close": "Cancel", "placement.fill": "Fill", "placement.fit": "Fit", "placement.stretch": "Stretch", diff --git a/LanMountainDesktop/Localization/zh-CN.json b/LanMountainDesktop/Localization/zh-CN.json index 84dd4d4..8843dfa 100644 --- a/LanMountainDesktop/Localization/zh-CN.json +++ b/LanMountainDesktop/Localization/zh-CN.json @@ -953,6 +953,10 @@ "study.interrupt_density.unavailable": "--", "desktop.add_page": "新增页面", "desktop.delete_page": "删除页面", + "desktop.delete_page_confirm.title": "确认删除页面", + "desktop.delete_page_confirm.message": "确定要删除当前页面吗?\n\n此操作将删除当前页面上的所有组件,且无法撤销。", + "desktop.delete_page_confirm.primary": "删除", + "desktop.delete_page_confirm.close": "取消", "placement.fill": "填充", "placement.fit": "适应", "placement.stretch": "拉伸", diff --git a/LanMountainDesktop/Views/MainWindow.ComponentSystem.cs b/LanMountainDesktop/Views/MainWindow.ComponentSystem.cs index 046b57e..b7ae167 100644 --- a/LanMountainDesktop/Views/MainWindow.ComponentSystem.cs +++ b/LanMountainDesktop/Views/MainWindow.ComponentSystem.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Shapes; @@ -10,6 +11,7 @@ using Avalonia.Layout; using Avalonia.Media; using Avalonia.Threading; using Avalonia.VisualTree; +using FluentAvalonia.UI.Controls; using FluentIcons.Avalonia; using FluentIcons.Common; using LanMountainDesktop.ComponentSystem; @@ -22,6 +24,8 @@ using LanMountainDesktop.Settings.Core; using LanMountainDesktop.Theme; using LanMountainDesktop.Views.Components; using PathShape = Avalonia.Controls.Shapes.Path; +using Symbol = FluentIcons.Common.Symbol; +using SymbolIcon = FluentIcons.Avalonia.SymbolIcon; namespace LanMountainDesktop.Views; @@ -826,7 +830,7 @@ public partial class MainWindow AddDesktopPage(); break; case "desktop.delete_page": - DeleteCurrentDesktopPage(); + ConfirmAndDeleteCurrentDesktopPage(); break; case "component.delete": DeleteSelectedComponent(); @@ -840,6 +844,29 @@ public partial class MainWindow } } + private async void ConfirmAndDeleteCurrentDesktopPage() + { + if (_desktopPageCount <= MinDesktopPageCount) + { + return; + } + + var dialog = new ContentDialog + { + Title = L("desktop.delete_page_confirm.title", "确认删除页面"), + Content = L("desktop.delete_page_confirm.message", "确定要删除当前页面吗?\n\n此操作将删除当前页面上的所有组件,且无法撤销。"), + PrimaryButtonText = L("desktop.delete_page_confirm.close", "取消"), + SecondaryButtonText = L("desktop.delete_page_confirm.primary", "删除"), + DefaultButton = ContentDialogButton.Primary + }; + + var result = await dialog.ShowAsync(this); + if (result == ContentDialogResult.Secondary) + { + DeleteCurrentDesktopPage(); + } + } + private void DeleteSelectedComponent() { if (_selectedDesktopComponentHost is null || _selectedDesktopComponentHost.Tag is not string placementId)