MIT License

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

Chromely深度技术分析

Chromely 是一个用于构建跨平台桌面应用的框架,它基于 .NET 平台,使用原生 GUI、HTML5、JavaScript、CSS、Owin、AspNetCore(MVC、RazorPages、Blazor)等多种技术栈进行开发。本文将从项目背景与痛点、核心技术揭秘、功能亮点与差异、应用场景与落地建议、综合评价等方面深入剖析 Chromely 的技术特点和实践价值。

项目背景与痛点

在跨平台应用开发领域,开发者常常面临多操作系统、多语言、多环境的复杂性,以及维护多个代码库和技术栈的负担。Chromely 应运而生,正是意图解决这一痛点,使得开发者能够通过单一代码库构建适用于 Windows、Linux、macOS 等多种操作系统的桌面应用。基于 .NET Core 和 .NET 5/6 应用程序,Chromely 提供了跨平台的 HTML 渲染功能和易用的前端开发体验。

核心技术揭秘

Chromely 架构的核心在于其灵活的技术栈组合。它利用 Electron 的 CEF (Chromium Embedded Framework) 编译器来渲染 HTML5 内容,结合 .NET 的强大后端支持,实现了前后端的无缝集成。尤其是它支持 Owin 和 AspNetCore,这为开发者提供了丰富的 Web 功能和成熟的中间件生态系统,如 MVC、Razor Pages 和 Blazor。

技术架构与数据流示例

以下是 Chromely 数据流的一个简化示意:

graph TD A[用户请求] --> B("前端界面") B --> C{"参数校验"} C -->|"通过"| D[后端逻辑] C -->|"失败"| E[返回错误] D --> F[数据库操作] F --> G[响应结果] G --> H{"结果处理"} H -->|"成功"| B H -->|"失败"| E

在这次数据流中,用户请求被前端界面捕获,经过参数校验后,正确的请求会被转发到后端逻辑进行处理,处理过程中可能包含数据库操作,处理结果回传给前端进行显示。

功能亮点与差异

不同于其他跨平台开发框架,如 Electron,Chromely 将 .NET 平台的优势融入其中,通过其对 Owin 和 AspNetCore 的支持,Chromely 在服务器端方面的表现尤为突出,这为开发复杂的后端逻辑提供了极大的便利。此外,Chromely 还支持整合 Blazor,这意味着开发者可以在服务器端通过 C# 语言编写组件,并在前端动态渲染,这一点是很多同类框架所不具备的。

应用场景与落地建议

在生产环境中使用 Chromely 时,需要注意以下几点:

  1. 性能优化:尽管 CEF 提供了强大的 HTML 渲染功能,但在资源消耗上可能高于原生桌面应用,特别是在处理复杂 UI 和大量数据时,需特别注意性能优化。
  2. 安全性:构建桌面应用时,要注意前后端分离的架构,避免潜在的安全风险。尤其是跨平台应用,需特别留意不同操作系统中常见的漏洞和攻击手段。
  3. 兼容性:尽管 Chromely 支持多操作系统,但具体的功能和性能表现可能会因操作系统版本和环境语言的不同而有所差异,开发时需要进行细致的测试和适配工作。

综合评价

Chromely 是一个强大的跨平台桌面应用开发框架,它结合了 .NET 平台的强大能力和 HTML5 技术,为开发者提供了一个高效、可靠的开发环境。其在技术栈丰富性、性能优化以及安全方面的表现尤其是在 Owin 和 AspNetCore 的配合下,使得其在服务器端应用的开发优势尤为突出。尽管存在一些潜在的性能和兼容性问题,通过细致的优化和适配,Chromely 让跨平台应用开发变得更加简单、高效。

语言占比

C
C#
HTML
Objective-C
Objective-C++
PowerShell
Shell

Release

README

** Announcement ** - Chromely is no longer being maintained!

For those who would like to continue working on the project via forks or alternative approaches, please send mattkol the appropriate links and they will be added here.

Thanks to all the contributors over the years for making the platform a great learning place.

Thank you all.

Chromely


For developers who are interested in WebView2 there is EdgeSharp, an offshoot of Chromely.

Chromely is a lightweight alternative to Electron.NET, Electron for .NET/.NET Core developers.

Chromely is a .NET/.NET Core HTML5 Chromium desktop framework. It is focused on building apps based on Xilium.CefGlue, CefSharp implementations of embedded Chromium (CEF) without WinForms or WPF, but can be extended to use WinForms or WPF. Chromely uses Windows, Linux and MacOS native GUI API as “thin” chromium hosts.

With Chromely you can build Single Page Application (SPA) HTML5 desktop apps with or without Node/npm. Building SPA apps using Blazor or javascript frameworks like Angular, React, Vue or similar is easy. You can use Visual Studio Code or any IDE you are familiar with as long as Chromely knows the entry html file from the compiled/bundled files. For more info please see - Blazor-Demos and Chromely-Apps.

Options of communicating (IPC) with rendering process are via:

If you like Chromely, please give it a star - it helps!

Have a quick question? Wanna chat? Connect on Join the chat at https://gitter.im/chromely_/Lobby

Have an app/project/tool using Chromely - please share!

Platforms

Cross-platform -Windows, Linux, MacOS. Built on CEF, CefGlue, NET Standard 2.0, .NET Core 3.0, .NET Framework 4.61 and above.

  • Windows(1) 32-bit
  • Windows(1) 64-bit
  • Linux(2) 32-bit
  • Linux(2) 64-bit
  • MacOSX(3) 64-bit
  • Linux ARM(4) Raspberry Pi

 (1)  Windows 7, Service Pack 1 and newer
 (2)  Ubuntu 16.04 and newer
       (Mono currently not working)
 (3)  Tested on macOS Mojave 10.14.6 (Other versions will likely work too)
 (4)  i.e. Raspberry Pi 3+ (starting with v5.x)
       (for v4.x - manual download of CEF builds for ARM required, available on http://chromely.org/cefbuilds/index.html)

Chromely.Core Chromely Chromely.Owin

Chromely + Angular
Chromely + React
Chromely + Vue

Creating a Simple App

For more info see - Getting Started or Wiki

A basic Chromely project requires:

ThreadApt.STA();

AppBuilder
    .Create(args)
    .UseApp<ChromelyBasicApp>()
    .Build()
    .Run();

Chromely Demos

Get started with our demos.

References

Contributing

Contributions are always welcome, via PRs, issues raised, or any other means. To become a dedicated contributor, please contact the Chromely team or raise an issue mentioning your intent.

License

Chromely is MIT licensed. For dependency licenses please see.

评论

暂无评论