feat: close directly if next window is null.

This commit is contained in:
Dong Bin
2025-02-24 19:50:02 +08:00
parent aa4507c9c8
commit dc2cf01b43
5 changed files with 72 additions and 58 deletions

View File

@@ -14,7 +14,7 @@ public partial class MainSplashWindow : SplashWindow
InitializeComponent();
}
protected override async Task<Window> CreateNextWindow()
protected override async Task<Window?> CreateNextWindow()
{
return new MainWindow()
{

View File

@@ -1,48 +1,54 @@
<u:SplashWindow 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:u="https://irihi.tech/ursa"
xmlns:viewModels="clr-namespace:Ursa.Demo.ViewModels"
xmlns:iri="https://irihi.tech/shared"
mc:Ignorable="d"
Width="400" Height="400"
CountDown="{x:Null}"
x:DataType="viewModels:SplashViewModel"
x:Class="Ursa.Demo.Views.MvvmSplashWindow"
Title="MvvmSplashWindow">
<Grid
<u:SplashWindow
x:Class="Ursa.Demo.Views.MvvmSplashWindow"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:iri="https://irihi.tech/shared"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="https://irihi.tech/ursa"
xmlns:viewModels="clr-namespace:Ursa.Demo.ViewModels"
Title="MvvmSplashWindow"
Width="400"
Height="400"
x:DataType="viewModels:SplashViewModel"
CountDown="{x:Null}"
mc:Ignorable="d">
<Grid
HorizontalAlignment="Center"
VerticalAlignment="Center"
ColumnDefinitions="Auto, Auto"
RowDefinitions="Auto, Auto, Auto">
<iri:IrihiLogo
Grid.Row="0"
Grid.Column="0"
Width="64"
Margin="0,0,16,0"
Fill="{DynamicResource SemiGrey5}" />
<StackPanel Grid.Row="0" Grid.Column="1">
<TextBlock
Classes="H2"
Text="铱泓科技"
Theme="{DynamicResource TitleTextBlock}" />
<TextBlock FontWeight="Bold" Text="IRIHI Technology" />
</StackPanel>
<ProgressBar
Grid.Row="1"
Grid.ColumnSpan="2"
Margin="0,16,0,0"
Value="{Binding Progress}" />
<StackPanel
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2">
<TextBlock
Margin="0,12,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ColumnDefinitions="Auto, Auto"
RowDefinitions="Auto, Auto, Auto">
<iri:IrihiLogo
Grid.Row="0"
Grid.Column="0"
Width="64"
Margin="0,0,16,0"
Fill="{DynamicResource SemiGrey5}" />
<StackPanel Grid.Row="0" Grid.Column="1">
<TextBlock
Classes="H2"
Text="铱泓科技"
Theme="{DynamicResource TitleTextBlock}" />
<TextBlock FontWeight="Bold" Text="IRIHI Technology" />
</StackPanel>
<ProgressBar Grid.Row="1" Grid.ColumnSpan="2" Value="{Binding Progress}" Margin="0 16 0 0"/>
<StackPanel
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2">
<TextBlock
Margin="0,12,0,0"
HorizontalAlignment="Center"
FontSize="14"
Text="聚焦生产力的美学进化" />
<TextBlock
HorizontalAlignment="Center"
FontSize="14"
Text="Aesthetic Evolution of Productivity" />
</StackPanel>
</Grid>
FontSize="14"
Text="聚焦生产力的美学进化" />
<TextBlock
HorizontalAlignment="Center"
FontSize="14"
Text="Aesthetic Evolution of Productivity" />
</StackPanel>
</Grid>
</u:SplashWindow>

View File

@@ -14,11 +14,15 @@ public partial class MvvmSplashWindow : SplashWindow
InitializeComponent();
}
protected override async Task<Window> CreateNextWindow()
protected override async Task<Window?> CreateNextWindow()
{
return new MainWindow()
if (this.DialogResult is true)
{
DataContext = new MainViewViewModel()
};
return new MainWindow()
{
DataContext = new MainViewViewModel()
};
}
return null;
}
}