{"id":49014,"date":"2025-09-17T15:39:38","date_gmt":"2025-09-17T07:39:38","guid":{"rendered":"https:\/\/www.zhidianwl.com\/zhidian\/?p=49014"},"modified":"2025-09-17T15:39:38","modified_gmt":"2025-09-17T07:39:38","slug":"%e5%89%8d%e7%ab%af%e7%bd%91%e9%a1%b5%e6%89%93%e5%8c%85exe%e6%93%8d%e4%bd%9c%e6%b5%81%e7%a8%8b%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.com\/zhidian\/2025\/49014\/","title":{"rendered":"\u524d\u7aef\u7f51\u9875\u6253\u5305exe\u64cd\u4f5c\u6d41\u7a0b\u4ecb\u7ecd"},"content":{"rendered":"<p>\u524d\u7aef\u7f51\u9875\u6253\u5305exe\u662f\u5c06\u4e00\u4e2a\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8fc7\u7a0b\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u53ef\u4ee5\u8ba9\u4f60\u5c06\u4f60\u7684\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u53d1\u5e03\u5230\u5404\u79cd\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\uff0c\u5305\u62ecWindows\u3001macOS\u548cLinux\u7b49\u64cd\u4f5c\u7cfb\u7edf\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u4ecb\u7ecd\u524d\u7aef\u7f51\u9875\u6253\u5305exe\u7684\u539f\u7406\u548c\u8be6\u7ec6\u8fc7\u7a0b\u3002<\/p>\n<p>\u4e00\u3001\u524d\u7aef\u7f51\u9875\u6253\u5305exe\u7684\u539f\u7406<\/p>\n<p>\u524d\u7aef\u7f51\u9875\u6253\u5305exe\u7684\u539f\u7406\u662f\u5c06\u4e00\u4e2a\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u8fd9\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u5305\u542b\u4e86\u6240\u6709\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u6240\u9700\u7684\u8d44\u6e90\u548c\u6587\u4ef6\uff0c\u4f8b\u5982HTML\u3001CSS\u3001JavaScript\u3001\u56fe\u7247\u3001\u97f3\u9891\u548c\u89c6\u9891\u7b49\u3002\u5f53\u7528\u6237\u8fd0\u884c\u8fd9\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u65f6\uff0c\u5b83\u4f1a\u81ea\u52a8\u6253\u5f00\u4e00\u4e2a\u672c\u5730\u7684Web\u670d\u52a1\u5668\uff0c\u5e76\u5728\u7528\u6237\u7684\u9ed8\u8ba4\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00\u5e94\u7528\u7a0b\u5e8f\u7684\u4e3b\u9875\u3002<\/p>\n<p>\u4e8c\u3001\u524d\u7aef\u7f51\u9875\u6253\u5305exe\u7684\u8be6\u7ec6\u8fc7\u7a0b<\/p>\n<p>1. \u5b89\u88c5\u6253\u5305\u5de5\u5177<\/p>\n<p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u5b89\u88c5\u4e00\u4e2a\u524d\u7aef\u7f51\u9875\u6253\u5305exe\u7684\u5de5\u5177\u3002\u76ee\u524d\u5e02\u9762\u4e0a\u6709\u5f88\u591a\u4e0d\u540c\u7684\u6253\u5305\u5de5\u5177\u53ef\u4f9b\u9009\u62e9\uff0c\u4f8b\u5982Electron\u3001NW.js\u3001AppJS\u7b49\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ee5Electron\u4e3a\u4f8b\u6765\u4ecb\u7ecd\u524d\u7aef\u7f51\u9875\u6253\u5305exe\u7684\u8be6\u7ec6\u8fc7\u7a0b\u3002<\/p>\n<p>2. \u521b\u5efa\u9879\u76ee\u6587\u4ef6\u5939<\/p>\n<p>\u5728\u4f60\u7684\u7535\u8111\u4e0a\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u9879\u76ee\u6587\u4ef6\u5939\uff0c\u5e76\u5728\u5176\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684package.json\u6587\u4ef6\u3002\u8fd9\u4e2a\u6587\u4ef6\u7528\u4e8e\u63cf\u8ff0\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u4f8b\u5982\u540d\u79f0\u3001\u7248\u672c\u3001\u4f5c\u8005\u3001\u63cf\u8ff0\u548c\u4f9d\u8d56\u9879\u7b49\u4fe1\u606f\u3002<\/p>\n<p>3. \u5b89\u88c5\u4f9d\u8d56\u9879<\/p>\n<p>\u5728\u547d\u4ee4\u884c\u4e2d\u8fdb\u5165\u4f60\u7684\u9879\u76ee\u6587\u4ef6\u5939\uff0c\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5Electron\u7684\u4f9d\u8d56\u9879\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>npm install electron &#8211;save-dev<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u5728\u4f60\u7684\u9879\u76ee\u6587\u4ef6\u5939\u4e2d\u5b89\u88c5Electron\u7684\u4f9d\u8d56\u9879\uff0c\u5e76\u5c06\u5b83\u4eec\u6dfb\u52a0\u5230\u4f60\u7684package.json\u6587\u4ef6\u4e2d\u3002<\/p>\n<p>4. \u521b\u5efa\u4e3b\u8fdb\u7a0b\u6587\u4ef6<\/p>\n<p>\u5728\u4f60\u7684\u9879\u76ee\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684main.js\u6587\u4ef6\u3002\u8fd9\u4e2a\u6587\u4ef6\u7528\u4e8e\u521b\u5efaElectron\u7684\u4e3b\u8fdb\u7a0b\uff0c\u5e76\u5728\u5176\u4e2d\u52a0\u8f7d\u4f60\u7684\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u5728main.js\u6587\u4ef6\u4e2d\uff0c\u4f60\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u6765\u521b\u5efaElectron\u7684\u4e3b\u7a97\u53e3\uff0c\u5e76\u5728\u5176\u4e2d\u52a0\u8f7d\u4f60\u7684\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>const { app, BrowserWindow } = require(&#8216;electron&#8217;)<\/p>\n<p>const path = require(&#8216;path&#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;, f<a href=\"https:\/\/exe.yimenapp.com\/tool-2222.html\">\u5982\u4f55\u628a\u7f51\u9875\u5730\u5740\u96c6\u6210exe<\/a>unction () {<\/p>\n<p>    if (BrowserWindow.getAllWindows().length === 0) createWindow()<\/p>\n<p>  })<\/p>\n<p>})<\/p>\n<p>app.on(&#8216;window-all-closed&#8217;, function () {<\/p>\n<p>  if (process.platform !== &#8216;<a href=\"https:\/\/exe.yimenapp.com\/tool-848.html\">\u5c01\u88c5\u7f51\u9875exe<\/a>darwin&#8217;) app.quit()<\/p>\n<p>})<\/p>\n<p>&#8220;`<\/p>\n<p>\u5728\u8fd9\u4e2a\u4ee3\u7801\u4e2d\uff0c\u4f60\u9700\u8981\u5c06width\u548cheight\u8bbe\u7f6e\u4e3a\u4f60\u5e94\u7528\u7a0b\u5e8f\u7a97\u53e3\u7684\u5927\u5c0f\uff0c\u5e76\u5c06webPreferences.nodeIntegration\u8bbe\u7f6e\u4e3atrue\u4ee5\u542f\u7528Node.js\u96c6\u6210\u3002\u7136\u540e\uff0c\u4f60\u9700\u8981\u4f7f\u7528win.loadFile(&#8216;index.html&#8217;)\u6765\u52a0\u8f7d\u4f60\u7684\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>5. \u521b\u5efa\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u5728\u4f60\u7684\u9879\u76ee\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684index.html\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u7f16\u5199\u4f60\u7684\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528HTML\u3001CSS\u548cJavaScript\u7b49\u6280\u672f\u6765\u521b\u5efa\u4f60\u7684\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>6. \u6253\u5305\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u5728\u547d\u4ee4\u884c\u4e2d\u8fdb\u5165\u4f60\u7684\u9879\u76ee\u6587\u4ef6\u5939\uff0c\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u6253\u5305\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>npx electron-packager . myapp &#8211;platform=win32 &#8211;arch=x64<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u4f7f\u7528Electron Packager\u5de5\u5177\u6765\u6253\u5305\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5c06\u5b83\u4eec\u8f93\u51fa\u5230myapp-win32-x64\u6587\u4ef6\u5939\u4e2d\u3002\u4f60\u53ef\u4ee5\u5c06\u8fd9\u4e2a\u6587\u4ef6\u5939\u590d\u5236\u5230\u4efb\u4f55Windows\u7535\u8111\u4e0a\uff0c\u5e76\u8fd0\u884cmyapp.exe\u6765\u542f\u52a8\u4f60\u7684\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u4e09\u3001\u603b\u7ed3<\/p>\n<p>\u524d\u7aef\u7f51\u9875\u6253\u5305exe\u662f\u5c06\u4e00\u4e2a\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8fc7<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.yimenyun.net\/2023-03\/17\/15\/13342809823.jpg\" \/><\/figure>\n<\/p>\n<p>\u7a0b\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u53ef\u4ee5\u8ba9\u4f60\u5c06\u4f60\u7684\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u53d1\u5e03\u5230\u5404\u79cd\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\uff0c\u5305\u62ecWindows\u3001macOS\u548cLinux\u7b49\u64cd\u4f5c\u7cfb\u7edf\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u4ecb\u7ecd\u4e86\u524d\u7aef\u7f51\u9875\u6253\u5305exe\u7684\u539f\u7406\u548c\u8be6\u7ec6\u8fc7\u7a0b\uff0c\u5e76\u4f7f\u7528Electron\u4e3a\u4f8b\u6765\u6f14\u793a\u4e86\u5982\u4f55\u6253\u5305\u4e00\u4e2a\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u7aef\u7f51\u9875\u6253\u5305exe\u662f\u5c06\u4e00\u4e2a\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8fc7\u7a0b\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u53ef\u4ee5\u8ba9\u4f60\u5c06\u4f60\u7684\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u53d1\u5e03\u5230\u5404\u79cd\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\uff0c\u5305\u62ecWindows\u3001macOS\u548cLinux\u7b49\u64cd\u4f5c\u7cfb\u7edf\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[38290,14,7571,171,117],"class_list":["post-49014","post","type-post","status-publish","format-standard","hentry","category-zuoexe","tag-linuxopenharmony","tag-14","tag-deb","tag-171","tag-117"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/49014","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/comments?post=49014"}],"version-history":[{"count":1,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/49014\/revisions"}],"predecessor-version":[{"id":49047,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/49014\/revisions\/49047"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/media?parent=49014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/categories?post=49014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/tags?post=49014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}