webview 部分_Microsoft Edge最令人兴奋的部分是WebView2

webview 部分

In the ancient days of the 1990s, when the internet was a new and trendy invention, programmers wondered if it might be a good vehicle for applications. So we tried to take the desktop technology of the time and wedge that into our web browsers. We used tools like ActiveX plugins and Java applets. We used embarrassingly bad, proprietary plugins like Office Web Components and FrontPage Extensions. Most sensible programmers stayed far away.

在 1990年代的远古时代,当互联网是一种新的和时髦的发明时,程序员想知道它是否可能是应用程序的好工具。 因此,我们尝试采用当时的桌面技术,并将其嵌入到Web浏览器中。 我们使用了ActiveX插件和Java applet之类的工具。 我们使用了令人尴尬的,糟糕的专有插件,例如Office Web Components和FrontPage Extensions。 大多数明智的程序员都远离。

Eventually people realized these strategies were never going to work at the scale of the web and for the incredible variety of web-connected computers and devices. There was too much install, too many security risks, too little support across different platforms. Instead, it turned out that the right model was the reverse. Instead of putting a native app into a browser, Trojan horse style, we needed to sneak web apps into our desktop applications. Today, this type of approach is called a hybrid application and it runs the gamut from a simple web page shown alongside native content to a complete JavaScript app in Electron.

最终,人们意识到这些策略永远无法在Web规模以及与Web连接的计算机和设备的各种变化中起作用。 安装太多,安全风险太多,跨不同平台的支持太少。 相反,事实证明正确的模型是相反的 。 我们没有将本地应用程序放入特洛伊木马风格的浏览器中,而是需要将Web应用程序潜入我们的桌面应用程序中。 今天,这种类型的方法称为混合应用程序 ,它的运行范围从从与本机内容一起显示的简单网页到Electron中的完整JavaScript应用程序。

Despite the popularity of hybrid applications, modern solutions for rolling your own are a bit of a patchwork. If you don’t want to use a full framework like Electron, you need to rely on a system control like WebBrowser (the original, IE-powered window for hosting web content) or the newer WebView (based on Edge, but limited to Windows 10). In the best case scenario, you’re managing a fallback to IE on older computers, and dealing the creaky Internet Explorer browser long past its expiration date. As a side effect, you never know what level of standards compliance you’ll get, which makes it impossible to take advantage of the most modern JavaScript and CSS features.

尽管混合应用程序很流行,但是用于滚动自己的现代解决方案仍然有些杂乱。 如果您不想使用像Electron这样的完整框架,则需要依靠系统控件,例如WebBrowser (用于托管Web内容的原始IE驱动窗口)或更新的WebView (基于Edge,但仅限于Windows) 10)。 最好的情况是,您要管理旧计算机上的IE后备,并处理过期的Internet Explorer浏览器。 副作用是,您永远不知道将获得什么级别的标准合规性,这使得无法利用最现代JavaScript和CSS功能。

Microsoft has been promising a fix for a while. They demonstrated a successor to WebView for C++ applications at last year’s Build conference. Now this successor,WebView2, is finally arriving and finally supports all types of Windows applications.

微软已经承诺修复了一段时间。 他们在去年的Build大会展示了C ++应用程序WebView的后继产品。 现在,此继任者WebView2终于WebView2 ,并最终支持所有类型的Windows应用程序。

Here’s the big picture. WebView2 runs on any version of Windows, reaching back to Windows 7. Microsoft also claims that it works on versions of Windows Server all the way back to the preposterously old Windows Server 2008 R2 (a fact that’s both incredible and mostly useless).

这是全局。 WebView2可以在Windows的任何版本上运行, WebView2可以追溯到Windows7。Microsoft还声称,它可以在Windows Server的所有版本上一直运行到荒谬的旧Windows Server 2008 R2(这一事实令人难以置信,并且几乎没有用)。

More importantly, WebView2 is guaranteed to use the Edge browser’s implementation of the good old industry standard Chromium engine. On pre-Windows 10 computers, there’s a small distributable that you may need to include (essentially, a componentized version of Edge). Once you do you’re guaranteed the latest version of the Edge rendering engine, in perpetuity. There’s also a “fixed” mode that lets you lock your application down to the version of Edge you built it with. But if you go this route, it’s up to you to manage the distribution of Edge updates, and accept the security risk of old versions.

更重要的是,保证WebView2使用Edge浏览器对旧的行业标准Chromium引擎的良好实现。 在Windows 10之前的计算机上,可能需要包括一小部分可分发内容(本质上是Edge的组件化版本)。 一旦确定,您将永远获得最新版本的Edge渲染引擎。 还有一种“固定”模式,可让您将应用程序锁定为使用其构建的Edge版本。 但是,如果您走这条路,则取决于您来管理Edge更新的分发,并接受旧版本的安全风险。

The wide compatibility and lightweight nature of WebView2 is impressive. It’s enough to make me forgive Edge for its aggressive attempts to sneak into my task bar and take over the default browser setting. (For the record, I think that Edge is a dramatically better browser than IE, but still plagued by some quirks. It’s best features are the ones copied from Chrome, and — although I won’t judge anyone who picks it for their daily driver — Edge still hasn’t become my favorite browser.)

WebView2的广泛兼容性和轻量级特性令人印象深刻。 这足以使我原谅Edge进行的大胆尝试,以潜入我的任务栏并接管默认浏览器设置。 (据记录,我认为Edge是一种比IE更好的浏览器,但仍然受到一些怪癖的困扰。最好的功能是从Chrome复制的功能,而且-尽管我不会判断是谁选择了它作为日常驱动程序— Edge仍然没有成为最喜欢的浏览器。)

WebView2 also has expansive application support. Its first early preview version was for C++ only. Now it runs on the .NET Framework both new and old (from .NET Framework 4.6 and .NET Core 3, to the future, .NET 5). And your choice of applications isn’t limited, because WebView2 works seamlessly in every important type of Windows application, including WPF, the new version of WinUI, Windows Forms, and even old-school Win32, as you would expect.

WebView2还具有广泛的应用程序支持。 它的第一个早期预览版本仅适用于C ++。 现在,它可以在新旧的.NET Framework上运行(从.NET Framework 4.6和.NET Core 3到将来的.NET 5 )。 而且您对应用程序的选择不受限制,因为WebView2可在Windows的所有重要类型中无缝运行,包括WPF, WinUI新版本 ,Windows Forms以及您期望的老式Win32。

In other words, you can take a legacy application, touch none of its application code, but insert a Chromium-powered window that hosts add-on content. You could use that window for a documentation system, news content, or add-on features. If you want to extend your application and blur the boundaries between desktop and web, there’s the usual message-passing ability (you can call a custom JavaScript function in your hosted web page, or your web page can notify you by posting a string or maybe some JSON). The WebView2 is already turning up all over Office, including in the desktop version of Outlook, where it hosts the Room Finder panel.

换句话说,您可以使用旧版应用程序,不触摸任何应用程序代码,而是插入一个由Chromium驱动的窗口,该窗口承载附加内容。 您可以将该窗口用于文档系统,新闻内容或附加功能。 如果您想扩展应用程序并模糊桌面与Web之间的界限,则可以使用通常的消息传递功能(您可以在托管网页中调用自定义JavaScript函数,或者您的网页可以通过发布字符串或一些JSON)。 WebView2已经在整个Office上打开,包括在Outlook的桌面版本中,它托管了Room Finder面板。

Although WebView2 still isn’t finished, it’s finally graduated to a preview release, and Microsoft has plenty of documentation and sample content. General availability for all application types is slated for the end of the year.

尽管WebView2仍未完成,但最终还是升级到了预览版本,并且Microsoft有大量的文档和示例内容 。 所有应用程序类型的通用可用性都将在今年年底发布

The future of WebView2 could be even brighter. It’s easy to imagine WebView2 facilitating a lightweight alternate to Electron with none of the Node.js overhead. And it’s particularly relevant now that Microsoft is experimenting with approaches that can lower the desktop hosting footprint for Blazor. In fact, given the popularity of Electron and all types of hybrid applications, it’s surprising how long it’s taken Microsoft to get this working. And it makes their decision to abandon IE and adopt Chromium even easier to understand.

WebView2的未来可能更加光明。 可以轻松想象WebView2促进了Electron的轻量级替代,而没有Node.js开销。 现在特别重要的是,微软正在试验可以减少Blazor桌面托管空间的方法。 实际上,考虑到Electron和所有类型的混合应用程序的普及,Microsoft花了多长时间才使它起作用,这令人惊讶。 而且,他们决定放弃IE并采用Chromium更加容易理解。

For Microsoft news, programming deep dives, and occasional humor, subscribe to the monthly Young Coder newsletter.

有关Microsoft新闻,编程深入探究和偶发幽默的信息,请订阅《 Young Coder》月刊

翻译自: https://medium.com/young-coder/the-most-exciting-part-of-microsoft-edge-is-webview2-584ac27fb788

webview 部分

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值