{"id":2386,"date":"2023-08-08T15:47:43","date_gmt":"2023-08-08T07:47:43","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=2386"},"modified":"2023-08-08T15:47:43","modified_gmt":"2023-08-08T07:47:43","slug":"html5%e9%a1%b9%e7%9b%ae%e6%89%93%e5%8c%85%e6%88%90exe%e6%ad%a5%e9%aa%a4%e8%af%b4%e6%98%8e","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/2386\/","title":{"rendered":"html5\u9879\u76ee\u6253\u5305\u6210exe\u6b65\u9aa4\u8bf4\u660e"},"content":{"rendered":"

HTML5\u662f\u4e00\u79cd\u7528\u4e8e\u6784\u5efaWeb\u5e94\u7528\u7a0b\u5e8f\u7684\u8bed\u8a00\uff0c\u5b83\u53ef\u4ee5\u5728\u4efb\u4f55\u8bbe\u5907\u4e0a\u8fd0\u884c\uff0c\u5305\u62ec\u684c\u9762\u3001\u79fb\u52a8\u8bbe\u5907\u548c\u667a\u80fd\u7535\u89c6\u3002\u4f46\u662f\uff0c\u6709\u65f6\u5019\u6211\u4eec\u9700\u8981\u5c06HTML5\u9879\u76ee\u6253\u5305\u6210exe\u6587\u4ef6\uff0c\u4ee5\u4fbf\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5c06HTML5\u9879\u76ee\u6253\u5305\u6210exe\u6587\u4ef6\u7684\u539f\u7406\u548c\u8be6\u7ec6\u6b65\u9aa4\u3002<\/p>\n

\u539f\u7406<\/p>\n

\u5c06HTML5\u9879\u76ee\u6253\u5305\u6210exe\u6587\u4ef6\u7684\u539f\u7406\u662f\u5c06HTML5\u9879\u76ee\u8f6c\u6362\u4e3a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528Electron\u6765\u5b9e\u73b0\u3002Electron\u662f\u4e00\u4e2a\u57fa\u4e8eNode.js\u548cChromium\u7684\u6846\u67b6\uff0c\u5b83\u53ef\u4ee5\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

Electron\u7684\u5de5\u4f5c\u539f\u7406\u662f\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u4e00\u4e2a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\uff0c\u8be5\u7a0b\u5e8f\u5177\u6709\u4e0e\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u76f8\u540c\u7684\u6743\u9650\u548c\u529f\u80fd\u3002Electron\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u7684HTML\u3001CSS\u548cJavaScript\u4ee3\u7801\u6253\u5305\u5230\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\uff0c\u5e76\u63d0\u4f9b\u4e0e\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u3001\u64cd\u4f5c\u7cfb\u7edf\u548c\u786c\u4ef6\u7684\u4ea4\u4e92\u80fd\u529b\u3002\u8fd9\u4f7f\u5f97\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u4f7f\u7528Web\u6280\u672f\u6784\u5efa\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5229\u7528Electron\u7684\u529f\u80fd\u5c06\u5176\u8f6c\u6362\u4e3a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

\u8be6\u7ec6\u6b65\u9aa4<\/p>\n

\u4e0b\u9762\u662f\u5c06HTML5\u9879\u76ee\u6253\u5305\u6210exe\u6587\u4ef6\u7684\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n

1. \u5b89\u88c5Node.js\u548cElectron<\/p>\n

\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5Node.js\u548cElectron\u3002Node.js\u662f\u4e00\u4e2a\u57fa\u4e8eChrome V8\u5f15\u64ce\u7684JavaScript\u8fd0\u884c\u73af\u5883\uff0c\u5b83\u53ef\u4ee5\u5728\u670d\u52a1\u5668\u7aef\u8fd0\u884cJavaScript\u4ee3\u7801\u3002Electron\u662f\u57fa\u4e8eNode.js\u7684\u6846\u67b6\uff0c\u5b83\u7528\u4e8e\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

2. \u521b\u5efaElectron\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u4f7f\u7528Electron\uff0c\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Electron\u5e94\u7528\u7a0b\u5e8f\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Electron\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n

“`<\/p>\n

npx create-electron-app my-app<\/p>\n

“`<\/p>\n

\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cmy-app\u201d\u7684\u65b0\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

3. \u5c06HTML5\u9879\u76ee\u6dfb\u52a0\u5230Electron\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u5c06HTML5\u9879\u76ee\u6dfb\u52a0\u5230Electron\u5e94\u7528\u7a0b\u5e8f\u4e2d\u3002\u5c06HTML\u3001CSS\u548cJavaScript\u6587\u4ef6\u590d\u5236\u5230\u201cmy-app\u201d\u6587\u4ef6\u5939\u4e2d\u3002\u5728\u201cmy-app\u201d\u6587\u4ef6\u5939\u4e2d\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u6587\u4ef6\u5939\u201capp\u201d\u5e76\u5c06HTML\u3001CSS\u548cJavaScript\u6587\u4ef6\u590d\u5236\u5230\u8be5\u6587\u4ef6\u5939\u4e2d\u3002<\/p>\n

4. \u5728Electron\u5e94\u7528\u7a0b\u5e8f\u4e2d\u52a0\u8f7dHTML5\u9879\u76ee<\/p>\n

\u5728Electron\u5e94\u7528\u7a0b\u5e8f\u4e2d\u52a0\u8f7dHTML5\u9879\u76ee\u3002\u4e3a\u6b64\u5c01\u88c5\u8f6f\u4ef6<\/a>\uff0c\u8bf7\u5728\u201cmain.js\u201d\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n

“`<\/p>\n

app.on(‘ready’, () => {<\/p>\n

mainWindow = new BrowserWindow({<\/p>\n

width: 800,<\/p>\n

height: 600<\/p>\n

})<\/p>\n

mainWindow.loadFile(‘app\/index.html’)<\/p>\n

})<\/p>\n

“`<\/p>\n

\u8fd9\u5c06\u5728Electron\u5e94\u7528\u7a0b\u5e8f\u4e2d\u52a0\u8f7dHTML5\u9879\u76ee\u3002<\/p>\n

5. \u6253\u5305Electron\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u4f7f\u7528Electron-builder\u5de5\u5177\u6253\u5305Electron\u5e94\u7528\u7a0b\u5e8f\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Electron-builder\uff1a<\/p>\n

“`<\/p>\n

npm install e<\/p>\n

<\/figure>\n<\/p>\n

lectron-builder –save-dev<\/p>\n

“`<\/p>\n

\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6253\u5305Electron\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n

“`<\/p>\n

npx electron-builder build<\/p>\n

“`<\/p>\n

\u8fd9\u5c06\u5728\u201cdist\u201d\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n

6. \u8fd0\u884cElectron\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u6700\u540e\uff0c\u8fd0\u884cElectron\u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u201cdist\u201d\u6587\u4ef6\u5939\u4e2d\u627e\u5230\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5e76\u8fd0\u884c\u5b83\u3002<\/p>\n

\u7ed3\u8bba<\/p>\n

\u5c06HTML5\u9879\u76ee\u6253\u5305\u6210exe\u6587\u4ef6\u662f\u4e00\u9879\u975e\u5e38\u6709\u7528\u7684\u6280\u80fd\uff0c\u5b83\u53ef\u4ee5\u8ba9\u6211\u4eec\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c\u3002\u4f7f\u7528Electron\u548cElect\u6587\u4ef6\u6253\u5305\u6210dmg<\/a>ron-builder\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u5c06HTML5\u9879\u76ee\u6253\u5305\u6210exe\u6587\u4ef6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

HTML5\u662f\u4e00\u79cd\u7528\u4e8e\u6784\u5efaWeb\u5e94\u7528\u7a0b\u5e8f\u7684\u8bed\u8a00\uff0c\u5b83\u53ef\u4ee5\u5728\u4efb\u4f55\u8bbe\u5907\u4e0a\u8fd0\u884c\uff0c\u5305\u62ec\u684c\u9762\u3001\u79fb\u52a8\u8bbe\u5907\u548c\u667a\u80fd\u7535\u89c6\u3002\u4f46\u662f\uff0c\u6709\u65f6\u5019\u6211\u4eec\u9700\u8981\u5c06HTML5\u9879\u76ee\u6253\u5305\u6210exe\u6587\u4ef6\uff0c\u4ee5\u4fbf\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c\u3002\u672c\u6587\u5c06\u4ecb<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[4997,4996,12,16,23],"topic":[],"class_list":["post-2386","post","type-post","status-publish","format-standard","hentry","category-exekf","tag-html5","tag-exe","tag-12","tag-16","tag-23"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/2386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=2386"}],"version-history":[{"count":0,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/2386\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=2386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=2386"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=2386"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=2386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}