Fix wasm deployment issue (#827)

* fix: update wasm-tools installation

* fix: add TrimmerRootAssembly for WASM optimization

* fix: update project to target .NET 10 and adjust deployment settings

* fix: add TrimmerRootAssembly for Ursa.Demo to improve WASM optimization

* fix: avoid Window based dialog crash on non-supported platforms.
This commit is contained in:
Dong Bin
2025-11-17 11:24:07 +08:00
committed by GitHub
parent 1cf920afa8
commit a4906d5130
5 changed files with 29 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.WebAssembly">
<PropertyGroup>
<TargetFramework>net8.0-browser</TargetFramework>
<TargetFramework>net10.0-browser</TargetFramework>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
@@ -9,9 +9,15 @@
<ItemGroup>
<AvaloniaResource Include="Assets\**"/>
</ItemGroup>
<ItemGroup>
<TrimmerRootAssembly Include="Ursa.Demo" />
<TrimmerRootAssembly Include="Ursa.Demo.Browser" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Browser" Version="$(AvaloniaVersion)"/>
<PackageReference Include="SkiaSharp.NativeAssets.WebAssembly" Version="3.119.1" />
</ItemGroup>
<ItemGroup>

View File

@@ -30,6 +30,6 @@ public class ButtonItem
private async Task Invoke()
{
await MessageBox.ShowAsync("Hello " + Name);
await MessageBox.ShowOverlayAsync("Hello " + Name);
}
}

View File

@@ -48,6 +48,11 @@ public partial class DefaultWindowDialogDemoViewModel: ObservableObject
private async Task ShowDialog()
{
if(OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS())
{
await MessageBox.ShowOverlayAsync("Window dialogs are not supported on this platform. Please use overlay dialogs instead.");
return;
}
var options = new DialogOptions()
{
Title = Title,
@@ -92,6 +97,11 @@ public partial class CustomWindowDialogDemoViewModel: ObservableObject
private async Task ShowDialog()
{
if(OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS())
{
await MessageBox.ShowOverlayAsync("Window dialogs are not supported on this platform. Please use overlay dialogs instead.");
return;
}
var options = new DialogOptions()
{
Title = Title,

View File

@@ -2,6 +2,7 @@
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using System.Windows.Input;
using Avalonia.Markup.Xaml.MarkupExtensions;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Ursa.Controls;
@@ -126,6 +127,12 @@ public class MessageBoxDemoViewModel: ObservableObject
}
else
{
if (OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS())
{
await MessageBox.ShowOverlayAsync("Only overlay message box is supported on this platform.",
"Ursa MessageBox", button: MessageBoxButton.OK, icon: MessageBoxIcon.Error);
return;
}
Result = await MessageBox.ShowAsync(_message, _title, icon: SelectedIcon, button:button);
}
}