feat: upgrade to support wasm.

This commit is contained in:
Zhang Dian 2023-06-04 23:10:03 +08:00
parent 7c1fd71e43
commit 232e6e4b41
6 changed files with 18 additions and 25 deletions

View File

@ -1,10 +1,10 @@
<Application
x:Class="Semi.Avalonia.Demo.Web.App"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Semi.Avalonia.Demo.Web">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Styles>
<FluentTheme />
<StyleInclude Source="avares://Semi.Avalonia/Themes/LightTheme.axaml" />
<StyleInclude Source="avares://Semi.Avalonia/Themes/Index.axaml" />
<StyleInclude Source="avares://Semi.Avalonia.DataGrid/Index.axaml" />
<StyleInclude Source="avares://Semi.Avalonia.ColorPicker/Index.axaml" />
</Application.Styles>
</Application>

View File

@ -1,4 +1,11 @@
/* HTML styles for the splash screen */
:root {
--sat: env(safe-area-inset-top);
--sar: env(safe-area-inset-right);
--sab: env(safe-area-inset-bottom);
--sal: env(safe-area-inset-left);
}
/* HTML styles for the splash screen */
.highlight {
color: white;

View File

@ -10,7 +10,6 @@
<link rel="modulepreload" href="./dotnet.js" />
<link rel="modulepreload" href="./avalonia.js" />
<link rel="stylesheet" href="./app.css" />
<link rel="preconnect" href="https://fonts.googleapis.com">
</head>
<body style="margin: 0px; overflow: hidden">

View File

@ -1,5 +1,4 @@
import { dotnet } from './dotnet.js'
import { registerAvaloniaModule } from './avalonia.js';
const is_browser = typeof window != "undefined";
if (!is_browser) throw new Error(`Expected to be running in a browser`);
@ -9,8 +8,6 @@ const dotnetRuntime = await dotnet
.withApplicationArgumentsFromQuery()
.create();
await registerAvaloniaModule(dotnetRuntime);
const config = dotnetRuntime.getConfig();
await dotnetRuntime.runMainAndExit(config.mainAssemblyName, [window.location.search]);

View File

@ -1,17 +1,16 @@
using System.Runtime.Versioning;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Media;
using Semi.Avalonia.Demo.Web;
using Avalonia.Browser;
[assembly: SupportedOSPlatform("browser")]
namespace Semi.Avalonia.Demo.Web;
internal partial class Program
{
private static void Main(string[] args)
{
BuildAvaloniaApp(); //.SetupBrowserApp("out");
}
private static async Task Main(string[] args) => await BuildAvaloniaApp()
.StartBrowserAppAsync("out");
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>();

View File

@ -10,20 +10,11 @@
<WasmExtraFilesToDeploy Include="AppBundle\**" />
</ItemGroup>
<ItemGroup>
<None Remove="Assets\SourceHanSansCN-Regular.otf" />
</ItemGroup>
<ItemGroup>
<AvaloniaResource Include="Assets\SourceHanSansCN-Regular.otf" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Browser" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Semi.Avalonia.Demo\Semi.Avalonia.Demo.csproj" />
<ProjectReference Include="..\Semi.Avalonia.Demo\Semi.Avalonia.Demo.csproj" />
</ItemGroup>
</Project>