winform\u6253\u5305<\/a>e.json\u6587\u4ef6\u4e2d\u3002<\/p>\n3. \u521b\u5efa\u5e94\u7528\u7a0b\u5e8f<\/p>\n
\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6587\u4ef6\u5939\u6765\u5b58\u653e\u5e94\u7528\u7a0b\u5e8f\u6587\u4ef6\u3002\u5728\u8be5\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684package.json\u6587\u4ef6\u3002\u8fd9\u4e2a\u6587\u4ef6\u662f\u7528\u6765\u63cf\u8ff0\u5e94\u7528\u7a0b\u5e8f\u7684\u5143\u6570\u636e\u7684\u3002\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n
“`<\/p>\n
{<\/p>\n
“name”: “MyApp”,<\/p>\n
“version”: “1.0.0”,<\/p>\n
“description”: “My first Electron application”,<\/p>\n
“main”: “main.js”,<\/p>\n
“scripts”: {<\/p>\n
“start”: “electron .”<\/p>\n
},<\/p>\n
“keywords”: [],<\/p>\n
“author”: “”,<\/p>\n
“license”: “ISC”,<\/p>\n
“dependencies”: {<\/p>\n
“electron”: “^11.0.0”<\/p>\n
}<\/p>\n
}<\/p>\n
“`<\/p>\n
\u5176\u4e2d\uff0cname\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u540d\u79f0\uff0cversion\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u7248\u672c\u53f7\uff0cdescription\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u63cf\u8ff0\uff0cmain\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u5165\u53e3\u6587\u4ef6\uff0cscripts\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u811a\u672c\uff0cdependencies\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u4f9d\u8d56\u9879\u3002<\/p>\n
4. \u521b\u5efa\u4e3b\u8fdb\u7a0b<\/p>\n
\u5728\u5e94\u7528\u7a0b\u5e8f\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3amain.js\u7684\u6587\u4ef6\u3002\u8fd9\u4e2a\u6587\u4ef6\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u4e3b\u8fdb\u7a0b\u3002\u5728\u8fd9\u4e2a\u6587\u4ef6\u4e2d\uff0c\u9700\u8981\u521b\u5efa\u4e00\u4e2aBrowserWindow\u5bf9\u8c61\u6765\u663e\u793aWeb\u5e94\u7528\u7a0b\u5e8f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n
“`<\/p>\n
const { app, BrowserWindow } = require(‘electron’)<\/p>\n
function createWindow () {<\/p>\n
const win = new BrowserWindow({<\/p>\n
width: 800,<\/p>\n
height: 600,<\/p>\n
webPreferences: {<\/p>\n
nodeIntegration: true<\/p>\n
}<\/p>\n
})<\/p>\n
win.loadFile(‘index.html’)<\/p>\n
}<\/p>\n
app.whenReady().then(() => {<\/p>\n
createWindow()<\/p>\n
})<\/p>\n
“`<\/p>\n
\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2aBrowserWindow\u5bf9\u8c61\uff0c\u5e76\u8bbe\u7f6e\u4e86\u5b83\u7684\u5927\u5c0f\u548cWebPreferences\u3002\u7136\u540e\uff0c\u6211\u4eec\u52a0\u8f7d\u4e86\u4e00\u4e2a\u540d\u4e3aindex.html\u7684\u6587\u4ef6\u3002\u8fd9\u4e2a\u6587\u4ef6\u662fWeb\u5e94\u7528\u7a0b\u5e8f\u7684\u5165\u53e3\u6587\u4ef6\u3002<\/p>\n
5. \u6253\u5305\u5e94\u7528\u7a0b\u5e8f<\/p>\n
\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u6253\u5305\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n
“`<\/p>\n
electron-packager . MyApp –platform=win32 –arch=x64 –icon=icon.ico –overwrite<\/p>\n
“`<\/p>\n
\u8fd9\u4e2a\u547d\u4ee4\u5c06\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u4e3a\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5176\u4e2d\uff0c.\u8868\u793a\u5f53\u524d\u6587\u4ef6\u5939\uff0cMyApp\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u540d\u79f0\uff0c–platform\u6307\u5b9a\u4e86\u6253\u5305\u7684\u5e73\u53f0\uff0c–arch\u6307\u5b9a\u4e86\u6253\u5305\u7684\u67b6\u6784\uff0c–icon\u6307\u5b9a\u4e86\u5e94\u7528\u7a0b\u5e8f\u7684\u56fe\u6807\uff0c–overwrite\u6307\u5b9a\u4e86\u662f\u5426\u8986\u76d6\u5df2\u6709\u6587\u4ef6\u3002<\/p>\n
6. \u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f<\/p>\n
\u6253\u5305\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5728dist\u6587\u4ef6\u5939\u4e2d\u627e\u5230\u5e94\u7528\u7a0b\u5e8f\u3002\u53cc\u51fb\u5e94\u7528\u7a0b\u5e8f\u5373\u53ef\u8fd0\u884c\u3002<\/p>\n
\u603b\u7ed3<\/p>\n
Web\u6253\u5305PC\u662f\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u4e3a\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u7684\u8fc7\u7a0b\u3002\u5b83\u7684\u539f\u7406\u662f\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u8fd0\u884c\u5728\u4e00\u4e2a\u5185\u7f6e\u7684Chrome\u6d4f\u89c8\u5668\u4e2d\uff0c\u7136\u540e\u5c06\u5176\u5305\u88c5\u4e3a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u3002\u4f7f\u7528Electron\u53ef\u4ee5\u65b9\u4fbf\u5730\u5b9e\u73b0Web\u6253\u5305PC\u3002\u901a\u8fc7\u5b89\u88c5Node.js\u548cElectron\uff0c\u521b\u5efa\u5e94\u7528\u7a0b\u5e8f\u548c\u4e3b\u8fdb\u7a0b\uff0c\u6253\u5305\u5e94\u7528\u7a0b\u5e8f\u548c\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u7b49\u6b65\u9aa4\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u4e3a\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
Web\u6253\u5305PC\u662f\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u4e3a\u53ef\u5728PC\u4e0a\u8fd0\u884c\u7684\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u7684\u8fc7\u7a0b\u3002\u8fd9\u79cd\u5e94\u7528\u7a0b\u5e8f\u901a\u5e38\u662f\u4f7f\u7528Web\u6280\u672f\u548c\u8bed\u8a00\uff08\u5982HTML\uff0cJavaScript\u548cCSS\uff09\u7f16\u5199\u7684\uff0c\u5e76\u4f7f\u7528\u6846\u67b6\uff08\u5982Electron\uff09\u5c06<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[20548,116,11576,12,849],"topic":[],"class_list":["post-17789","post","type-post","status-publish","format-standard","hentry","category-zhuomianruanjian","tag-epub","tag-116","tag-exe","tag-12","tag-849"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/17789","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/comments?post=17789"}],"version-history":[{"count":0,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/17789\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/media?parent=17789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/categories?post=17789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/tags?post=17789"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/topic?post=17789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}