mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-08-19 03:33:24 +08:00
feat.PLONDS系统开发
This commit is contained in:
@@ -283,7 +283,9 @@
|
||||
Text="请选择一个专用文件夹。默认位置需要管理员权限,和现有安装方式保持一致。" />
|
||||
</StackPanel>
|
||||
|
||||
<Border Classes="content-card">
|
||||
<!-- 正常路径选择 UI(提权不需要时显示) -->
|
||||
<Border Classes="content-card"
|
||||
IsVisible="{Binding !IsElevationRequired}">
|
||||
<StackPanel Spacing="16">
|
||||
<StackPanel Spacing="6">
|
||||
<TextBlock Text="安装目录"
|
||||
@@ -313,6 +315,42 @@
|
||||
Content="开机时自动启动阑山桌面" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- Task 2: 自动提权提示 -->
|
||||
<Border Classes="content-card"
|
||||
IsVisible="{Binding IsElevationRequired}">
|
||||
<StackPanel Spacing="16">
|
||||
<StackPanel Spacing="6">
|
||||
<TextBlock Text="需要管理员权限"
|
||||
FontSize="16"
|
||||
FontWeight="SemiBold" />
|
||||
<TextBlock Text="{Binding ElevationMessage}"
|
||||
Classes="muted" />
|
||||
</StackPanel>
|
||||
<Border Classes="info-panel">
|
||||
<Grid ColumnDefinitions="Auto,*"
|
||||
ColumnSpacing="10">
|
||||
<TextBlock Classes="installer-icon"
|
||||
Text=""
|
||||
Foreground="{DynamicResource InstallerAccentBrush}"
|
||||
FontSize="18" />
|
||||
<TextBlock Grid.Column="1"
|
||||
Text="点击下方按钮将以管理员身份重新启动安装程序。安装程序将自动继续到下一步。"
|
||||
Classes="muted" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<Button Classes="primary-command"
|
||||
HorizontalAlignment="Left"
|
||||
Command="{Binding RelaunchElevatedCommand}">
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Spacing="6">
|
||||
<TextBlock Classes="installer-icon"
|
||||
Text="" />
|
||||
<TextBlock Text="以管理员身份重新启动" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
@@ -395,8 +433,15 @@
|
||||
<ProgressBar Minimum="0"
|
||||
Maximum="1"
|
||||
Value="{Binding DownloadProgress}" />
|
||||
<TextBlock Classes="caption-text"
|
||||
Text="{Binding DownloadBytesText}" />
|
||||
<Grid ColumnDefinitions="*,Auto"
|
||||
ColumnSpacing="12">
|
||||
<TextBlock Classes="caption-text"
|
||||
Text="{Binding DownloadBytesText}" />
|
||||
<TextBlock Grid.Column="1"
|
||||
Classes="caption-text"
|
||||
Text="{Binding DownloadSpeedText}"
|
||||
FontWeight="SemiBold" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Spacing="8">
|
||||
@@ -488,7 +533,7 @@
|
||||
<Border Grid.Row="1"
|
||||
Background="Transparent"
|
||||
Padding="36,16,42,18">
|
||||
<Grid ColumnDefinitions="*,Auto,Auto"
|
||||
<Grid ColumnDefinitions="*,Auto,Auto,Auto"
|
||||
ColumnSpacing="8">
|
||||
<Border Classes="error-bar"
|
||||
IsVisible="{Binding HasError}">
|
||||
@@ -515,14 +560,35 @@
|
||||
<TextBlock Text="上一步" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<!-- Task 1: 取消版本检查按钮(检查中显示) -->
|
||||
<Button Grid.Column="2"
|
||||
Classes="secondary-command"
|
||||
Command="{Binding CancelCheckCommand}"
|
||||
IsVisible="{Binding IsCheckingUpdate}">
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Spacing="6">
|
||||
<TextBlock Classes="installer-icon"
|
||||
Text="" />
|
||||
<TextBlock Text="取消" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Grid.Column="3"
|
||||
Classes="primary-command"
|
||||
Command="{Binding NextCommand}">
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Spacing="6">
|
||||
<TextBlock Text="下一步" />
|
||||
<!-- 正常状态:下一步 -->
|
||||
<TextBlock Text="下一步"
|
||||
IsVisible="{Binding !IsCheckingUpdate}" />
|
||||
<!-- 检查中状态 -->
|
||||
<TextBlock Text="检查中..."
|
||||
IsVisible="{Binding IsCheckingUpdate}" />
|
||||
<TextBlock Classes="installer-icon"
|
||||
Text="" />
|
||||
Text=""
|
||||
IsVisible="{Binding !IsCheckingUpdate}" />
|
||||
<TextBlock Classes="installer-icon"
|
||||
Text=""
|
||||
IsVisible="{Binding IsCheckingUpdate}" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Platform.Storage;
|
||||
using LanDesktopPLONDS.Installer.ViewModels;
|
||||
|
||||
@@ -22,6 +24,80 @@ public partial class MainWindow : Window
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Task 5: 安装进行中阻止关闭窗口,弹出中文确认对话框。
|
||||
/// </summary>
|
||||
protected override async void OnClosing(WindowClosingEventArgs e)
|
||||
{
|
||||
if (DataContext is not MainWindowViewModel { IsInstalling: true })
|
||||
{
|
||||
base.OnClosing(e);
|
||||
return;
|
||||
}
|
||||
|
||||
e.Cancel = true;
|
||||
var confirmed = await ShowCloseConfirmDialogAsync();
|
||||
if (confirmed)
|
||||
{
|
||||
if (DataContext is MainWindowViewModel vm)
|
||||
{
|
||||
vm.CancelInstallCommand.Execute(null);
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> ShowCloseConfirmDialogAsync()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
|
||||
var yesButton = new Button { Content = "确定退出", MinWidth = 100 };
|
||||
yesButton.Classes.Add("primary-command");
|
||||
yesButton.Click += (_, _) => tcs.TrySetResult(true);
|
||||
|
||||
var noButton = new Button { Content = "继续安装", MinWidth = 100 };
|
||||
noButton.Classes.Add("secondary-command");
|
||||
noButton.Click += (_, _) => tcs.TrySetResult(false);
|
||||
|
||||
var buttonPanel = new StackPanel
|
||||
{
|
||||
Orientation = Orientation.Horizontal,
|
||||
HorizontalAlignment = HorizontalAlignment.Right,
|
||||
Spacing = 8,
|
||||
Margin = new Thickness(0, 16, 0, 0),
|
||||
};
|
||||
buttonPanel.Children.Add(yesButton);
|
||||
buttonPanel.Children.Add(noButton);
|
||||
|
||||
DockPanel.SetDock(buttonPanel, Dock.Bottom);
|
||||
|
||||
var panel = new DockPanel { Margin = new Thickness(24) };
|
||||
panel.Children.Add(buttonPanel);
|
||||
panel.Children.Add(new TextBlock
|
||||
{
|
||||
Text = "安装正在进行,确定要退出吗?",
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
FontSize = 15,
|
||||
});
|
||||
|
||||
var dialog = new Window
|
||||
{
|
||||
Title = "确认退出",
|
||||
Width = 400,
|
||||
Height = 180,
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner,
|
||||
CanResize = false,
|
||||
WindowDecorations = WindowDecorations.BorderOnly,
|
||||
Content = panel,
|
||||
};
|
||||
|
||||
dialog.Closed += (_, _) => tcs.TrySetResult(false);
|
||||
|
||||
_ = dialog.ShowDialog(this);
|
||||
return await tcs.Task;
|
||||
}
|
||||
|
||||
private async Task<string?> BrowseForFolderAsync(string currentPath)
|
||||
{
|
||||
IStorageFolder? startFolder = null;
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:installer="using:LanDesktopPLONDS.Installer"
|
||||
x:Class="LanDesktopPLONDS.Installer.Views.UninstallConfirmWindow"
|
||||
x:DataType="installer:UninstallConfirmViewModel"
|
||||
Title="确认卸载阑山桌面"
|
||||
Width="480"
|
||||
Height="300"
|
||||
CanResize="False"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Background="#1E1E1E"
|
||||
ExtendClientAreaToDecorationsHint="False"
|
||||
WindowDecorations="Full">
|
||||
<Grid RowDefinitions="Auto,*,Auto"
|
||||
Margin="24">
|
||||
<StackPanel Spacing="8">
|
||||
<TextBlock Text="确认卸载"
|
||||
FontSize="20"
|
||||
FontWeight="SemiBold"
|
||||
Foreground="White" />
|
||||
<TextBlock Text="确定要卸载阑山桌面吗?此操作将删除所有已安装的文件。"
|
||||
TextWrapping="Wrap"
|
||||
Foreground="#99FFFFFF"
|
||||
FontSize="14" />
|
||||
</StackPanel>
|
||||
|
||||
<Border Grid.Row="1"
|
||||
Background="#2D2D2D"
|
||||
CornerRadius="8"
|
||||
Padding="16"
|
||||
Margin="0,16,0,0">
|
||||
<StackPanel Spacing="4">
|
||||
<TextBlock Text="安装路径"
|
||||
FontSize="12"
|
||||
Foreground="#99FFFFFF" />
|
||||
<TextBlock Text="{Binding InstallPath}"
|
||||
FontFamily="Consolas"
|
||||
FontSize="13"
|
||||
Foreground="#CCFFFFFF"
|
||||
TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<StackPanel Grid.Row="2"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Right"
|
||||
Spacing="8"
|
||||
Margin="0,16,0,0">
|
||||
<Button Content="取消"
|
||||
Width="100"
|
||||
Height="36"
|
||||
CornerRadius="6"
|
||||
Background="#3D3D3D"
|
||||
Foreground="White"
|
||||
Click="OnCancelClick" />
|
||||
<Button Content="确认卸载"
|
||||
Width="100"
|
||||
Height="36"
|
||||
CornerRadius="6"
|
||||
Background="#C42B1C"
|
||||
Foreground="White"
|
||||
Click="OnConfirmClick" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,27 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace LanDesktopPLONDS.Installer.Views;
|
||||
|
||||
public partial class UninstallConfirmWindow : Window
|
||||
{
|
||||
public UninstallConfirmWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnConfirmClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is UninstallConfirmViewModel vm)
|
||||
{
|
||||
vm.Confirm();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCancelClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is UninstallConfirmViewModel vm)
|
||||
{
|
||||
vm.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user