{"id":44426,"date":"2025-08-07T15:39:45","date_gmt":"2025-08-07T07:39:45","guid":{"rendered":"https:\/\/h5app.yimenapp.cn\/h5app\/?p=44426"},"modified":"2025-08-07T15:39:45","modified_gmt":"2025-08-07T07:39:45","slug":"%e5%89%8d%e7%ab%af%e5%bc%80%e5%8f%91window%e6%a1%8c%e9%9d%a2%e5%ba%94%e7%94%a8%e6%96%b9%e6%b3%95%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/h5app.yimenapp.cn\/h5app\/2025\/ruanjiankf\/44426\/","title":{"rendered":"\u524d\u7aef\u5f00\u53d1window\u684c\u9762\u5e94\u7528\u65b9\u6cd5\u4ecb\u7ecd"},"content":{"rendered":"<p>\u524d\u7aef\u5f00\u53d1\u684c\u9762\u5e94\u7528\u662f\u4e00\u79cd\u975e\u5e38\u6d41\u884c\u7684\u6280\u672f\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u5c06Web\u6280\u672f\u4e0e\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u7ed3\u5408\u8d77\u6765\uff0c\u4ece\u800c\u4e3a\u7528\u6237\u63d0\u4f9b\u66f4\u597d\u7684\u7528\u6237\u4f53\u9a8c\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Electron\u6846\u67b6<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.yimenyun.net\/2023-03\/15\/11\/12986626197.jpg\" \/><\/figure>\n<\/p>\n<p>\u5f00\u53d1\u7a97\u53e3\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u4e00\u3001\u4ec0\u4e48\u662fElectron\u6846\u67b6\uff1f<\/p>\n<p>Electron\u662f\u4e00\u4e2a\u57fa\u4e8eNode.js\u548cChromium\u7684\u5f00\u6e90\u6846\u67b6\uff0c\u53ef\u4ee5\u7528\u4e8e\u521b\u5efa\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u4f7f\u7528HTML\u3001CSS\u548cJavaScript\u7b49Web\u6280\u672f\u6765\u6784\u5efa\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\uff0c\u540c\u65f6\u4e5f\u652f\u6301\u5e73\u53f0\u672c\u673a\u5e94\u7528\u7a0b\u5e8f\u7684\u529f\u80fd\uff0c\u5982\u6587\u4ef6\u7cfb\u7edf\u548c\u64cd\u4f5c\u7cfb\u7edfAPI\u7b49\u3002<\/p>\n<p>\u4e8c\u3001\u5982\u4f55\u4f7f\u7528Electron\u6846\u67b6\uff1f<\/p>\n<p>1. \u5b89\u88c5Electron<\/p>\n<p>\u9996\u5148\uff0c\u9700\u8981\u5b89\u88c5Node.js\u548cnpm\u3002\u7136\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528npm\u6765\u5b89\u88c5Electron\u3002\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>npm install electron &#8211;save-dev<\/p>\n<p>&#8220;`<\/p>\n<p>2. \u521b\u5efa\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6587\u4ef6\u5939\uff0c\u7136\u540e\u5728\u8be5\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3amain.js\u7684\u6587\u4ef6\u3002\u5728main.js\u6587\u4ef6\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u6765\u521b\u5efa\u4e00\u4e2a\u6700\u5c0f\u7684Electron\u5e94\u7528\u7a0b\u5e8f\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>})<\/p>\n<p>&#8220;`<\/p>\n<p>3. \u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u542f\u52a8\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>npm start<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u5c06\u542f\u52a8Electron\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5728\u7a97\u53e3\u4e2d\u663e\u793a\u4e00\u4e2a\u7a7a\u767d\u9875\u9762\u3002<\/p>\n<p>4. \u6dfb\u52a0HTML\u3001CSS\u548cJavaScript<\/p>\n<p>\u73b0\u5728\uff0c\u53ef\u4ee5\u5728\u9879\u76ee\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aindex.html\u7684\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u6dfb\u52a0HTML\u3001CSS\u548cJavaScript\u4ee3\u7801\u3002\u5728main.js\u6587\u4ef6\u4e2d\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u6765\u52a0\u8f7dindex.html\u6587\u4ef6\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>win.loadFile(&#8216;index.html&#8217;)<\/p>\n<p>&#8220;`<\/p>\n<p>5. \u6253\u5305\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u5b8c\u6210\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u53d1\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528Electron-packager\u6216Electron-builder\u7b49\u5de5\u5177\u5c06\u5176\u6253\u5305\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\u3002\u8fd9\u4e9b\u5de5\u5177\u53ef\u4ee5\u5c06\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u5230Windows\u3001macOS\u548cLinux\u7b49\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\u3002<\/p>\n<p>\u4e09\u3001Electron\u6846\u67b6\u7684\u4f18\u52bf<\/p>\n<p>1. \u8de8\u5e73\u53f0\uff1aElectron\u53ef\u4ee5\u5728Windows\u3001macOS\u548cLinux\u7b49\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\u8fd0\u884c\u3002<\/p>\n<p>2. Web\u6280\u672f\uff1aElectron\u4f7f\u7528Web\u6280\u672f\u6765\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\uff0c\u8fd9\u4f7f\u5f97\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u4f7f\u7528\u719f\u6089\u7684\u6280\u672f\u6765\u521b\u5efa\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>3. \u793e\u533a\u652f\u6301\uff1aElectron\u62e5\u6709\u4e00\u4e2a\u5e9e\u5927\u7684\u793e\u533a\uff0c\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u4ece\u4e2d\u83b7\u5f97\u652f\u6301\u548c\u5e2e\u52a9\u3002<\/p>\n<p>4. \u5f3a\u5927\u7684\u529f\u80fd\uff1aElectron\u652f\u6301\u5e73\u53f0\u672c\u673a\u5e94\u7528\u7a0b\u5e8f\u7684\u529f\u80fd\uff0c\u5982\u6587\u4ef6\u7cfb\u7edf\u548c\u64cd\u4f5c\u7cfb\u7edfAPI\u7b49\u3002<\/p>\n<p>\u56db\u3001Electron\u6846\u67b6\u7684\u7f3a\u70b9<\/p>\n<p>1. \u5927\u5c0f\uff1aElectron\u5e94\u7528\u7a0b\u5e8f\u76f8\u5bf9\u8f83\u5927\uff0c\u56e0\u4e3a\u5b83\u9700\u8981\u5305\u542bChromium\u7b49\u5e93\u3002<\/p>\n<p>2. \u6027\u80fd\uff1a\u7531\u4e8eElectron\u5e94\u7528\u7a0b\u5e8f\u4f7f\u7528Chromium\u4f5c\u4e3a\u5176\u8fd0\u884c\u65f6\u73af\u5883\uff0c\u56e0\u6b64\u53ef\u80fd\u4f1a\u5360\u7528\u5927\u91cf\u5185\u5b58\u548cCPU\u3002<\/p>\n<p>\u603b\u4e4b\uff0cElectron\u6846\u67b6\u4e3a\u5f00\u53d1\u4eba\u5458\u63d0\u4f9b\u4e86\u4e00\u79cd\u4f7f\u7528Web\u6280\u672f\u5f00\u53d1\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u7684\u7b80\u5355\u65b9\u6cd5\u3002\u4f7f\u7528Electro<a href=\"https:\/\/exe.yimenapp.com\/tool-43.html\">exe\u6587\u4ef6\u6346\u7ed1<\/a>n\uff0c\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u521b\u5efa\u8de8\u5e73<a href=\"https:\/\/exe.yimenapp.com\/tool-1972.html\">html\u6253\u5305\u6210exe\u53ef\u4ee5\u8fdb\u884chttp<\/a>\u53f0\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u83b7\u5f97\u5e73\u53f0\u672c\u673a\u5e94\u7528\u7a0b\u5e8f\u7684\u529f\u80fd\u3002\u867d\u7136Electron\u5e94\u7528\u7a0b\u5e8f\u53ef\u80fd\u4f1a\u76f8\u5bf9\u8f83\u5927\uff0c\u5e76\u4e14\u53ef\u80fd\u4f1a\u5360\u7528\u5927\u91cf\u5185\u5b58\u548cCPU\uff0c\u4f46\u662f\u5b83\u4eec\u53ef\u4ee5\u63d0\u4f9b\u66f4\u597d\u7684\u7528\u6237\u4f53\u9a8c\uff0c\u56e0\u4e3a\u5b83\u4eec\u53ef\u4ee5\u4f7f\u7528Web\u6280\u672f\u6765\u521b\u5efa\u7f8e\u89c2\u548c\u4ea4\u4e92\u6027\u5f3a\u7684\u7528\u6237\u754c\u9762\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u7aef\u5f00\u53d1\u684c\u9762\u5e94\u7528\u662f\u4e00\u79cd\u975e\u5e38\u6d41\u884c\u7684\u6280\u672f\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u5c06Web\u6280\u672f\u4e0e\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u7ed3\u5408\u8d77\u6765\uff0c\u4ece\u800c\u4e3a\u7528\u6237\u63d0\u4f9b\u66f4\u597d\u7684\u7528\u6237\u4f53\u9a8c\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Electron\u6846\u67b6\u5f00\u53d1\u7a97\u53e3\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002\u4e00\u3001\u4ec0\u4e48\u662fElectro<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[24027,929,11,338,21634],"topic":[],"class_list":["post-44426","post","type-post","status-publish","format-standard","hentry","category-ruanjiankf","tag-macwine","tag-929","tag-11","tag-338","tag-pc"],"_links":{"self":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/44426","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\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/comments?post=44426"}],"version-history":[{"count":1,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/44426\/revisions"}],"predecessor-version":[{"id":44430,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/44426\/revisions\/44430"}],"wp:attachment":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/media?parent=44426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/categories?post=44426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/tags?post=44426"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/topic?post=44426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}