{"id":4592,"date":"2023-08-04T15:47:56","date_gmt":"2023-08-04T07:47:56","guid":{"rendered":"https:\/\/h5app.yimenapp.cn\/h5app\/?p=4592"},"modified":"2023-08-04T15:47:56","modified_gmt":"2023-08-04T07:47:56","slug":"h5%e8%bd%ac%e6%88%90exe%e5%b8%b8%e7%94%a8%e5%b7%a5%e5%85%b7%e6%8e%a8%e8%8d%90","status":"publish","type":"post","link":"https:\/\/h5app.yimenapp.cn\/h5app\/2023\/ruanjiankf\/4592\/","title":{"rendered":"h5\u8f6c\u6210exe\u5e38\u7528\u5de5\u5177\u63a8\u8350"},"content":{"rendered":"<p>H5\uff08HTML5\uff09\u662f\u4e00\u79cd\u7528\u4e8e\u6784\u5efa\u7f51\u9875\u7684\u6807\u51c6\uff0c\u5b83\u5df2\u7ecf\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8eWeb\u5f00\u53d1\u9886\u57df\u3002\u4f46\u662f\uff0c\u6709\u65f6\u5019\u6211\u4eec\u9700\u8981\u5c06H5\u8f6c\u6362\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\uff08exe\uff09\uff0c\u8fd9\u6837\u53ef\u4ee5\u65b9\u4fbf\u5730\u5728\u672c\u5730\u8fd0\u884c\uff0c\u800c\u4e0d\u5fc5\u4f9d\u8d56\u4e8e\u6d4f\u89c8\u5668\u3002\u4e0b\u9762\uff0c\u6211\u5c06\u4ecb\u7ecdH5\u8f6c\u6362\u4e3aexe\u7684\u539f\u7406\u548c\u8be6\u7ec6\u8fc7\u7a0b\u3002<\/p>\n<p>\u4e00\u3001H5\u8f6c\u6362\u4e3aexe\u7684\u539f\u7406<\/p>\n<p>H5\u8f6c\u6362\u4e3aexe\u7684\u539f\u7406\u662f\u5c06H5\u9875\u9762\u6253\u5305\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u4f7f\u5176\u80fd\u591f\u5728\u672c\u5730\u72ec\u7acb\u8fd0\u884c\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u6d89\u53ca\u5230\u4e24\u4e2a\u4e3b\u8981\u7684\u6280\u672f\uff1aElectron\u548cNW.js\u3002<\/p>\n<p>Electron\u662f\u7531GitHub\u5f00\u53d1\u7684\u4e00\u4e2a\u5f00\u6e90\u6846\u67b6\uff0c\u5b83\u57fa\u4e8eNode.js\u548cChromium\u6d4f\u89c8\u5668\uff0c\u53ef\u4ee5\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002Electron\u63d0\u4f9b\u4e86\u8bb8\u591aAPI\uff0c\u5305\u62ec\u6587\u4ef6\u7cfb\u7edf\u3001\u7f51\u7edc\u3001\u7a97\u53e3\u7ba1\u7406\u7b49\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c06Web\u6280\u672f\u5e94\u7528\u4e8e\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u4e2d\u3002<\/p>\n<p>NW.js\uff08\u524d\u8eab\u4e3aNode-Webkit\uff09\u662f\u53e6\u4e00\u4e2a\u5f00\u6e90\u6846\u67b6\uff0c\u4e5f\u53ef\u4ee5\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002NW.js\u4e0eElectron\u7c7b\u4f3c\uff0c\u57fa\u4e8eNode.js\u548cChromium\u6d4f\u89c8\u5668\uff0c\u63d0\u4f9b\u4e86\u8bb8\u591aAPI\u548c\u6a21\u5757\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c06Web\u6280\u672f\u5e94\u7528\u4e8e\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u4e2d\u3002<\/p>\n<p>\u4e8c\u3001H5\u8f6c\u6362\u4e3aexe\u7684\u8be6\u7ec6\u8fc7\u7a0b<\/p>\n<p>\u4e0b\u9762\uff0c\u6211\u5c06\u4ecb\u7ecd\u4f7f\u7528Electron\u5c06H5\u8f6c\u6362\u4e3aexe\u7684\u8be6\u7ec6\u8fc7\u7a0b\u3002\u8fd9\u91cc\u4ee5Windows\u64cd\u4f5c\u7cfb\u7edf\u4e3a\u4f8b\u3002<\/p>\n<p>\u6b65\u9aa4\u4e00\uff1a\u5b89\u88c5Node.js\u548cElectron<\/p>\n<p>\u9996\u5148\uff0c\u9700\u8981\u5b89\u88c5Node.js\u548cElectron\u3002Node.js\u662fElectron\u7684\u57fa\u7840\uff0c\u6240\u4ee5\u5fc5\u987b\u5148\u5b89\u88c5Node.js\u3002Node.js\u7684\u5b89\u88c5\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u4ece\u5b98\u7f51\u4e0b\u8f7d\u5b89\u88c5\u5305\u5e76\u5b89\u88c5\u5373\u53ef\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Electron\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>npm install -g electron<\/p>\n<p>&#8220;`<\/p>\n<p>\u6b65\u9aa4\u4e8c\uff1a\u521b\u5efa<a href=\"https:\/\/exe.yimenapp.com\/tool-536.html\">\u6253\u5305deb\u5de5\u5177<\/a>\u9879\u76ee<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\uff0c\u5e76\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3amain.js\u7684\u6587\u4ef6\u3002main.js\u662fElectron\u5e94\u7528\u7a0b\u5e8f\u7684\u4e3b\u6587\u4ef6\uff0c\u5b83\u8d1f\u8d23\u521b\u5efa\u5e94\u7528\u7a0b\u5e8f\u7a97\u53e3\u548c\u5904\u7406\u7a97\u53e3\u4e8b\u4ef6\u7b49\u3002<\/p>\n<p>\u5728main.js\u4e2d\uff0c\u9700\u8981\u5f15\u5165Electron\u6a21\u5757\uff0c\u5e76\u521b\u5efa\u4e00\u4e2aBrowserWindow\u5bf9\u8c61\u6765\u663e\u793aH5\u9875\u9762\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684main.js\u6587\u4ef6\u7684\u4f8b\u5b50\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>const { app, BrowserWindow } = require(&#8216;electron&#8217;)<\/p>\n<p>function createWindow () {<\/p>\n<p>  const win = new BrowserWindow({<\/p>\n<p>    width: 800,<\/p>\n<p>    height: 600,<\/p>\n<p>    webPreferences: {<\/p>\n<p>      nodeIntegration: true<\/p>\n<p>    }<\/p>\n<p>  })<\/p>\n<p>  win.loadFile(&#8216;index.html&#8217;)<\/p>\n<p>}<\/p>\n<p>app.whenReady().then(() =&gt; {<\/p>\n<p>  createWindow()<\/p>\n<p>  app.on(&#8216;activate&#8217;, () =&gt; {<\/p>\n<p>    if (BrowserWindow.getAllW<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-03\/20\/11\/20762987684.jpg\" \/><\/figure>\n<\/p>\n<p>indows().length === 0) {<\/p>\n<p>      createWindow()<\/p>\n<p>    }<\/p>\n<p>  })<\/p>\n<p>})<\/p>\n<p>app.on(&#8216;window-all-closed&#8217;, () =&gt; {<\/p>\n<p>  if (process.platform !== &#8216;darwin&#8217;) {<\/p>\n<p>    app.quit()<\/p>\n<p>  }<\/p>\n<p>})<\/p>\n<p>&#8220;`<\/p>\n<p>\u5728\u4ee5\u4e0a\u4ee3\u7801\u4e2d\uff0c\u9996\u5148\u5f15\u5165\u4e86Electron\u6a21\u5757\uff0c\u5e76\u521b\u5efa\u4e86\u4e00\u4e2acreateWindow\u51fd\u6570\u6765\u521b\u5efa\u7a97\u53e3\u3002\u5728createWindow\u51fd\u6570\u4e2d\uff0c\u521b\u5efa\u4e86\u4e00\u4e2aBrowserWindow\u5bf9\u8c61\uff0c\u5e76\u8bbe\u7f6e\u4e86\u7a97\u53e3\u7684\u5927\u5c0f\u548cH5\u9875\u9762\u7684\u6587\u4ef6\u540d\uff08\u8fd9\u91cc\u662findex.html\uff09\u3002\u6700\u540e\uff0c\u4f7f\u7528app.whenReady()\u65b9\u6cd5\u6765\u521b\u5efa\u7a97\u53e3\uff0c\u5e76\u5728\u7a97\u53e3\u5173\u95ed\u65f6\u9000\u51fa\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u6b65\u9aa4\u4e09\uff1a\u6253\u5305\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u6700\u540e\u4e00\u6b65\u662f\u5c06\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002\u53ef\u4ee5\u4f7f\u7528Electron\u63d0\u4f9b\u7684electron-packager\u6a21\u5757\u6765\u6253\u5305\u5e94\u7528\u7a0b\u5e8f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u547d\u4ee4\u884c\u793a\u4f8b\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>electron-packager . MyApp &#8211;platform=win32 &#8211;arch=x64 &#8211;icon=.\/icon.ico<\/p>\n<p>&#8220;`<\/p>\n<p>\u5176\u4e2d\uff0c\u201c.\u201d\u8868\u793a\u5f53\u524d\u76ee\u5f55\uff0c\u201cMyApp\u201d\u662f<a href=\"https:\/\/exe.yimenapp.com\/tool-3924.html\">\u5982\u4f55\u5c06jframe\u9879\u76ee\u6253\u5305\u6210exe\u6267\u884c\u6587\u4ef6<\/a>\u5e94\u7528\u7a0b\u5e8f\u7684\u540d\u79f0\uff0c\u201c&#8211;platform=win32\u201d\u8868\u793a\u6253\u5305\u6210Windows\u5e73\u53f0\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u201c&#8211;arch=x64\u201d\u8868\u793a\u4f7f\u752864\u4f4d\u67b6\u6784\uff0c\u201c&#8211;icon=.\/icon.ico\u201d\u8868\u793a\u4f7f\u7528\u4e00\u4e2a\u540d\u4e3aicon.ico\u7684\u56fe\u6807\u6587\u4ef6\u3002<\/p>\n<p>\u6253\u5305\u5b8c\u6210\u540e\uff0c\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2a\u540d\u4e3aMyApp-win32-x64\u7684\u6587\u4ef6\u5939\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u53ef\u6267\u884c\u6587\u4ef6\u548c\u76f8\u5173\u6587\u4ef6\u3002\u53cc\u51fb\u53ef\u6267\u884c\u6587\u4ef6\u5373\u53ef\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u603b\u7ed3<\/p>\n<p>H5\u8f6c\u6362\u4e3aexe\u7684\u8fc7\u7a0b\u6d89\u53ca\u5230\u4e24\u4e2a\u4e3b\u8981\u7684\u6280\u672f\uff1aElectron\u548cNW.js\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4ecb\u7ecd\u4e86\u4f7f\u7528Electron\u5c06H5\u8f6c\u6362\u4e3aexe\u7684\u8be6\u7ec6\u8fc7\u7a0b\uff0c\u5305\u62ec\u5b89\u88c5Node.js\u548cElectron\u3001\u521b\u5efa\u9879\u76ee\u548c\u6253\u5305\u5e94\u7528\u7a0b\u5e8f\u3002\u901a\u8fc7\u8fd9\u4e2a\u8fc7\u7a0b\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06H5\u9875\u9762\u6253\u5305\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u65b9\u4fbf\u5730\u5728\u672c\u5730\u72ec\u7acb\u8fd0\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>H5\uff08HTML5\uff09\u662f\u4e00\u79cd\u7528\u4e8e\u6784\u5efa\u7f51\u9875\u7684\u6807\u51c6\uff0c\u5b83\u5df2\u7ecf\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8eWeb\u5f00\u53d1\u9886\u57df\u3002\u4f46\u662f\uff0c\u6709\u65f6\u5019\u6211\u4eec\u9700\u8981\u5c06H5\u8f6c\u6362\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\uff08exe\uff09\uff0c\u8fd9\u6837\u53ef\u4ee5\u65b9\u4fbf\u5730\u5728\u672c\u5730\u8fd0\u884c\uff0c\u800c\u4e0d\u5fc5\u4f9d\u8d56\u4e8e\u6d4f\u89c8\u5668\u3002\u4e0b\u9762\uff0c\u6211\u5c06\u4ecb\u7ecdH5\u8f6c<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[8775,8774,407,11,232],"topic":[],"class_list":["post-4592","post","type-post","status-publish","format-standard","hentry","category-ruanjiankf","tag-dmg","tag-exe","tag-407","tag-11","tag-232"],"_links":{"self":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/4592","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/comments?post=4592"}],"version-history":[{"count":0,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/4592\/revisions"}],"wp:attachment":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/media?parent=4592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/categories?post=4592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/tags?post=4592"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/topic?post=4592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}