浏览器CEFSharp88+X86+win7 之多页面展示(四)
代码
/// <summary>
/// cef浏览器全局设置
/// </summary>
public class CefHelper
{/// <summary>/// 初始化cef引擎/// </summary>public static void 东方仙盟_浏览器88初始化(){var settings = new CefSettings(){Locale = "zh-CN",AcceptLanguageList = "zh-CN,zh;q=0.8",PersistSessionCookies = true,UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0 Safari/537.36",IgnoreCertificateErrors = true,LogSeverity = LogSeverity.Disable, //禁用日志//为空则将以“隐身模式”创建浏览器//CachePath = AppDomain.CurrentDomain.BaseDirectory + "cef_cache",//Windows上用户“Local Settings\Application Data\CEF\User Data”目录UserDataPath = AppDomain.CurrentDomain.BaseDirectory + "cef_temp"};settings.CefCommandLineArgs.Add("disable-gpu", "1"); // 禁用gpusettings.CefCommandLineArgs.Add("no-proxy-server", "1"); //禁用代理settings.CefCommandLineArgs.Add("proxy-auto-detect", "0"); //禁用代理//settings.CefCommandLineArgs.Add("proxy-server", "ProxyAddress");settings.CefCommandLineArgs.Add("--disable-web-security", "1"); //允许跨域settings.CefCommandLineArgs.Add("--ignore-urlfetcher-cert-requests", "1");//忽略安全证书settings.CefCommandLineArgs.Add("--ignore-certificate-errors", "1");//忽略安全证书settings.CefCommandLineArgs.Add("enable-media-stream", "1"); //允许webRTC//settings.CefCommandLineArgs["enable-system-flash"] = "1";//settings.CefCommandLineArgs.Add("ppapi-flash-version", "32.0.0.171");//settings.CefCommandLineArgs.Add("ppapi-flash-path", @"plugins\pepflashplayer.dll");Cef.EnableHighDPISupport();CefSharpSettings.ConcurrentTaskExecution = true;//CefSharpSettings.LegacyJavascriptBindingEnabled = true;Cef.Initialize(settings);}/// <summary>/// 关闭cef引擎/// </summary>public static void Shutdown(){Cef.Shutdown();try{Directory.Delete($"{AppDomain.CurrentDomain.BaseDirectory}GPUCache", true);Directory.Delete($"{AppDomain.CurrentDomain.BaseDirectory}cef_temp", true);}catch{}}
}
前端
//CefSharp.BindObjectAsync('myClass');
//myClass.say();
CefSharp.BindObjectAsync('myClass').then(function (result) {
myClass.say();
});
---------------------------------------------------------------------------------------------
后端执行js
//不带参数
webview.ExecuteScriptAsync("myClass.say()");
//带参数
var p = {
say2: function (txt) { //前端对象方法
alert(txt);
}
}
webview.ExecuteScriptAsync("p.say2","这是参数");
//执行有返回值的js
var res = await webview.EvaluateScriptAsync("p.say2","asdas");
MessageBox.Show(res.Result.ToString());
form代码
public static ChromiumWebBrowser webview;
public FrmMain()
{webview = new ChromiumWebBrowser(App.WebUrl);webview.Dock = DockStyle.Fill;webview.DownloadHandler = new DownloadHandler();webview.MenuHandler = new MenuHandler();webview.JavascriptObjectRepository.Register("myClass", new AAA(), true);Controls.Add(webview);CheckForIllegalCrossThreadCalls = false;InitializeComponent();}
引用库
CefSharp.Core.dll
CefSharp.dll
CefSharp.WinForms.dll右键属性==>不要生成到目录
解压
CefSharp.H264.x86.88.4.2.nupkg
资源文件
NuGet Gallery | CefSharp.H264.x86 133.4.2
环境要求
.NETFramework 4.5.2
新版特性
以下是一些注意事項:
- 您現在可以使用 將擴充功能上傳至 Chrome 線上應用程式商店。
- CSS 屬性可讓您輕鬆設定任何元素的顯示比例。
- Chrome 88 會在特定情況下,隱藏網頁的鏈結 JavaScript 計時器。
- 您現在可以在受信任的網路活動中使用
- 的所有影片都已上線。
我是現在在家工作並拍攝影片,讓我們一起來看看 Chrome 88 有哪些新功能可供開發人員使用!
Manifest V3
Chrome 88 現已支援使用 Manifest V3 建構的擴充功能,您可以將這些擴充功能上傳至 Chrome 線上應用程式商店。Manifest V3 是全新的擴充功能平台,可讓 Chrome 擴充功能在預設情況下更安全、效能更佳,並尊重隱私權。
舉例來說,這項政策禁止遠端代管程式碼,有助於 Chrome 線上應用程式商店審查人員更清楚瞭解擴充功能可能帶來的風險。並且應該可讓您更快更新擴充功能。
這項功能會引入服務工作者,取代背景頁面。由於服務工作者只會在需要時駐留在記憶體中,因此擴充功能會使用較少的系統資源。
為了讓使用者更清楚瞭解擴充功能如何使用及分享其資料,並進一步控管相關設定,我們將在日後的版本中採用新的安裝流程,讓使用者在安裝時拒絕敏感權限。
請造訪進一步瞭解相關詳情,以及如何將目前的擴充功能遷移至 Manifest V3
阿雪技术观
在科技发展浪潮中,我们不妨积极投身技术共享。不满足于做受益者,更要主动担当贡献者。无论是分享代码、撰写技术博客,还是参与开源项目维护改进,每一个微小举动都可能蕴含推动技术进步的巨大能量。东方仙盟是汇聚力量的天地,我们携手在此探索硅基生命,为科技进步添砖加瓦。
Hey folks, in this wild tech - driven world, why not dive headfirst into the whole tech - sharing scene? Don't just be the one reaping all the benefits; step up and be a contributor too. Whether you're tossing out your code snippets, hammering out some tech blogs, or getting your hands dirty with maintaining and sprucing up open - source projects, every little thing you do might just end up being a massive force that pushes tech forward. And guess what? The Eastern FairyAlliance is this awesome place where we all come together. We're gonna team up and explore the whole silicon - based life thing, and in the process, we'll be fueling the growth of technology.