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 <Application
x:Class="Semi.Avalonia.Demo.Web.App" x:Class="Semi.Avalonia.Demo.Web.App"
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:local="using:Semi.Avalonia.Demo.Web">
<Application.Styles> <Application.Styles>
<FluentTheme /> <StyleInclude Source="avares://Semi.Avalonia/Themes/Index.axaml" />
<StyleInclude Source="avares://Semi.Avalonia/Themes/LightTheme.axaml" /> <StyleInclude Source="avares://Semi.Avalonia.DataGrid/Index.axaml" />
<StyleInclude Source="avares://Semi.Avalonia.ColorPicker/Index.axaml" />
</Application.Styles> </Application.Styles>
</Application> </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 { .highlight {
color: white; color: white;

View File

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

View File

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

View File

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

View File

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