mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-08-19 16:13:24 +08:00
feat.设置logo改进
This commit is contained in:
@@ -91,32 +91,6 @@
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- 更新页面 -->
|
||||
<Border Background="{DynamicResource SystemControlBackgroundAltMediumBrush}"
|
||||
CornerRadius="8"
|
||||
Padding="15">
|
||||
<Grid ColumnDefinitions="*,Auto">
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Text="{x:Static res:Strings.DevDebug_Update}"
|
||||
FontWeight="SemiBold"
|
||||
FontSize="14" />
|
||||
<TextBlock Text="显示更新进度和状态"
|
||||
FontSize="11"
|
||||
Opacity="0.6"
|
||||
Margin="0,3,0,0" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Spacing="8">
|
||||
<ToggleSwitch Content="{x:Static res:Strings.DevDebug_EnableFeature}"
|
||||
IsChecked="{Binding IsUpdateEnabled}"
|
||||
OnContent="功能"
|
||||
OffContent="查看" />
|
||||
<Button Content="{x:Static res:Strings.DevDebug_Open}"
|
||||
Command="{Binding OpenUpdateCommand}"
|
||||
HorizontalAlignment="Right" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- OOBE页面 -->
|
||||
<Border Background="{DynamicResource SystemControlBackgroundAltMediumBrush}"
|
||||
CornerRadius="8"
|
||||
|
||||
@@ -24,7 +24,6 @@ public partial class DevDebugWindow : Window
|
||||
// 订阅事件
|
||||
_viewModel.OpenSplashRequested += OnOpenSplashRequested;
|
||||
_viewModel.OpenErrorRequested += OnOpenErrorRequested;
|
||||
_viewModel.OpenUpdateRequested += OnOpenUpdateRequested;
|
||||
_viewModel.OpenOobeRequested += OnOpenOobeRequested;
|
||||
_viewModel.OpenDataLocationRequested += OnOpenDataLocationRequested;
|
||||
_viewModel.CloseRequested += OnCloseRequested;
|
||||
@@ -74,28 +73,6 @@ public partial class DevDebugWindow : Window
|
||||
errorWindow.Show();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开更新页面
|
||||
/// </summary>
|
||||
private void OnOpenUpdateRequested(object? sender, UpdateOpenEventArgs e)
|
||||
{
|
||||
var updateWindow = new UpdateWindow();
|
||||
|
||||
if (!e.IsFunctional)
|
||||
{
|
||||
// 查看模式:显示模拟更新
|
||||
updateWindow.SetDebugMode(true);
|
||||
}
|
||||
|
||||
updateWindow.Show();
|
||||
|
||||
if (e.IsFunctional)
|
||||
{
|
||||
// 功能模式:模拟更新进度
|
||||
_ = SimulateUpdateProgress(updateWindow);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开OOBE页面
|
||||
/// </summary>
|
||||
@@ -161,7 +138,7 @@ public partial class DevDebugWindow : Window
|
||||
/// </summary>
|
||||
private async Task SimulateSplashProgress(SplashWindow splashWindow)
|
||||
{
|
||||
var stages = new[] { Strings.Preview_SplashInitializing, Strings.Preview_SplashCheckingUpdates, Strings.Preview_SplashCheckingPlugins, Strings.Preview_SplashLaunchingHost };
|
||||
var stages = new[] { Strings.Preview_SplashInitializing, Strings.Preview_SplashCheckingPlugins, Strings.Preview_SplashLaunchingHost };
|
||||
var reporter = (ISplashStageReporter)splashWindow;
|
||||
|
||||
for (int i = 0; i < stages.Length; i++)
|
||||
@@ -175,33 +152,13 @@ public partial class DevDebugWindow : Window
|
||||
splashWindow.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 模拟更新进度
|
||||
/// </summary>
|
||||
private async Task SimulateUpdateProgress(UpdateWindow updateWindow)
|
||||
{
|
||||
var stages = new[] { "下载", "验证", "安装", "清理" };
|
||||
|
||||
foreach (var stage in stages)
|
||||
{
|
||||
updateWindow.Report(stage, $"正在{stage}...", Array.IndexOf(stages, stage) * 25 + 10);
|
||||
await Task.Delay(800);
|
||||
}
|
||||
|
||||
updateWindow.ReportComplete(true, null);
|
||||
|
||||
// 2秒后关闭
|
||||
await Task.Delay(2000);
|
||||
updateWindow.Close();
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
// 取消订阅事件
|
||||
_viewModel.OpenSplashRequested -= OnOpenSplashRequested;
|
||||
_viewModel.OpenErrorRequested -= OnOpenErrorRequested;
|
||||
_viewModel.OpenUpdateRequested -= OnOpenUpdateRequested;
|
||||
_viewModel.OpenOobeRequested -= OnOpenOobeRequested;
|
||||
_viewModel.OpenDataLocationRequested -= OnOpenDataLocationRequested;
|
||||
_viewModel.CloseRequested -= OnCloseRequested;
|
||||
|
||||
base.OnClosed(e);
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:views="clr-namespace:LanMountainDesktop.Launcher.Views"
|
||||
xmlns:res="clr-namespace:LanMountainDesktop.Launcher.Resources"
|
||||
mc:Ignorable="d"
|
||||
d:DesignWidth="480"
|
||||
d:DesignHeight="320"
|
||||
x:Class="LanMountainDesktop.Launcher.Views.UpdateWindow"
|
||||
x:DataType="views:UpdateWindow"
|
||||
x:CompileBindings="False"
|
||||
Title="{x:Static res:Strings.Update_Title}"
|
||||
Width="480"
|
||||
Height="320"
|
||||
CanResize="False"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
WindowDecorations="None"
|
||||
Background="{DynamicResource SolidBackgroundFillColorBaseBrush}"
|
||||
TransparencyLevelHint="None"
|
||||
Icon="/Assets/logo.ico">
|
||||
<Design.DataContext>
|
||||
<views:UpdateWindow />
|
||||
</Design.DataContext>
|
||||
|
||||
<Grid>
|
||||
<!-- 顶部:应用名称和最小化按钮 -->
|
||||
<Grid VerticalAlignment="Top" Margin="24,24,24,0">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Spacing="8">
|
||||
<TextBlock x:Name="TitleText"
|
||||
Text="{x:Static res:Strings.Update_AppName}"
|
||||
FontSize="24"
|
||||
FontWeight="SemiBold"
|
||||
Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
|
||||
<Border Background="{DynamicResource AccentFillColorDefaultBrush}"
|
||||
CornerRadius="4"
|
||||
Padding="6,2"
|
||||
VerticalAlignment="Center">
|
||||
<TextBlock Text="{x:Static res:Strings.Update_StatusUpdate}"
|
||||
FontSize="11"
|
||||
FontWeight="SemiBold"
|
||||
Foreground="{DynamicResource TextOnAccentFillColorPrimaryBrush}" />
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
<!-- 最小化按钮 -->
|
||||
<Button x:Name="MinimizeButton"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Width="32"
|
||||
Height="32"
|
||||
Background="Transparent"
|
||||
BorderThickness="0">
|
||||
<TextBlock Text=""
|
||||
FontSize="12"
|
||||
FontFamily="{DynamicResource SymbolThemeFontFamily}"
|
||||
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
<!-- 底部区域:进度条和状态 -->
|
||||
<Grid VerticalAlignment="Bottom" Margin="24,0,24,24">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 第一行:左下角状态,右下角百分比 -->
|
||||
<Grid Grid.Row="0" Margin="0,0,0,8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 左下角:状态文字 -->
|
||||
<TextBlock x:Name="StatusText"
|
||||
Grid.Column="0"
|
||||
FontSize="11"
|
||||
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
||||
Opacity="0.8"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Bottom"
|
||||
Text="{x:Static res:Strings.Update_StatusUpdating}" />
|
||||
|
||||
<!-- 右下角:百分比 -->
|
||||
<TextBlock x:Name="PercentText"
|
||||
Grid.Column="1"
|
||||
FontSize="11"
|
||||
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
||||
Opacity="0.8"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Text="0%" />
|
||||
</Grid>
|
||||
|
||||
<!-- 底部:进度条 -->
|
||||
<ProgressBar x:Name="ProgressIndicator"
|
||||
Grid.Row="1"
|
||||
Minimum="0"
|
||||
Maximum="100"
|
||||
Value="0"
|
||||
Height="4"
|
||||
IsIndeterminate="True"
|
||||
Foreground="{DynamicResource AccentFillColorDefaultBrush}"
|
||||
Background="{DynamicResource ControlStrokeColorDefaultBrush}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,124 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Threading;
|
||||
using LanMountainDesktop.Launcher.Resources;
|
||||
|
||||
namespace LanMountainDesktop.Launcher.Views;
|
||||
|
||||
/// <summary>
|
||||
/// 更新进度窗口 - 用于预览模式显示更新/插件升级进度
|
||||
/// </summary>
|
||||
public partial class UpdateWindow : Window
|
||||
{
|
||||
public UpdateWindow()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeEventHandlers();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化事件处理程序
|
||||
/// </summary>
|
||||
private void InitializeEventHandlers()
|
||||
{
|
||||
var minimizeButton = this.FindControl<Button>("MinimizeButton");
|
||||
if (minimizeButton != null)
|
||||
{
|
||||
minimizeButton.Click += (s, e) =>
|
||||
{
|
||||
this.WindowState = WindowState.Minimized;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新状态和进度
|
||||
/// </summary>
|
||||
public void Report(string stage, string message, int progressPercent = -1)
|
||||
{
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
var statusText = this.FindControl<TextBlock>("StatusText");
|
||||
var progressIndicator = this.FindControl<ProgressBar>("ProgressIndicator");
|
||||
var percentText = this.FindControl<TextBlock>("PercentText");
|
||||
|
||||
if (statusText is null || progressIndicator is null || percentText is null)
|
||||
{
|
||||
Console.Error.WriteLine($"[UpdateWindow] Controls not found in Report: StatusText={statusText != null}, ProgressIndicator={progressIndicator != null}, PercentText={percentText != null}");
|
||||
return;
|
||||
}
|
||||
|
||||
statusText.Text = message;
|
||||
|
||||
if (progressPercent >= 0)
|
||||
{
|
||||
progressIndicator.IsIndeterminate = false;
|
||||
progressIndicator.Value = progressPercent;
|
||||
percentText.Text = $"{progressPercent}%";
|
||||
}
|
||||
else
|
||||
{
|
||||
progressIndicator.IsIndeterminate = true;
|
||||
percentText.Text = "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示更新完成状态
|
||||
/// </summary>
|
||||
public void ReportComplete(bool success, string? errorMessage = null)
|
||||
{
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
var statusText = this.FindControl<TextBlock>("StatusText");
|
||||
var progressIndicator = this.FindControl<ProgressBar>("ProgressIndicator");
|
||||
var percentText = this.FindControl<TextBlock>("PercentText");
|
||||
var titleText = this.FindControl<TextBlock>("TitleText");
|
||||
|
||||
if (statusText is null || progressIndicator is null || percentText is null || titleText is null)
|
||||
{
|
||||
Console.Error.WriteLine($"[UpdateWindow] Controls not found in ReportComplete");
|
||||
return;
|
||||
}
|
||||
|
||||
progressIndicator.IsIndeterminate = false;
|
||||
progressIndicator.Value = 100;
|
||||
percentText.Text = "100%";
|
||||
|
||||
if (success)
|
||||
{
|
||||
statusText.Text = Strings.Update_Complete;
|
||||
}
|
||||
else
|
||||
{
|
||||
titleText.Text = Strings.Update_Failed;
|
||||
statusText.Text = errorMessage ?? Strings.Update_FailedMessage;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置调试模式
|
||||
/// </summary>
|
||||
public void SetDebugMode(bool isDebugMode)
|
||||
{
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
var statusText = this.FindControl<TextBlock>("StatusText");
|
||||
var titleText = this.FindControl<TextBlock>("TitleText");
|
||||
|
||||
if (statusText is null || titleText is null)
|
||||
{
|
||||
Console.Error.WriteLine($"[UpdateWindow] Controls not found in SetDebugMode");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDebugMode)
|
||||
{
|
||||
titleText.Text = Strings.Update_DebugTitle;
|
||||
statusText.Text = Strings.Update_DebugMessage;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user