От: | Serginio1 | https://habrahabr.ru/users/serginio1/topics/ | |
Дата: | 24.05.20 16:28 | ||
Оценка: | 2 (1) |
static void Main(string[] args)
{
var window = new WebWindow(".NET Core + Vue.js file explorer");
window.OnWebMessageReceived += HandleWebMessageReceived;
window.NavigateToLocalFile("wwwroot/index.html");
window.WaitForExit();
}
window.external.sendMessage(JSON.stringify({
command: 'navigateTo',
basePath: app.directoryInfo.name,
relativePath: relativePath
}));
static void HandleWebMessageReceived(object sender, string message)
{
var window = (WebWindow)sender;
var parsedMessage = JsonDocument.Parse(message).RootElement;
switch (parsedMessage.GetProperty("command").GetString())
{
case "navigateTo":
static void SendCommand(WebWindow window, string commandName, object arg)
{
window.SendMessage(JsonSerializer.Serialize(new { command = commandName, arg = arg }));
}
static void Main(string[] args)
{
ComponentsDesktop.Run<Startup>("My Blazor App", "wwwroot/index.html");
}
Напомним, что это не включает в себя WebAssembly, Node.js, или Chromium. Это просто .NET Core работает изначально, напрямую взаимодействуя с собственной технологией веб-рендеринга ОС.
How it works
On Windows, WebWindow uses the new Chromium-based Edge via webview2, assuming you have that browser installed (it could fall back on older Edge if you don’t, but I haven’t implemented that)
On Mac, it uses the OS’s built-in WKWebView, which is the same technology behind Safari
On Linux, it uses WebKitGTK+2, which is yet again a WebKit-based technology
The whole point of this, compared with using Electron, is to produce apps that are smaller to download and use less memory. But does it actually? Here are the stats for download size: