{"id":15842,"date":"2024-01-16T15:43:22","date_gmt":"2024-01-16T07:43:22","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=15842"},"modified":"2024-01-16T15:43:22","modified_gmt":"2024-01-16T07:43:22","slug":"vue%e6%89%93%e5%8c%85%e6%88%90%e5%8f%af%e4%bb%a5%e7%9b%b4%e6%8e%a5%e8%bf%90%e8%a1%8c%e7%9a%84exe%e5%a6%82%e4%bd%95%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/15842\/","title":{"rendered":"vue\u6253\u5305\u6210\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c\u7684exe\u5982\u4f55\u64cd\u4f5c"},"content":{"rendered":"

\u82f9\u679c\u7535\u8111\u7528exe\u8f6f\u4ef6<\/a> <\/p>\n

Vue\u662f\u4e00\u4e2a\u6d41\u884c\u7684JavaScript\u6846\u67b6\uff0c\u7528\u4e8e\u6784\u5efa\u73b0\u4ee3\u5355\u9875\u9762\u5e94\u7528\u7a0b\u5e8f\uff08SPA\uff09\u3002Vue\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u5728Web\u6d4f\u89c8\u5668\u4e2d\u8fd0\u884c\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528Electron\u5c06\u5176\u6253\u5305\u6210\u53ef\u5728\u684c\u9762\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Electron\u5c06Vue\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u53ef\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff08exe\uff09\u3002<\/p>\n

Electron\u662f\u4e00\u4e2a\u5f00\u6e90\u6846\u67b6\uff0c\u7528\u4e8e\u6784\u5efa\u8de8\u5e73\u53f0\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u57fa\u4e8eNode.js\u548cChromium\uff0c\u5141\u8bb8\u4f7f\u7528Web\u6280\u672f\uff08HTML\uff0cCSS\u548cJavaScript\uff09\u6784\u5efa\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002Electron\u63d0\u4f9b\u4e86\u4e00\u4e2a\u540d\u4e3aElectron Builder\u7684\u63d2\u4ef6\uff0c\u5b83\u53ef\u4ee5\u5c06Electron\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u53ef\u5728Windows\uff0cmacOS\u548cLinux\u4e0a\u8fd0\u884c\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u4e0b\u9762\u662f\u5c06Vue\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\u7684\u6b65\u9aa4\uff1a<\/p>\n

1. \u5b89\u88c5Electron\u548cElectron Builder<\/p>\n

\u5728\u547d\u4ee4\u884c\u4e2dpc\u5ba2\u6237\u7aef\u5f00\u53d1\u8f6f\u4ef6<\/a>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5Electron\u548cElectron Builder\uff1a<\/p>\n

“`<\/p>\n

npm install –save-dev electron electron-builder<\/p>\n

“`<\/p>\n

2. \u914d\u7f6epackage.json<\/p>\n

\u5728package.json\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff1a<\/p>\n

“`<\/p>\n

“build”: {<\/p>\n

“productName”: “My App”,<\/p>\n

“appId”: “com.myapp”,<\/p>\n

“directories”: {<\/p>\n

“output”: “dist”<\/p>\n

},<\/p>\n

“files”: [<\/p>\n

“dist\/**\/*”,<\/p>\n

“node_modules\/**\/*”<\/p>\n

],<\/p>\n

“win”: {<\/p>\n

\n

<\/figure>\n<\/p>\n

“target”: “nsis”<\/p>\n

}<\/p>\n

}<\/p>\n

“`<\/p>\n

\u8fd9\u4e9b\u914d\u7f6e\u6307\u5b9a\u4e86\u5e94\u7528\u7a0b\u5e8f\u7684\u540d\u79f0\uff0cID\uff0c\u8f93\u51fa\u76ee\u5f55\uff0c\u8981\u5305\u542b\u7684\u6587\u4ef6\u4ee5\u53ca\u8981\u6784\u5efa\u7684Windows\u76ee\u6807\uff08nsis\u8868\u793a\u4f7f\u7528Nullsoft Scriptable Install System\u6784\u5efa\u5b89\u88c5\u7a0b\u5e8f\uff09\u3002<\/p>\n

3. \u6784\u5efaVue\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u6784\u5efaVue\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n

“`<\/p>\n

npm run build<\/p>\n

“`<\/p>\n

\u8fd9\u5c06\u5728dist\u76ee\u5f55\u4e2d\u751f\u6210\u7f16\u8bd1\u540e\u7684Vue\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

4. \u6253\u5305Electron\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u6253\u5305Electron\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n

“`<\/p>\n

npm run electron:build<\/p>\n

“`<\/p>\n

\u8fd9\u5c06\u4f7f\u7528Electron Builder\u5c06Vue\u5e94\u7528\u7a0b\u5e8f\u548cElectron\u6846\u67b6\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002\u6253\u5305\u5b8c\u6210\u540e\uff0c\u53ef\u6267\u884c\u6587\u4ef6\u5c06\u4f4d\u4e8edist\u76ee\u5f55\u4e2d\u7684win-unpacked\u6587\u4ef6\u5939\u4e2d\u3002<\/p>\n

5. \u5b89\u88c5\u548c\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u5728dist\u76ee\u5f55\u4e2d\uff0c\u53cc\u51fb\u53ef\u6267\u884c\u6587\u4ef6\u8fdb\u884c\u5b89\u88c5\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c\u8be5\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

\u8fd9\u5c31\u662f\u5c06Vue\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u53ef\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c\u7684\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8fc7\u7a0b\u3002\u4f7f\u7528\u7c7b\u4f3c\u7684\u6b65\u9aa4\uff0c\u4e5f\u53ef\u4ee5\u5c06Vue\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u53ef\u5728macOS\u548cLinux\u4e0a\u8fd0\u884c\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Vue\u662f\u4e00\u4e2a\u6d41\u884c\u7684JavaScript\u6846\u67b6\uff0c\u7528\u4e8e\u6784\u5efa\u73b0\u4ee3\u5355\u9875\u9762\u5e94\u7528\u7a0b\u5e8f\uff08SPA\uff09\u3002Vue\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u5728Web\u6d4f\u89c8\u5668\u4e2d\u8fd0\u884c\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528Electron\u5c06\u5176\u6253\u5305\u6210\u53ef\u5728\u684c\u9762\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c06<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[19506,19507,256,19508,12],"topic":[],"class_list":["post-15842","post","type-post","status-publish","format-standard","hentry","category-exekf","tag-19506","tag-19507","tag-256","tag-dmg","tag-12"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/15842","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\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=15842"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/15842\/revisions"}],"predecessor-version":[{"id":15844,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/15842\/revisions\/15844"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=15842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=15842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=15842"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=15842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}