text: (this["webpackJsonpformium-client-frontend"]=this["webpackJsonpformium-client-frontend"]||[]).push([[3],{20:function(e,t,c){},27:function(e,t,c){"use strict";c.r(t);var r=c(0),n=(c(1),c(6)),i=function(){return Object(r.jsxs)("article",{children:[Object(r.jsx)("h2",{children:"JavaScript"}),Object(r.jsx)("p",{children:"NanUI provides the ability to interact with CEF's JavaScript environment. You can execute JavaScript code synchronously or asynchronously in the .NET environment and get the return value from JavaScript."}),Object(r.jsx)("p",{children:"NanUI also provides interfaces for registering JavaScript extensions. You can use this feature to extend JavaScript functions."}),Object(r.jsxs)("ul",{children:[Object(r.jsxs)("li",{children:[Object(r.jsx)("p",{children:Object(r.jsx)("b",{children:"Execute JavaScript code without return value"})}),Object(r.jsxs)("p",{children:["After the NanUI browser environment is initialized, you can use the"," ",Object(r.jsx)("b",{children:"ExecuteJavaScript"})," method to execute JavaScript code."]}),Object(r.jsx)("div",{className:"alert alert-secondary",children:Object(r.jsx)("pre",{children:'ExecuteJavaScript("alert(1+1)");'})}),Object(r.jsx)("p",{children:Object(r.jsx)("button",{className:"btn btn-primary",onClick:function(){return Object(n.b)()},children:"Execute"})})]}),Object(r.jsxs)("li",{children:[Object(r.jsx)("p",{children:Object(r.jsx)("b",{children:"Execute JavaScript code with return value"})}),Object(r.jsxs)("p",{children:["After NanUI's browser environment is initialized, you can use the"," ",Object(r.jsx)("b",{children:"EvaluateJavaScriptAsync"})," method to asynchronously execute JavaScript code with return values."]}),Object(r.jsx)("div",{className:"alert alert-secondary",children:Object(r.jsxs)("pre",{children:["var result = await EvaluateJavaScriptAsync(\"(function(){ return {a:1,b:'hello',c:(s)=>alert(s)}; })()\");\n","if(result.Success)\n","{\n","\tvar retval = result.ResultValue;\n",'\tMessageBox.Show($"a={retval.GetInt("a")} b={retval.GetString("b")}", "Value from JS");\n','\tawait retval.GetValue("c").ExecuteFunctionAsync(GetMainFrame(), new JavaScriptValue[] { JavaScriptValue.CreateString("Hello from C#") });\n',"}"]})}),Object(r.jsx)("p",{children:Object(r.jsx)("button",{className:"btn btn-primary",onClick:function(){return Object(n.a)()},children:"Execute"})})]}),Object(r.jsxs)("li",{children:[Object(r.jsx)("p",{children:Object(r.jsx)("b",{children:"Register JavaScript objects"})}),Object(r.jsxs)("p",{children:["Use the ",Object(r.jsx)("b",{children:"RegisterExternalObjectValue"})," method in conjunction with the ",Object(r.jsx)("b",{children:"JavaScriptValue"})," object to register .NET objects, properties, or methods into the ",Object(r.jsx)("b",{children:"Formium.external"})," object in the JavaScript environment."]}),Object(r.jsxs)("p",{children:["You can now open ",Object(r.jsx)("b",{children:"Developer Tools"})," from the left and enter the following code in the console to view the injected .NET objects."]}),Object(r.jsx)("div",{className:"alert alert-secondary",children:Object(r.jsx)("pre",{children:"> Formium.external.tester"})})]}),Object(r.jsxs)("li",{children:[Object(r.jsx)("p",{children:Object(r.jsx)("b",{children:"Register JavaScript extensions"})}),Object(r.jsxs)("p",{children:["Objects generated using JavaScript extensions can be called in each frame of CEF, which is different from objects registered using the"," ",Object(r.jsx)("b",{children:"RegisterExternalObjectValue"})," method which can only be used in the current frame."]}),Object(r.jsxs)("p",{children:["You can now open ",Object(r.jsx)("b",{children:"Developer Tools"})," from the left and enter the following code in the console to observe the injected JavaScript extension."]}),Object(r.jsx)("div",{className:"alert alert-secondary",children:Object(r.jsx)("pre",{children:"> DemoWindow"})}),Object(r.jsxs)("p",{children:["NanUI provides an easy way to register extensions, which can register synchronous and asynchronous methods. Please check the source code in the sample project in the"," ",Object(r.jsx)("code",{children:"DemoWindowExtension"})," folder."]})]})]})]})},a=function(){return Object(r.jsxs)("article",{children:[Object(r.jsx)("h2",{children:"JavaScript"}),Object(r.jsx)("p",{children:"NanUI \u63d0\u4f9b\u4e0e CEF \u7684 JavaScript \u73af\u5883\u4ea4\u4e92\u7684\u80fd\u529b\u3002\u60a8\u53ef\u4ee5\u5728 .NET \u73af\u5883\u4e2d\u540c\u6b65\u6216\u5f02\u6b65\u6267\u884c JavaScript \u4ee3\u7801\u5e76\u83b7\u5f97\u8fd4\u56de\u503c\u3002"}),Object(r.jsx)("p",{children:"\u6b64\u5916 NanUI \u8fd8\u63d0\u4f9b\u4e86\u6ce8\u518c JavaScript \u6269\u5c55\u7684\u63a5\u53e3\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u6b64\u529f\u80fd\u6269\u5c55 JavaScript \u7684\u529f\u80fd\u3002"}),Object(r.jsxs)("ul",{children:[Object(r.jsxs)("li",{children:[Object(r.jsx)("p",{children:Object(r.jsx)("b",{children:"\u6267\u884c\u65e0\u8fd4\u56de\u503c JavaScript \u4ee3\u7801"})}),Object(r.jsxs)("p",{children:["\u5728 NanUI \u7684\u6d4f\u89c8\u5668\u73af\u5883\u521d\u59cb\u5316\u4e4b\u540e\u5c31\u53ef\u4ee5\u4f7f\u7528 ",Object(r.jsx)("b",{children:"ExecuteJavaScript"})," ","\u65b9\u6cd5\u6765\u6267\u884c JavaScript \u4ee3\u7801\u3002"]}),Object(r.jsx)("div",{className:"alert alert-secondary",children:Object(r.jsx)("pre",{children:'ExecuteJavaScript("alert(1+1)");'})}),Object(r.jsx)("p",{children:Object(r.jsx)("button",{className:"btn btn-primary",onClick:function(){return Object(n.b)()},children:"\u6267\u884c"})})]}),Object(r.jsxs)("li",{children:[Object(r.jsx)("p",{children:Object(r.jsx)("b",{children:"\u6267\u884c\u6709\u8fd4\u56de\u503c JavaScript \u4ee3\u7801"})}),Object(r.jsxs)("p",{children:["\u5728 NanUI \u7684\u6d4f\u89c8\u5668\u73af\u5883\u521d\u59cb\u5316\u4e4b\u540e\u5c31\u53ef\u4ee5\u4f7f\u7528"," ",Object(r.jsx)("b",{children:"EvaluateJavaScriptAsync"})," \u65b9\u6cd5\u6765\u5f02\u6b65\u6267\u884c\u5e26\u8fd4\u56de\u503c\u7684 JavaScript \u4ee3\u7801\u3002"]}),Object(r.jsx)("div",{className:"alert alert-secondary",children:Object(r.jsxs)("pre",{children:["var result = await EvaluateJavaScriptAsync(\"(function(){ return {a:1,b:'hello',c:(s)=>alert(s)}; })()\");\n","if(result.Success)\n","{\n","\tvar retval = result.ResultValue;\n",'\tMessageBox.Show($"a={retval.GetInt("a")} b={retval.GetString("b")}", "Value from JS");\n','\tawait retval.GetValue("c").ExecuteFunctionAsync(GetMainFrame(), new JavaScriptValue[] { JavaScriptValue.CreateString("Hello from C#") });\n',"}"]})}),Object(r.jsx)("p",{children:Object(r.jsx)("button",{className:"btn btn-primary",onClick:function(){return Object(n.a)()},children:"\u6267\u884c"})})]}),Object(r.jsxs)("li",{children:[Object(r.jsx)("p",{children:Object(r.jsx)("b",{children:"\u6ce8\u518c JavaScript \u5bf9\u8c61"})}),Object(r.jsxs)("p",{children:["\u4f7f\u7528 ",Object(r.jsx)("b",{children:"RegisterExternalObjectValue"})," \u65b9\u6cd5\u5e76\u914d\u5408"," ",Object(r.jsx)("b",{children:"JavaScriptValue"})," \u5bf9\u8c61\u53ef\u4ee5\u5c06 .NET \u7684\u5bf9\u8c61\uff0c\u5c5e\u6027\u6216\u65b9\u6cd5\u7b49\u6ce8\u518c\u5230 JavaScript \u73af\u5883\u7684 ",Object(r.jsx)("b",{children:"Formium.external"})," \u5bf9\u8c61\u91cc\u3002"]}),Object(r.jsxs)("p",{children:["\u60a8\u73b0\u5728\u53ef\u4ee5\u4ece\u5de6\u4fa7\u6253\u5f00",Object(r.jsx)("b",{children:"\u5f00\u53d1\u8005\u5de5\u5177"}),"\u5728\u63a7\u5236\u53f0\u4e2d\u8f93\u5165\u4e0b\u9762\u4ee3\u7801\u89c2\u5bdf\u6ce8\u5165\u7684 .NET \u5bf9\u8c61\u3002"]}),Object(r.jsx)("div",{className:"alert alert-secondary",children:Object(r.jsx)("pre",{children:"> Formium.external.tester"})})]}),Object(r.jsxs)("li",{children:[Object(r.jsx)("p",{children:Object(r.jsx)("b",{children:"\u6ce8\u518c JavaScript \u6269\u5c55"})}),Object(r.jsxs)("p",{children:["\u4f7f\u7528 JavaScript \u6269\u5c55\u751f\u6210\u7684\u5bf9\u8c61\u53ef\u4ee5\u5728 CEF \u7684\u5404\u4e2a Frame \u4e2d\u8c03\u7528\uff0c\u8fd9\u70b9\u4e0e\u4f7f\u7528 ",Object(r.jsx)("b",{children:"RegisterExternalObjectValue"})," ","\u65b9\u6cd5\u6ce8\u518c\u7684\u5bf9\u8c61\u53ea\u80fd\u7528\u4e8e\u5f53\u524d frame \u6709\u6240\u533a\u522b\u3002"]}),Object(r.jsxs)("p",{children:["\u60a8\u73b0\u5728\u53ef\u4ee5\u4ece\u5de6\u4fa7\u6253\u5f00",Object(r.jsx)("b",{children:"\u5f00\u53d1\u8005\u5de5\u5177"}),"\u5728\u63a7\u5236\u53f0\u4e2d\u8f93\u5165\u4e0b\u9762\u4ee3\u7801\u89c2\u5bdf\u6ce8\u5165\u7684 JavaScript \u6269\u5c55\u3002"]}),Object(r.jsx)("div",{className:"alert alert-secondary",children:Object(r.jsx)("pre",{children:"> DemoWindow"})}),Object(r.jsxs)("p",{children:["NanUI \u63d0\u4f9b\u7b80\u4fbf\u7684\u6ce8\u518c\u6269\u5c55\u7684\u65b9\u6cd5\uff0c\u80fd\u591f\u6ce8\u518c\u540c\u6b65\u548c\u5f02\u6b65\u7684\u65b9\u6cd5\u3002\u8bf7\u67e5\u770b\u793a\u4f8b\u9879\u76ee",Object(r.jsx)("code",{children:"DemoWindowExtension"}),"\u6587\u4ef6\u5939\u4e2d\u7684\u6e90\u7801\u3002"]})]})]})]})},s=(c(20),c(2));t.default=function(){var e=Object(s.d)().state.lang;return Object(r.jsx)("div",{className:"js-page",children:"en-US"===e?Object(r.jsx)(i,{}):Object(r.jsx)(a,{})})}}}]);