exe\u5c01\u88c5revit<\/a>\u5176\u4e2d\u7f16\u5199\u4ee5\u4e0b\u4ee3\u7801\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
app.on(‘activate’, () => {<\/p>\n
if (BrowserWindow.getAllWindows().length === 0) {<\/p>\n
createWindow()<\/p>\n
}<\/p>\n
})<\/p>\n
})<\/p>\n
app.on(‘window-all-closed’, () => {<\/p>\n
if (process.platform !== ‘darwin’) {<\/p>\n
app.quit()<\/p>\n
}<\/p>\n
})<\/p>\n
“`<\/p>\n
\u8fd9\u4e2a\u4ee3\u7801\u4f1a\u521b\u5efa\u4e00\u4e2aElectron\u7a97\u53e3\uff0c\u5e76\u52a0\u8f7d\u540d\u4e3aindex.html\u7684\u6587\u4ef6\u3002\u6211\u4eec\u53ef\u4ee5\u5728\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u7f16\u5199\u6211\u4eec\u7684H5\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u3002<\/p>\n
5. \u6253\u5305\u5e94\u7528\u7a0b\u5e8f<\/p>\n
\u7f16\u5199\u5b8c\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u4e4b\u540e\uff0c\u6211\u4eec\u9700\u8981\u5c06\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u4e3a\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u3002\u53ef\u4ee5\u4f7f\u7528Electron Builder\u6765\u5b8c\u6210\u6253\u5305\u3002<\/p>\n
\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5Electron Builder\u3002\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n
“`<\/p>\n
npm install electron-builder –save-dev<\/p>\n
“`<\/p>\n
\u7136\u540e\uff0c\u5728package.json\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n
“`<\/p>\n
“build”: {<\/p>\n
“appId”: “com.example.myapp”,<\/p>\n
“productName”: “My App”,<\/p>\n
“directories”: {<\/p>\n
“output”: “dist”<\/p>\n
},<\/p>\n
“win”: {<\/p>\n
“target”: “nsis”<\/p>\n
}<\/p>\n
}<\/p>\n
“`<\/p>\n
\u8fd9\u4e2a\u4ee3\u7801\u4f1a\u544a\u8bc9Electron Builder\u5982\u4f55\u6253\u5305\u6211\u4eec\u7684<\/p>\n
<\/figure>\n<\/p>\n\u5e94\u7528\u7a0b\u5e8f\u3002\u5176\u4e2d\uff0cappId\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u552f\u4e00\u6807\u8bc6\u7b26\uff0cproductName\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u540d\u79f0\uff0cdirectories.output\u662f\u8f93\u51fa\u76ee\u5f55\uff0cwin.target\u662f\u6253\u5305\u7684\u76ee\u6807\u5e73\u53f0\u3002<\/p>\n
\u5b8c\u6210\u4ee5\u4e0a\u64cd\u4f5c\u540e\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u6253\u5305\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n
“`<\/p>\n
npm run dist<\/p>\n
“`<\/p>\n
\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u5c06\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u4e3a\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5e76\u5b58\u50a8\u5728dist\u76ee\u5f55\u4e2d\u3002<\/p>\n
6. \u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f<\/p>\n
\u6253\u5305\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u53cc\u51fb\u53ef\u6267\u884c\u6587\u4ef6\u6765\u8fd0\u884c\u6211\u4eec\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u8fd9\u4e2a\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u5728Windows\u7cfb\u7edf\u4e2d\u8fd0\u884c\uff0c\u800c\u4e0d\u9700\u8981\u4f9d\u8d56\u4e8e\u4efb\u4f55\u6d4f\u89c8\u5668\u3002<\/p>\n
\u603b\u7ed3<\/p>\n
\u4ee5\u4e0a\u5c31\u662f\u5c06H5\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3aEXE\u7684\u539f\u7406\u548c\u8be6\u7ec6\u4ecb\u7ecd\u3002\u901a\u8fc7\u4f7f\u7528Electron\u6846\u67b6\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u5c06H5\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u4e3a\u4e00\u4e2a\u5305\u542b\u6d4f\u89c8\u5668\u5185\u6838\u7684\u5355\u72ec\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5728Windows\u7cfb\u7edf\u4e2d\u8fd0\u884c\u3002\u5e0c\u671b\u672c\u6587\u53ef\u4ee5\u5e2e\u52a9\u5230\u5927\u5bb6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
HTML5\u662f\u4e00\u79cd\u57fa\u4e8eWeb\u7684\u6280\u672f\uff0c\u5b83\u53ef\u4ee5\u4e3a\u7528\u6237\u63d0\u4f9b\u66f4\u52a0\u4e30\u5bcc\u7684\u7f51\u9875\u4f53\u9a8c\u3002\u800cEXE\u5219\u662fWindows\u64cd\u4f5c\u7cfb\u7edf\u4e0b\u7684\u53ef\u6267\u884c\u6587\u4ef6\u683c\u5f0f\u3002\u56e0\u6b64\uff0c\u5c06H5\u8f6c\u6362\u4e3aEXE\u53ef\u4ee5\u8ba9\u6211\u4eec\u5728Windows\u7cfb\u7edf\u4e2d\u8fd0\u884cH5\u5e94\u7528\u7a0b\u5e8f\uff0c<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[2265,24,116,41,5505],"topic":[],"class_list":["post-2664","post","type-post","status-publish","format-standard","hentry","category-zhuomianruanjian","tag-phpexe","tag-24","tag-116","tag-41","tag-5505"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/2664","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\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/comments?post=2664"}],"version-history":[{"count":0,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/2664\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/media?parent=2664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/categories?post=2664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/tags?post=2664"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/topic?post=2664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}