Electron: 如何以 Vue.js, Vuetify 开始应用 (2)

命令定义在了 package.json :

{ ... "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint", "electron:build": "vue-cli-service electron:build", "electron:serve": "vue-cli-service electron:serve", "postinstall": "electron-builder install-app-deps", "postuninstall": "electron-builder install-app-deps" }, ... }

yarn 执行即可,如下:

$ yarn lint yarn run v1.22.4 $ vue-cli-service lint DONE No lint errors found! ✨ Done in 3.17s. yarn add @types/node@12 --dev 是为了修正如下错误 ERROR in /Users/John/Codes/ikuokuo/start-electron/my-app/node_modules/electron/electron.d.ts(1659,31): 1659:31 Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'? ... 编辑 src/router/index.ts 是为了修正如下警告 WARN It is detected that you are using Vue Router. If you are using history mode, you must push the default route when the root component is loaded. Learn more at https://goo.gl/GM1xZG . 发布 Electron 应用

Vue 应用了 Electron Builder 插件,所以直接用此工具即可。

GitHub: https://github.com/electron-userland/electron-builder

yarn electron:build 编译发布:

# 淘宝镜像,国内下载 Electron 更快 export ELECTRON_MIRROR="https://cdn.npm.taobao.org/dist/electron/" # macOS 下禁用签名。若要签名,见最后参考 export CSC_IDENTITY_AUTO_DISCOVERY=false cd my-app yarn electron:build

dist_electron/ 下即是发布内容。

例如 macOS 可见打包好的 dmg :

Electron: 如何以 Vue.js, Vuetify 开始应用

双击 dmg 试用或安装:

Electron: 如何以 Vue.js, Vuetify 开始应用

若要修改发布格式或内容,见 Electron Builder 文档: https://www.electron.build/ 。

export CSC_IDENTITY_AUTO_DISCOVERY=false 是为了避免如下错误 ... • signing file=dist_electron/mac/my-app.app identityName=gdb_codesign identityHash=BC899AF362F80B3FDB39F966A1601E2AFAFA100B provisioningProfile=none (node:10223) UnhandledPromiseRejectionWarning: Error: Command failed: codesign --sign BC899AF362F80B3FDB39F966A1601E2AFAFA100B --force --timestamp --options runtime --entitlements /Users/John/Workspace/Codes/start-electron/my-app/node_modules/app-builder-lib/templates/entitlements.mac.plist /Users/John/Workspace/Codes/start-electron/my-app/dist_electron/mac/my-app.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Helpers/chrome_crashpad_handler error: The specified item could not be found in the keychain. ... (node:10223) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:10223) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 参考

electron-app

start-electron

Electron

Application Distribution

Electron Builder

Code Signing

Notarize app for macOS

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpxszs.html