{"id":18843,"date":"2024-03-15T09:42:42","date_gmt":"2024-03-15T01:42:42","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=18843"},"modified":"2024-03-15T09:42:42","modified_gmt":"2024-03-15T01:42:42","slug":"web%e8%bd%ac%e6%a1%8c%e9%9d%a2%e5%ba%94%e7%94%a8%e6%93%8d%e4%bd%9c%e5%8a%9e%e6%b3%95%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/18843\/","title":{"rendered":"web\u8f6c\u684c\u9762\u5e94\u7528\u64cd\u4f5c\u529e\u6cd5\u4ecb\u7ecd"},"content":{"rendered":"<p>\u968f\u7740\u4e92\u8054\u7f51\u6280\u672f\u7684\u53d1\u5c55\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u5e94\u7528\u7a0b\u5e8f\u90fd\u662f\u57fa\u4e8eWeb\u6280\u672f\u6765\u5f00\u53d1\u7684\u3002Web\u5e94\u7528\u5177\u6709\u8de8\u5e73\u53f0\u3001\u6613\u7ef4\u62a4\u3001\u6613\u90e8\u7f72\u7b49\u4f18\u70b9\uff0c\u53d7\u5230\u4e86\u5e7f\u6cdb\u7684\u5e94\u7528\u3002\u4f46\u662f\uff0cWeb\u5e94\u7528\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\u4e5f\u5b58\u5728\u4e00\u4e9b\u4e0d\u8db3\uff0c\u6bd4\u5982\u79bb\u7ebf\u4f7f\u7528\u3001\u7cfb\u7edf\u7ea7\u522b\u7684\u529f\u80fd\u7b49\u3002\u8fd9\u65f6\u5019\uff0c\u5c06Web\u5e94\u7528\u8f6c\u6362\u4e3a\u684c\u9762\u5e94\u7528\u5c31\u663e\u5f97\u5c24\u4e3a\u91cd\u8981\u3002\u672c\u6587\u5c06\u4ece\u539f\u7406\u548c\u8be6\u7ec6\u4ecb\u7ecd\u4e24\u4e2a\u65b9\u9762\uff0c\u4ecb\u7ecd\u5982\u4f55\u5c06Web\u5e94\u7528\u8f6c\u6362\u4e3a\u684c\u9762\u5e94\u7528\u3002<\/p>\n<p>\u4e00\u3001\u539f\u7406<\/p>\n<p>\u5c06Web\u5e94\u7528\u8f6c\u6362\u4e3a\u684c\u9762\u5e94\u7528\u7684\u539f\u7406\u662f\u901a\u8fc7\u5c06Web\u5e94\u7528\u5305\u88c5\u6210\u4e00\u4e2a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u6765\u5b9e\u73b0\u3002\u8fd9\u4e2a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u4f1a\u5728\u7528\u6237\u7684\u8bbe\u5907\u4e0a\u8fd0\u884c\uff0c\u800c\u4e0d\u662f\u5728Web\u6d4f\u89c8\u5668\u4e2d\u3002\u8fd9\u4e2a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u4f1a\u901a\u8fc7Web\u89c6\u56fe\u6765\u52a0\u8f7dWeb\u5e94\u7528\uff0c\u5e76\u5c06Web\u5e94\u7528\u7684\u754c\u9762\u548c\u529f\u80fd\u5448\u73b0\u7ed9\u7528\u6237\u3002<\/p>\n<p>\u5177\u4f53\u6765\u8bf4\uff0c\u5c06Web\u5e94\u7528\u8f6c\u6362\u4e3a\u684c\u9762\u5e94\u7528\u9700\u8981\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p>1. \u521b\u5efa\u4e00\u4e2a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u6846\u67b6\uff1a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u6846\u67b6\u662f\u4e00\u4e2a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\uff0c\u5b83\u7684\u4f5c\u7528\u662f\u5c06Web\u5e94\u7528\u5305\u88c5\u6210\u4e00\u4e2a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u6846\u67b6\u8d1f\u8d23\u52a0\u8f7dWeb\u89c6\u56fe\uff0c\u5e76\u5c06Web\u5e94\u7528\u7684\u754c\u9762\u548c\u529f\u80fd\u5448\u73b0\u7ed9\u7528\u6237\u3002<\/p>\n<p>2. \u5c06Web\u5e94\u7528\u6253\u5305\u4e3a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\uff1a\u5c06Web\u5e94\u7528\u6253\u5305\u4e3a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u9700\u8981\u4f7f\u7528\u76f8\u5173\u7684\u5de5\u5177\u548c\u6280\u672f\u3002\u6253\u5305\u7684\u8fc7\u7a0b\u4e2d\u9700\u8981\u5c06Web\u5e94\u7528\u7684\u6240\u6709\u6587\u4ef6\u6253\u5305\u5230\u4e00\u4e2a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u5e76\u5c06\u5176\u4e0e\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u6846<a href=\"https:\/\/exe.yimenapp.com\/tool-1574.html\">\u9879\u76ee\u6253\u5305\u6210exe\u8f6f\u4ef6<\/a>\u67b6\u5173\u8054\u3002<\/p>\n<p>3. \u5b89\u88c5\u548c\u8fd0\u884c\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\uff1a\u5b89\u88c5\u548c\u8fd0\u884c\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u9700\u8981\u7528\u6237\u624b\u52a8\u5b8c\u6210\u3002\u7528\u6237\u9700\u8981\u4e0b\u8f7d\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5c06\u5176\u5b89\u88c5\u5230\u81ea\u5df1\u7684\u8bbe\u5907\u4e0a\u3002\u4e4b\u540e\u7528\u6237\u53ef\u4ee5\u50cf\u8fd0\u884c\u5176\u4ed6\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u4e00\u6837\u8fd0\u884c\u8be5\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u4e8c\u3001\u8be6\u7ec6\u4ecb\u7ecd<\/p>\n<p>\u5c06Web\u5e94\u7528\u8f6c\u6362\u4e3a\u684c\u9762\u5e94\u7528\u7684\u5177\u4f53\u5b9e\u73b0\u65b9\u5f0f\u6709\u591a\u79cd\uff0c\u4e0b\u9762\u4ecb\u7ecd\u5176\u4e2d\u4e00\u79cd\u6bd4\u8f83\u5e38\u7528\u7684\u65b9\u5f0f\u3002<\/p>\n<p>1. \u4f7f\u7528Electron\u6253\u5305Web\u5e94\u7528<\/p>\n<p>Electron\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u6846\u67b6\uff0c\u5b83\u53ef\u4ee5\u5c06Web\u5e94\u7528\u6253\u5305\u4e3a\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002Electron\u7684\u539f\u7406\u662f\u901a\u8fc7\u5c06Web\u5e94\u7528\u6253\u5305\u5230\u4e00\u4e2a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u5e76\u4f7f\u7528Chromium\u4f5c\u4e3aWeb\u89c6\u56fe\uff0c\u4f7f\u5f97Web\u5e94\u7528\u53ef\u4ee5\u50cf\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u4e00\u6837\u8fd0\u884c\u3002<\/p>\n<p>\u4f7f\u7528Electron\u6253\u5305Web\u5e94\u7528\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<p>\uff081\uff09\u5b89\u88c5Electron<\/p>\n<p>\u4f7f\u7528npm\u5b89\u88c5Electron\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>npm install electron &#8211;save-dev<\/p>\n<p>&#8220;`<\/p>\n<p>\uff082\uff09\u521b\u5efaElectron\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u521b\u5efa\u4e00\u4e2aElectron\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>  app.on(&#8216;activate&#8217;, () =&gt; {<\/p>\n<p>    if (BrowserWindow.getAllWindows().length === 0) {<\/p>\n<p>      createWindow()<\/p>\n<p>    }<\/p>\n<p>  })<\/p>\n<p>})<\/p>\n<p>app.on(&#8216;window-all-cl<a href=\"https:\/\/exe.yimenapp.com\/tool-763.html\">\u524d\u7aefvue\u9879\u76ee\u6253\u5305\u6210exe<\/a>osed&#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>\uff083\uff09\u6253\u5305Web\u5e94\u7528<\/p>\n<p>\u4f7f\u7528Electron-builder\u6253\u5305Web\u5e94\u7528\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>npm install electron-builder &#8211;save-dev<\/p>\n<p>&#8220;`<\/p>\n<p>\u914d\u7f6eElectron-builder\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>{<\/p>\n<p>  &#8220;name&#8221;: &#8220;my-app&#8221;,<\/p>\n<p>  &#8220;version&#8221;: &#8220;1.0.0&#8221;,<\/p>\n<p>  &#8220;description&#8221;: &#8220;My App&#8221;,<\/p>\n<p>  &#8220;main&#8221;: &#8220;main.js&#8221;,<\/p>\n<p>  &#8220;scripts&#8221;: {<\/p>\n<p>    &#8220;start&#8221;: &#8220;electron .&#8221;,<\/p>\n<p>    &#8220;pack&#8221;: &#8220;electron-builder &#8211;dir&#8221;,<\/p>\n<p>    &#8220;dist&#8221;: &#8220;electron-builder&#8221;<\/p>\n<p>  },<\/p>\n<p>  &#8220;author&#8221;: &#8220;My Name&#8221;,<\/p>\n<p>  &#8220;license&#8221;: &#8220;MIT&#8221;,<\/p>\n<p>  &#8220;devDependencies&#8221;: {<\/p>\n<p>    &#8220;electron&#8221;: &#8220;^12.0.0&#8221;,<\/p>\n<p>    &#8220;electron-builder&#8221;: &#8220;^22.10.5&#8221;<\/p>\n<p>  },<\/p>\n<p>  &#8220;build&#8221;: {<\/p>\n<p>    &#8220;appId&#8221;: &#8220;com.example.myapp&#8221;,<\/p>\n<p>    &#8220;productName&#8221;: &#8220;My App&#8221;,<\/p>\n<p>    &#8220;directories&#8221;: {<\/p>\n<p>      &#8220;output&#8221;: &#8220;dist&#8221;<\/p>\n<p>    },<\/p>\n<p>    &#8220;win&#8221;: {<\/p>\n<p>      &#8220;target&#8221;: &#8220;nsis&#8221;<\/p>\n<p>    },<\/p>\n<p>    &#8220;nsis&#8221;: {<\/p>\n<p>      &#8220;oneClick&#8221;: false,<\/p>\n<p>      &#8220;allowElevation&#8221;: true,<\/p>\n<p>      &#8220;allowToChangeInstallationDirectory&#8221;: true,<\/p>\n<p>      &#8220;installerIcon&#8221;: &#8220;build\/icon.ico&#8221;,<\/p>\n<p>      &#8220;uninstallerIcon&#8221;: &#8220;build\/icon.ico&#8221;,<\/p>\n<p>      &#8220;installerHeaderIcon&#8221;: &#8220;build\/icon.ico&#8221;,<\/p>\n<p>      &#8220;createDesktopShortcut&#8221;: true,<\/p>\n<p>      &#8220;createStartMenuShortcut&#8221;: true,<\/p>\n<p>      &#8220;shortcutName&#8221;: &#8220;My App&#8221;<\/p>\n<p>    }<\/p>\n<p>  }<\/p>\n<p>}<\/p>\n<p>&#8220;`<\/p>\n<p>\u6253\u5305Web\u5e94\u7528\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>npm run dist<\/p>\n<p>&#8220;<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.yimenyun.net\/2023-03\/23\/10\/03711276817.jpg\" \/><\/figure>\n<\/p>\n<p>`<\/p>\n<p>2. \u4f7f\u7528NW.js\u6253\u5305Web\u5e94\u7528<\/p>\n<p>NW.js\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u6846\u67b6\uff0c\u5b83\u53ef\u4ee5\u5c06Web\u5e94\u7528\u6253\u5305\u4e3a\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002NW.js\u7684\u539f\u7406\u548cElectron\u7c7b\u4f3c\uff0c\u4e5f\u662f\u901a\u8fc7\u5c06Web\u5e94\u7528\u6253\u5305\u5230\u4e00\u4e2a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u5e76\u4f7f\u7528Chromium\u4f5c\u4e3aWeb\u89c6\u56fe\uff0c\u4f7f\u5f97Web\u5e94\u7528\u53ef\u4ee5\u50cf\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u4e00\u6837\u8fd0\u884c\u3002<\/p>\n<p>\u4f7f\u7528NW.js\u6253\u5305Web\u5e94\u7528\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<p>\uff081\uff09\u5b89\u88c5NW.js<\/p>\n<p>\u4e0b\u8f7dNW.js\u5b89\u88c5\u5305\u5e76\u5b89\u88c5\u3002<\/p>\n<p>\uff082\uff09\u521b\u5efaNW.js\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u521b\u5efa\u4e00\u4e2aNW.js\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>{<\/p>\n<p>  &#8220;name<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u968f\u7740\u4e92\u8054\u7f51\u6280\u672f\u7684\u53d1\u5c55\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u5e94\u7528\u7a0b\u5e8f\u90fd\u662f\u57fa\u4e8eWeb\u6280\u672f\u6765\u5f00\u53d1\u7684\u3002Web\u5e94\u7528\u5177\u6709\u8de8\u5e73\u53f0\u3001\u6613\u7ef4\u62a4\u3001\u6613\u90e8\u7f72\u7b49\u4f18\u70b9\uff0c\u53d7\u5230\u4e86\u5e7f\u6cdb\u7684\u5e94\u7528\u3002\u4f46\u662f\uff0cWeb\u5e94\u7528\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\u4e5f\u5b58\u5728\u4e00\u4e9b\u4e0d\u8db3\uff0c\u6bd4\u5982\u79bb\u7ebf\u4f7f\u7528\u3001\u7cfb\u7edf\u7ea7\u522b\u7684<\/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":[19427,10533,12,3048,300],"topic":[],"class_list":["post-18843","post","type-post","status-publish","format-standard","hentry","category-exekf","tag-windows10","tag-exe","tag-12","tag-3048","tag-300"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/18843","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=18843"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/18843\/revisions"}],"predecessor-version":[{"id":18850,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/18843\/revisions\/18850"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=18843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=18843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=18843"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=18843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}