├── tests ├── builds │ └── .gitkeep ├── scaffold.sh ├── wine.sh ├── scaffold.js └── builds.json ├── docs ├── cn │ ├── miscellaneous.md │ ├── book.json │ ├── development.md │ ├── contributing.md │ ├── using_the_file_structure.md │ ├── meta.md │ ├── migration-guide.md │ ├── building_your_app.md │ ├── testing.md │ ├── using_css_frameworks.md │ ├── SUMMARY.md │ ├── webpack-configurations.md │ ├── new-releases.md │ ├── npm_scripts.md │ ├── main-process.md │ ├── file-tree.md │ ├── savingreading-local-files.md │ ├── project_structure.md │ ├── unittesting.md │ ├── global_configuration.md │ ├── vue_accessories.md │ ├── getting_started.md │ ├── entry_indexhtml.md │ ├── end-to-end_testing.md │ ├── using-electron-packager.md │ ├── using-static-assets.md │ ├── renderer-process.md │ ├── using_pre-processors.md │ ├── faqs.md │ ├── using-electron-builder.md │ └── README.md ├── en │ ├── miscellaneous.md │ ├── book.json │ ├── development.md │ ├── contributing.md │ ├── using_the_file_structure.md │ ├── building_your_app.md │ ├── migration-guide.md │ ├── testing.md │ ├── meta.md │ ├── using_css_frameworks.md │ ├── SUMMARY.md │ ├── global_configuration.md │ ├── file-tree.md │ ├── npm_scripts.md │ ├── unittesting.md │ ├── new-releases.md │ ├── webpack-configurations.md │ ├── main-process.md │ ├── savingreading-local-files.md │ ├── project_structure.md │ ├── entry_indexhtml.md │ ├── debugging-production.md │ ├── end-to-end_testing.md │ ├── getting_started.md │ ├── using-electron-packager.md │ ├── vue_accessories.md │ ├── using_pre-processors.md │ ├── using-static-assets.md │ ├── faqs.md │ ├── renderer-process.md │ ├── using-electron-builder.md │ └── README.md ├── ja │ ├── miscellaneous.md │ ├── book.json │ ├── development.md │ ├── contributing.md │ ├── using_the_file_structure.md │ ├── meta.md │ ├── migration-guide.md │ ├── building_your_app.md │ ├── testing.md │ ├── using_css_frameworks.md │ ├── SUMMARY.md │ ├── new-releases.md │ ├── webpack-configurations.md │ ├── file-tree.md │ ├── npm_scripts.md │ ├── main-process.md │ ├── global_configuration.md │ ├── savingreading-local-files.md │ ├── unittesting.md │ ├── project_structure.md │ ├── entry_indexhtml.md │ ├── vue_accessories.md │ ├── getting_started.md │ ├── end-to-end_testing.md │ ├── using-electron-packager.md │ ├── using-static-assets.md │ ├── using_pre-processors.md │ ├── renderer-process.md │ ├── faqs.md │ ├── using-electron-builder.md │ └── README.md ├── LANGS.md └── images │ ├── logo.png │ └── landing-page.jpg ├── template ├── dist │ ├── web │ │ └── .gitkeep │ └── electron │ │ └── .gitkeep ├── static │ └── .gitkeep ├── src │ ├── renderer │ │ ├── assets │ │ │ ├── .gitkeep │ │ │ └── logo.png │ │ ├── store │ │ │ ├── index.js │ │ │ └── modules │ │ │ │ ├── index.js │ │ │ │ └── Counter.js │ │ ├── router │ │ │ └── index.js │ │ ├── App.vue │ │ ├── main.js │ │ └── components │ │ │ ├── LandingPage │ │ │ └── SystemInformation.vue │ │ │ └── LandingPage.vue │ ├── index.ejs │ └── main │ │ ├── index.dev.js │ │ └── index.js ├── build │ └── icons │ │ ├── icon.icns │ │ ├── icon.ico │ │ └── 256x256.png ├── .eslintignore ├── .gitignore ├── test │ ├── .eslintrc │ ├── e2e │ │ ├── specs │ │ │ └── Launch.spec.js │ │ ├── index.js │ │ └── utils.js │ └── unit │ │ ├── specs │ │ └── LandingPage.spec.js │ │ ├── index.js │ │ └── karma.conf.js ├── .electron-vue │ ├── build.config.js │ ├── dev-client.js │ ├── webpack.main.config.js │ ├── webpack.web.config.js │ ├── build.js │ ├── dev-runner.js │ └── webpack.renderer.config.js ├── appveyor.yml ├── .babelrc ├── README.md ├── .eslintrc.js ├── .travis.yml └── package.json ├── .gitignore ├── book.json ├── .github └── ISSUE_TEMPLATE.md ├── package.json ├── LICENSE.md └── meta.js /tests/builds/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/cn/miscellaneous.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/en/miscellaneous.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/ja/miscellaneous.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template/dist/web/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template/static/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template/dist/electron/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template/src/renderer/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/cn/book.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": "" 3 | } 4 | -------------------------------------------------------------------------------- /docs/en/book.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": "" 3 | } 4 | -------------------------------------------------------------------------------- /docs/ja/book.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": "" 3 | } 4 | -------------------------------------------------------------------------------- /docs/LANGS.md: -------------------------------------------------------------------------------- 1 | * [English](en/) 2 | * [日本語](ja/) 3 | * [中文](cn/) 4 | -------------------------------------------------------------------------------- /docs/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliuq/electron-vue/master/docs/images/logo.png -------------------------------------------------------------------------------- /docs/images/landing-page.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliuq/electron-vue/master/docs/images/landing-page.jpg -------------------------------------------------------------------------------- /template/build/icons/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliuq/electron-vue/master/template/build/icons/icon.icns -------------------------------------------------------------------------------- /template/build/icons/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliuq/electron-vue/master/template/build/icons/icon.ico -------------------------------------------------------------------------------- /template/build/icons/256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliuq/electron-vue/master/template/build/icons/256x256.png -------------------------------------------------------------------------------- /template/.eslintignore: -------------------------------------------------------------------------------- 1 | {{#testing unit e2e}} 2 | test/unit/coverage/** 3 | test/unit/*.js 4 | test/e2e/*.js 5 | {{/testing}} 6 | -------------------------------------------------------------------------------- /template/src/renderer/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliuq/electron-vue/master/template/src/renderer/assets/logo.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | _book 3 | thumbs.db 4 | .DS_Store 5 | node_modules 6 | tests/builds/* 7 | npm-debug.log 8 | npm-debug.*.log 9 | !.gitkeep 10 | -------------------------------------------------------------------------------- /template/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | dist/electron/* 3 | dist/web/* 4 | build/* 5 | !build/icons 6 | {{#if unit}} 7 | coverage 8 | {{/if}} 9 | node_modules/ 10 | npm-debug.log 11 | npm-debug.log.* 12 | thumbs.db 13 | !.gitkeep 14 | -------------------------------------------------------------------------------- /template/src/renderer/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | 4 | import modules from './modules' 5 | 6 | Vue.use(Vuex) 7 | 8 | export default new Vuex.Store({ 9 | modules, 10 | strict: process.env.NODE_ENV !== 'production' 11 | }) 12 | -------------------------------------------------------------------------------- /docs/cn/development.md: -------------------------------------------------------------------------------- 1 | # 开发 2 | 3 | ### 开始开发环境设置 4 | 5 | 在你使用 `yarn` 或 `npm install` 安装了依赖之后, 运行... 6 | 7 | ```bash 8 | yarn run dev # 或者 npm run dev 9 | ``` 10 | 11 | ...然后 轰! 现在,你就在运行一个 electron-vue 应用程序. 12 | ![](../images/landing-page.jpg) 13 | 14 | 此样板代码附带了几个易于移除的登录页面组件。 15 | -------------------------------------------------------------------------------- /docs/cn/contributing.md: -------------------------------------------------------------------------------- 1 | # 贡献 2 | 3 | 想要贡献你的力量?随时提交 pull 请求。在准备提交任何内容之前,请务必查看以下内容... 4 | 5 | ### JavaScript 标准规范 6 | 7 | 为确保所有 JS 代码遵循基本的 ***风格标准***,请务必遵循这些 [规则](http://standardjs.com/#rules)。 8 | 9 | [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) 10 | -------------------------------------------------------------------------------- /docs/ja/development.md: -------------------------------------------------------------------------------- 1 | # 開発 2 | 3 | ### 開発セットアップ 4 | 5 | `yarn` または `npm install` で依存関係をインストールした後、実行します... 6 | 7 | ```bash 8 | yarn run dev # or npm run dev 9 | ``` 10 | 11 | ...そしてやりました!electron-vue アプリケーションの実行に成功しました。 12 | ![](../images/landing-page.jpg) 13 | 14 | このボイラープレートには、簡単に取り外し可能なランディングページがいくつか付属しています。 15 | -------------------------------------------------------------------------------- /template/test/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "mocha": true 4 | }, 5 | "globals": { 6 | "assert": true, 7 | "expect": true, 8 | "should": true, 9 | "__static": true 10 | }{{#if eslint}}{{#if_eq eslintConfig 'airbnb'}}, 11 | "rules": { 12 | "func-names": 0, 13 | "prefer-arrow-callback": 0 14 | }{{/if_eq}}{{/if}} 15 | } 16 | -------------------------------------------------------------------------------- /docs/ja/contributing.md: -------------------------------------------------------------------------------- 1 | # 貢献 2 | 3 | このボイラープレートを手助けしたいですか?遠慮なくプルリクエストを送信してください。何かを送信する準備をする前に、以下をチェックしてください... 4 | 5 | ### JavaScript 標準スタイル 6 | 7 | 全ての JS が***標準スタイル***に従っていることを確実にするために、これらの[ルール](http://standardjs.com/#rules)に従っていることを確認してください。 8 | 9 | [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) 10 | -------------------------------------------------------------------------------- /docs/cn/using_the_file_structure.md: -------------------------------------------------------------------------------- 1 | # Using the File Structure 2 | 3 | electron-vue 尽可能不强制一个特别的项目结构,但是努力去跟随通用 Vue & Electron 的实践。以下文档描述了在元项目结构中使用的通用实践。 4 | 5 | **如果你对 Electron 的 **`renderer`** 和 **`main`**进程不熟悉,请认真阅读第一部分 **[**快速起步**](http://electron.atom.io/docs/tutorial/quick-start)**。它详尽的解释了他们的不同。** 6 | 7 | ### [渲染进程](renderer-process.md) 8 | 9 | ### [主进程](main-process.md) 10 | -------------------------------------------------------------------------------- /tests/scaffold.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Scaffold boilerplate with given templateName 5 | cd "$PWD/tests" 6 | node scaffold.js "$1" 7 | 8 | # Install dependecies 9 | cd "$PWD/builds/$1" 10 | yarn 11 | 12 | # Run unit/e2e testing 13 | yarn test 14 | 15 | # Run webpack and build electron 16 | yarn run build 17 | 18 | # Clean up current scaffold 19 | cd .. 20 | rm -rf "$1" 21 | -------------------------------------------------------------------------------- /template/test/e2e/specs/Launch.spec.js: -------------------------------------------------------------------------------- 1 | import utils from '../utils' 2 | 3 | describe('Launch', function () { 4 | beforeEach(utils.beforeEach) 5 | afterEach(utils.afterEach) 6 | 7 | it('shows the proper application title', function () { 8 | return this.app.client.getTitle() 9 | .then(title => { 10 | expect(title).to.equal('{{ name }}') 11 | }) 12 | }) 13 | }) 14 | -------------------------------------------------------------------------------- /template/src/renderer/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | 4 | Vue.use(Router) 5 | 6 | export default new Router({ 7 | routes: [ 8 | { 9 | path: '/', 10 | name: 'landing-page', 11 | component: require('@/components/LandingPage').default 12 | }, 13 | { 14 | path: '*', 15 | redirect: '/' 16 | } 17 | ] 18 | }) 19 | -------------------------------------------------------------------------------- /docs/en/development.md: -------------------------------------------------------------------------------- 1 | # Development 2 | 3 | ### Starting the development setup 4 | 5 | After you have installed dependencies with `yarn` or `npm install`, then run... 6 | 7 | ```bash 8 | yarn run dev # or npm run dev 9 | ``` 10 | 11 | ...and boom! You now have a running electron-vue app. 12 | ![](../images/landing-page.jpg) 13 | 14 | This boilerplate comes with a few landing-page components that are easily removable. 15 | 16 | -------------------------------------------------------------------------------- /docs/en/contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | Wanting to help with this boilerplate? Feel free to submit a pull request. Before getting ready to submit anything, make sure to check out the following... 3 | 4 | ### JavaScript Standard Style 5 | To ensure all JS follows basic ***style standards*** make sure it follows these [rules](http://standardjs.com/#rules). 6 | 7 | [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) -------------------------------------------------------------------------------- /template/src/renderer/store/modules/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The file enables `@/store/index.js` to import all vuex modules 3 | * in a one-shot manner. There should not be any reason to edit this file. 4 | */ 5 | 6 | const files = require.context('.', false, /\.js$/) 7 | const modules = {} 8 | 9 | files.keys().forEach(key => { 10 | if (key === './index.js') return 11 | modules[key.replace(/(\.\/|\.js)/g, '')] = files(key).default 12 | }) 13 | 14 | export default modules 15 | -------------------------------------------------------------------------------- /template/test/unit/specs/LandingPage.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import LandingPage from '@/components/LandingPage' 3 | 4 | describe('LandingPage.vue', () => { 5 | it('should render correct contents', () => { 6 | const vm = new Vue({ 7 | el: document.createElement('div'), 8 | render: h => h(LandingPage) 9 | }).$mount() 10 | 11 | expect(vm.$el.querySelector('.title').textContent).to.contain('Welcome to your new project!') 12 | }) 13 | }) 14 | -------------------------------------------------------------------------------- /docs/cn/meta.md: -------------------------------------------------------------------------------- 1 | # 更多 2 | 3 | ### 感谢 4 | 5 | 哇,非常感谢你们的帮助,使得 electron-vue 在 GitHub 上成为(我可以找到的)前 3 名 `vue-cli` 模板之一。我从来没有想过这个项目会像今天一样脱颖而出。回想过去,我起初(在 **2016年5月**)做了这个样板只是为个人的闭源项目。当我知道我已经完成了大部分的代码之后,我决定开源(样板本身)。转到今天,项目里已经有了这么多新的功能,并且得到了社区的大力支持。我也想给社区的人们一些特别的话,你们帮助我解决了一些我无法解决的问题。你们绝对没有任何义务去做任何事情,但是你们还是这么做的,我很感激。 6 | 7 | 如果你正在阅读这篇文章,那我几乎可以假设你真的很喜欢 electron-vue。我花了很多时间在创建这个样板上。如果你愿意的话,请自愿留下一些小费。electron-vue 未来的发展肯定不会依赖于这些捐赠,但如果你决定捐赠,它总是一个可以的选择。 8 | 9 | #### [**使用 PayPal.me 进行转账**](https://www.paypal.me/simulatedgreg/5) 10 | -------------------------------------------------------------------------------- /tests/wine.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Update lists 4 | sudo apt-get update 5 | 6 | # Preset agreement to install ttf programmatically 7 | echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections 8 | sudo apt-get -y install ttf-mscorefonts-installer 9 | 10 | # Install wine for win32 building support 11 | sudo apt-get -y install wine 12 | 13 | # Install `electron-builder` dependencies 14 | sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils 15 | -------------------------------------------------------------------------------- /template/test/e2e/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | // Set BABEL_ENV to use proper env config 4 | process.env.BABEL_ENV = 'test' 5 | 6 | // Enable use of ES6+ on required files 7 | require('babel-register')({ 8 | ignore: /node_modules/ 9 | }) 10 | 11 | // Attach Chai APIs to global scope 12 | const { expect, should, assert } = require('chai') 13 | global.expect = expect 14 | global.should = should 15 | global.assert = assert 16 | 17 | // Require all JS files in `./specs` for Mocha to consume 18 | require('require-dir')('./specs') 19 | -------------------------------------------------------------------------------- /docs/cn/migration-guide.md: -------------------------------------------------------------------------------- 1 | # 迁移指南 2 | 3 | 本文档尝试解释 _应该_ 如何实现你的项目迁移,但是由于整体项目结构始终可能变化,因此,这可能不是一个完整验证过的方法。 4 | 5 | 1. 使用 `vue init simulatedgreg/electron-vue my-project` 生成一个崭新的 electron-vue 项目 6 | 2. 将当前项目 `src` 内的文件复制到新项目的 `src` 目录中 7 | 3. 将 `package.json` 里的依赖关系从当前项目复制到新项目的 `package.json` 里 8 | 4. 使用 `yarn` 或 `npm install` 安装依赖 9 | 5. 在开发模式下运行项目 \(`yarn run dev` 或 `npm run dev`\) 10 | 6. 监视控制台以修复可能出现的错误 11 | 12 | 正如前面提到的,并没有一个完整验证过的方法来迁移到一个新的项目,但上述这些步骤,通常是可以让你成功完成迁移。任何对项目结构或资源处理的私自修改,将依靠你或你的团队来完成迁移。请确保查看文档的其余部分,因为它将始终反映 electron-vue 当前版本的 `master` 分支。 13 | -------------------------------------------------------------------------------- /template/test/e2e/utils.js: -------------------------------------------------------------------------------- 1 | import electron from 'electron' 2 | import { Application } from 'spectron' 3 | 4 | export default { 5 | afterEach () { 6 | this.timeout(10000) 7 | 8 | if (this.app && this.app.isRunning()) { 9 | return this.app.stop() 10 | } 11 | }, 12 | beforeEach () { 13 | this.timeout(10000) 14 | this.app = new Application({ 15 | path: electron, 16 | args: ['dist/electron/main.js'], 17 | startTimeout: 10000, 18 | waitTimeout: 10000 19 | }) 20 | 21 | return this.app.start() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /template/.electron-vue/build.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | /** 4 | * `electron-packager` options 5 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-electron-packager.html 6 | */ 7 | module.exports = { 8 | arch: 'x64', 9 | asar: true, 10 | dir: path.join(__dirname, '../'), 11 | icon: path.join(__dirname, '../build/icons/icon'), 12 | ignore: /(^\/(src|test|\.[a-z]+|README|yarn|static|dist\/web))|\.gitkeep/, 13 | out: path.join(__dirname, '../build'), 14 | overwrite: true, 15 | platform: process.env.BUILD_TARGET || 'all' 16 | } 17 | -------------------------------------------------------------------------------- /template/test/unit/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | Vue.config.devtools = false 3 | Vue.config.productionTip = false 4 | 5 | // require all test files (files that ends with .spec.js) 6 | const testsContext = require.context('./specs', true, /\.spec$/) 7 | testsContext.keys().forEach(testsContext) 8 | 9 | // require all src files except main.js for coverage. 10 | // you can also change this to match only the subset of files that 11 | // you want coverage for. 12 | const srcContext = require.context('../../src/renderer', true, /^\.\/(?!main(\.js)?$)/) 13 | srcContext.keys().forEach(srcContext) 14 | -------------------------------------------------------------------------------- /template/src/renderer/store/modules/Counter.js: -------------------------------------------------------------------------------- 1 | const state = { 2 | main: 0 3 | } 4 | 5 | const mutations = { 6 | DECREMENT_MAIN_COUNTER (state) { 7 | {{#if_eq eslintConfig 'airbnb'}}state.main = state.main - 1{{else}}state.main--{{/if_eq}} 8 | }, 9 | INCREMENT_MAIN_COUNTER (state) { 10 | {{#if_eq eslintConfig 'airbnb'}}state.main = state.main + 1{{else}}state.main++{{/if_eq}} 11 | } 12 | } 13 | 14 | const actions = { 15 | someAsyncTask ({ commit }) { 16 | // do something async 17 | commit('INCREMENT_MAIN_COUNTER') 18 | } 19 | } 20 | 21 | export default { 22 | state, 23 | mutations, 24 | actions 25 | } 26 | -------------------------------------------------------------------------------- /docs/ja/using_the_file_structure.md: -------------------------------------------------------------------------------- 1 | # Using the File Structure 2 | 3 | electron-vue does its best to not force a particular project structure, but does try to follow common Vue & Electron practices. The following documentation describes common practices used in the original project structure. 4 | 5 | **If you are unfamiliar with Electron's **`renderer`** and **`main`** processes, please give the first section of the **[**Quick Start**](http://electron.atom.io/docs/tutorial/quick-start)** a good read. It explains, in detail, their differences.** 6 | 7 | ### [Renderer Process](renderer-process.md) 8 | 9 | ### [Main Process](main-process.md) 10 | -------------------------------------------------------------------------------- /docs/cn/building_your_app.md: -------------------------------------------------------------------------------- 1 | # 构建你的应用程序 2 | 3 | electron-vue 支持使用 [electron-packager](https://github.com/electron-userland/electron-packager) 和 [electron-builder](https://github.com/electron-userland/electron-builder) 来构建和分发你的产品阶段的程序。两个构建工具都由了不起的 [@electron-userland](https://github.com/electron-userland) 社区支持,每个都有详尽的文档。在 `vue-cli` 脚手架过程中,你会被问到你想要使用哪个构建器。 4 | 5 | ## [`electron-packager`](using-electron-packager.md) 6 | 7 | 如果你刚开始制作 electron 应用程序或只需要创建简单的可执行文件,那么 `electron-packager` 就可以满足你的需求。 8 | 9 | ## [`electron-builder`](using-electron-builder.md) 10 | 11 | 如果你正在寻找完整的安装程序、自动更新的支持、使用 Travis CI 和 AppVeyor 的 CI 构建、或本机 node 模块的自动重建,那么你会需要 `electron-builder`。 12 | -------------------------------------------------------------------------------- /docs/en/using_the_file_structure.md: -------------------------------------------------------------------------------- 1 | # Using the File Structure 2 | 3 | electron-vue does its best to not force a particular project structure, but does try to follow common Vue & Electron practices. The following documentation describes common practices used in the original project structure. 4 | 5 | **If you are unfamiliar with Electron's **`renderer`** and **`main`** processes, please give the first section of the **[**Quick Start**](http://electron.atom.io/docs/tutorial/quick-start)** a good read. It explains, in detail, their differences.** 6 | 7 | ### [Renderer Process](renderer-process.md) 8 | 9 | ### [Main Process](main-process.md) 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/ja/meta.md: -------------------------------------------------------------------------------- 1 | # メタ 2 | 3 | ### ありがとうございます 4 | 5 | わあ、electron-vue を GitHub で(見つけることができる)トップ3の `vue-cli` テンプレートのうちの1つにするのを手伝ってくれてありがとうございます。このプロジェクトが今のようになるとは思っても見ませんでした。振り返ると、もともとこのボイラープレートは(**2016年5月**に)個人用のクローズドソースとして作成し、大部分が再利用可能になっていることを知ったときに(ボイラープレート自身を)オープンソースにすることを決めました。今では、新しい機能が数多く導入され、コミュニティからの驚くべきサポートがあります。 私が答えられないときに問題に答えてくれるコミュニティの人々に格別の感謝を表明したいです。 皆さんは何かをする絶対的な義務はありませんが、してくれます。私はそれに感謝しています。 6 | 7 | これを読んでいるなら、本当に electron-vue を楽しんでくれているはずだと思います。このボイラープレートを作成するのに多くの時間が費やされました。あなたが気前が良くて、望むならば、遠慮なくチップを残してください。確かに electron-vue の将来の開発は寄付に依存しませんが、それを使用することに決めるならば、常にオプションとなります。 8 | 9 | #### [**PayPal.me**](https://www.paypal.me/simulatedgreg/5) 10 | -------------------------------------------------------------------------------- /book.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": "./docs", 3 | "plugins": [ 4 | "edit-link", 5 | "theme-vuejs@git+https://github.com/pearofducks/gitbook-plugin-theme-vuejs.git", 6 | "github", 7 | "ga" 8 | ], 9 | "pluginsConfig": { 10 | "edit-link": { 11 | "base": "https://github.com/SimulatedGREG/electron-vue/tree/master/docs", 12 | "label": "Edit This Page" 13 | }, 14 | "github": { 15 | "url": "https://github.com/SimulatedGREG/electron-vue" 16 | }, 17 | "ga": { 18 | "token": "UA-64200901-3" 19 | } 20 | }, 21 | "links": { 22 | "sharing": { 23 | "facebook": false, 24 | "twitter": true 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /docs/ja/migration-guide.md: -------------------------------------------------------------------------------- 1 | # 移行ガイド 2 | 3 | 以下のドキュメントでは、プロジェクトが移行をどのように達成*すべき*であるか説明しますが、プロジェクト全体の構造が常に変更されているため、完全な方法ではない可能性があります。 4 | 5 | 1. `vue init simulatedgreg/electron-vue my-project` を行い、electron-vue の新しいバージョンをスキャフォールドする 6 | 2. 現在のプロジェクトの `src` ファイルを新しくスキャフォールディングした `src` ディレクトリにコピーする 7 | 3. `package.json` の依存関係を現在のプロジェクトから新しくスキャフォールディングした `package.json` にコピーする 8 | 4. `yarn` もしくは `npm install` で依存関係をインストールする 9 | 5. 開発モードでプロジェクトを実行する(`yarn run dev` もしくは `npm run dev`) 10 | 6. コンソールで修正するエラーを監視する 11 | 12 | 上で言及したように、新しいスキャフォールドに移行する完全な方法はありませんが、一般的でほぼ完全に進めるための主要なステップになります。 プロジェクトの構造やアセットの取り扱いに関する個人的な変更は、あなたまたはチームが移行することになります。`master` ブランチの electron-vue の現在のバージョンを常に反映するので、残りのドキュメントを必ずチェックしてください。 13 | -------------------------------------------------------------------------------- /template/src/renderer/App.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 27 | 28 | 31 | -------------------------------------------------------------------------------- /docs/ja/building_your_app.md: -------------------------------------------------------------------------------- 1 | # アプリケーション構築 2 | 3 | electron-vue はビルドと本番アプリケーションの配布のために [electron-packager](https://github.com/electron-userland/electron-packager) と [electron-builder](https://github.com/electron-userland/electron-builder) の両方をサポートしています。両方のビルドツールは素晴らしい [@electron-userland](https://github.com/electron-userland) コミュニティによって支援されていて、それぞれに詳細なドキュメントがあります。`vue-cli` のスキャフォールディング中にどちらのビルダーを使いたいか尋ねられます。 4 | 5 | ## [`electron-packager`](using-electron-packager.md) 6 | 7 | electron アプリケーションを作成するのが初めて使う人や単純な実行可能ファイルを作成する必要がある場合、`electron-packager` がニーズに最適です。 8 | 9 | ## [`electron-builder`](using-electron-builder.md) 10 | 11 | 完全なインストーラー、自動更新サポート、Travis CI と AppVeyor を使用した CI ビルド、またはネイティブコードモジュールの再構築の自動化を探し求めている場合、`electron-builder` が最適です。 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | #### Found an issue or bug with electron-vue? Tell me all about it! 2 | Questions regarding how to use `electron` or `vue` are likely to be closed as they are not direct issues with this boilerplate. Please seek solutions from official documentation or their respective communities. 3 | 4 | ##### Describe the issue / bug. 5 | \# 6 | 7 | ##### How can I reproduce this problem? 8 | \# 9 | 10 | ##### If visual, provide a screenshot. 11 | \# 12 | 13 | ##### Tell me about your development environment. 14 | * Node version: 15 | * NPM version: 16 | * vue-cli version: (if necessary) 17 | * Operating System: 18 | 19 | #### *If you are looking to suggest an enhancement or feature, then feel free to remove everything above.* 20 | -------------------------------------------------------------------------------- /docs/cn/testing.md: -------------------------------------------------------------------------------- 1 | # 测试 2 | 3 | 因受到了官方样板代码 `vuejs-templates/webpack` 提供的测试功能的极大启发,electron-vue 同时支持单元测试和 `renderer` 进程的端到端测试。在 `vue-cli` 脚手架中,你可以选择是否包含测试。 4 | 5 | ## [单元测试](unittesting.md) 6 | 7 | 使用 Karma + Mocha 运行单元测试 8 | 9 | ```bash 10 | npm run unit 11 | ``` 12 | 13 | ## [端对端测试](end-to-end_testing.md) 14 | 15 | 使用 Spectron + Mocha 运行端对端测试 16 | 17 | ```bash 18 | npm run e2e 19 | ``` 20 | 21 | ## 运行所有测试 22 | 23 | ```bash 24 | npm test 25 | ``` 26 | 27 | ### 关于 CI 测试 28 | 29 | 如果在脚手架时你决定使用 `electron-builder` 作为构建工具,那么你可以在针对 `darwin`、`linux` 和 `win32` 的 Travis CI 以及 AppVeyor 上轻松测试你的程序。在 `.travis.yml` 和 `appveyor.yml` 两者之间,你会发现一些被注释掉的部分,你可以快速取消注释以启用测试。确保阅读 [**使用 CI 的自动化部署**](/using-electron-builder.md#automated-deployments-using-ci) 上的更多信息。 30 | -------------------------------------------------------------------------------- /docs/cn/using_css_frameworks.md: -------------------------------------------------------------------------------- 1 | # CSS 框架的使用 2 | 3 | 虽然这可能看起来并不明智,但我建议你使用 [`style-loader`](https://github.com/webpack/style-loader) 将第三方 CSS 库导入 webpack,其实这一点我们已经为你做了。 4 | 5 | ## 使用案例 6 | 7 | 假设你要为你的程序使用 [bootstrap](http://getbootstrap.com/)、[bulma](http://bulma.io/) 或者 [materialize](http://materializecss.com/)。你可以仍旧像通常情况下一样,从 `npm` 安装你的库,而不是将资源附加到 `index.ejs` 上,我们将在我们的 JavaScript 中导入 CSS,具体在 `src/renderer/main.js` 中。 8 | 9 | #### 例子 10 | 11 | 让我们安装 `bulma` 如下 12 | 13 | ```bash 14 | npm install bulma --save 15 | ``` 16 | 17 | 然后,在 `src/renderer/main.js` 里面加入这一行: 18 | 19 | ```bash 20 | import 'bulma/css/bulma.css' 21 | ``` 22 | 23 | 替代方案是, 你也可以在你的组件文件中引用 `bulma`。 24 | 25 | **App.vue** 26 | 27 | ```html 28 | 31 | ``` 32 | 33 | 现在,`webpack` 会为我们的应用程序加载 `bulma`,并使其在产品构建中可用. 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "electron-vue", 3 | "version": "0.0.0", 4 | "description": "An Electron & Vue.js quick start boilerplate with vue-cli support", 5 | "main": "meta.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/SimulatedGREG/electron-vue.git" 9 | }, 10 | "keywords": [ 11 | "electron", 12 | "vue", 13 | "boilerplate", 14 | "hot", 15 | "reload", 16 | "router", 17 | "vuex", 18 | "resource" 19 | ], 20 | "author": "Greg Holguin (https://github.com/SimulatedGREG)", 21 | "license": "MIT", 22 | "bugs": { 23 | "url": "https://github.com/SimulatedGREG/electron-vue/issues" 24 | }, 25 | "homepage": "https://github.com/SimulatedGREG/electron-vue#readme", 26 | "devDependencies": { 27 | "suppose": "^0.6.1" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /template/appveyor.yml: -------------------------------------------------------------------------------- 1 | {{#testing unit e2e}} 2 | # Commented sections below can be used to run tests on the CI server 3 | # https://simulatedgreg.gitbooks.io/electron-vue/content/en/testing.html#on-the-subject-of-ci-testing 4 | {{/testing}} 5 | version: 0.1.{build} 6 | 7 | branches: 8 | only: 9 | - master 10 | 11 | image: Visual Studio 2017 12 | platform: 13 | - x64 14 | 15 | cache: 16 | - node_modules 17 | - '%APPDATA%\npm-cache' 18 | - '%USERPROFILE%\.electron' 19 | - '%USERPROFILE%\AppData\Local\Yarn\cache' 20 | 21 | init: 22 | - git config --global core.autocrlf input 23 | 24 | install: 25 | - ps: Install-Product node 8 x64 26 | - git reset --hard HEAD 27 | - yarn 28 | - node --version 29 | 30 | build_script: 31 | {{#testing unit e2e}} 32 | #- yarn test 33 | {{/testing}} 34 | - yarn build 35 | 36 | test: off 37 | -------------------------------------------------------------------------------- /template/src/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{ name }} 6 | <% if (htmlWebpackPlugin.options.nodeModules) { %> 7 | 8 | 11 | <% } %> 12 | 13 | 14 |
15 | 16 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /template/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "comments": false, 3 | "env": { 4 | {{#testing unit e2e}} 5 | "test": { 6 | "presets": [ 7 | ["env", { 8 | "targets": { "node": 7 } 9 | }], 10 | "stage-0" 11 | ], 12 | "plugins": ["istanbul"] 13 | }, 14 | {{/testing}} 15 | "main": { 16 | "presets": [ 17 | ["env", { 18 | "targets": { "node": 7 } 19 | }], 20 | "stage-0" 21 | ] 22 | }, 23 | "renderer": { 24 | "presets": [ 25 | ["env", { 26 | "modules": false 27 | }], 28 | "stage-0" 29 | ] 30 | }, 31 | "web": { 32 | "presets": [ 33 | ["env", { 34 | "modules": false 35 | }], 36 | "stage-0" 37 | ] 38 | } 39 | }, 40 | "plugins": ["transform-runtime"] 41 | } 42 | -------------------------------------------------------------------------------- /template/README.md: -------------------------------------------------------------------------------- 1 | # {{ name }} 2 | 3 | > {{ description }} 4 | 5 | #### Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | npm install 10 | 11 | # serve with hot reload at localhost:9080 12 | npm run dev 13 | 14 | # build electron application for production 15 | npm run build 16 | 17 | {{#testing unit e2e}} 18 | # run {{#unit}}unit{{/unit}}{{#unit}}{{#e2e}} & {{/e2e}}{{/unit}}{{#e2e}}end-to-end{{/e2e}} tests 19 | npm test 20 | 21 | {{/testing}} 22 | 23 | {{#if eslint}} 24 | # lint all JS/Vue component files in `src/` 25 | npm run lint 26 | 27 | {{/if}} 28 | ``` 29 | 30 | --- 31 | 32 | This project was generated with [electron-vue](https://github.com/SimulatedGREG/electron-vue) using [vue-cli](https://github.com/vuejs/vue-cli). Documentation about the original structure can be found [here](https://simulatedgreg.gitbooks.io/electron-vue/content/index.html). 33 | -------------------------------------------------------------------------------- /docs/ja/testing.md: -------------------------------------------------------------------------------- 1 | # テスト 2 | 3 | electron-vue は `renderer` プロセスのユニットテストとエンドツーエンドテストの両方をサポートし、公式の `vuejs-templates/webpack` ボイラープレートで提供されているテスト設定に大きく影響を受けています。`vue-cli` スキャフォールディング中にテストサポートを含めるかの選択があります。 4 | 5 | ## [ユニットテスト](unittesting.md) 6 | 7 | Karma と Mocha でユニットテストを実行する 8 | 9 | ```bash 10 | npm run unit 11 | ``` 12 | 13 | ## [エンドツーエンドテスト](end-to-end_testing.md) 14 | 15 | Spectron と Mocha でエンドツーエンドテストを実行する 16 | 17 | ```bash 18 | npm run e2e 19 | ``` 20 | 21 | ## 全てのテストを実行する 22 | 23 | ```bash 24 | npm test 25 | ``` 26 | 27 | ### CI テストについて 28 | 29 | スキャフォールディング時にビルドツールとして `electron-builder` を使うことに決めた場合、`darwin`、`linux`、`win32`向けにTravis CI と AppVeyorの両方で簡単にアプリケーションをテストできます。`.travis.yml` と `appveyor.yml` の中には、コメントアウトされたセクションがあります。テストを有効にするために、セクションのコメントアウトを解除することができます。詳細については、[**CI を使用した自動デプロイ**](/using-electron-builder.md#automated-deployments-using-ci)を読んでください。** ** 30 | -------------------------------------------------------------------------------- /docs/ja/using_css_frameworks.md: -------------------------------------------------------------------------------- 1 | # CSS フレームワークの使用 2 | 3 | これは簡単なように思えるかもしれませんが、すでに用意されている [`style-loader`](https://github.com/webpack/style-loader) を使用してサードパーティの CSS ライブラリを webpack にインポートすることをお勧めします。 4 | 5 | ## ユースケース 6 | 7 | アプリケーションに [bootstrap](http://getbootstrap.com/) 、 [bulma](http://bulma.io/) 、 [materialize](http://materializecss.com/) を使いたいとします。いつも通り `npm` からインストールしますが、 `index.ejs` に追加する代わりに、JavaScript 、特に `src/renderer/main.js` に CSS をインポートします。 8 | 9 | #### 例 10 | 11 | `bulma` をインストールしましょう 12 | 13 | ```bash 14 | npm install bulma --save 15 | ``` 16 | 17 | それでは `src/renderer/main.js` にこの行を追加しましょう。 18 | 19 | ```bash 20 | import 'bulma/css/bulma.css' 21 | ``` 22 | 23 | また、コンポーネントファイル内に `bulma` を含めることもできます。 24 | 25 | **App.vue** 26 | 27 | ```html 28 | 31 | ``` 32 | 33 | `webpack` は `bulma` を読み込み、本番ビルドで使用できるようにします。 34 | -------------------------------------------------------------------------------- /template/src/renderer/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | {{#isEnabled plugins 'axios'}} 3 | import axios from 'axios' 4 | {{/isEnabled}} 5 | 6 | import App from './App' 7 | {{#isEnabled plugins 'vue-router'}} 8 | import router from './router' 9 | {{/isEnabled}} 10 | {{#isEnabled plugins 'vuex'}} 11 | import store from './store' 12 | {{/isEnabled}} 13 | 14 | {{#isEnabled plugins 'vue-electron'}} 15 | if (!process.env.IS_WEB) Vue.use(require('vue-electron')) 16 | {{/isEnabled}} 17 | {{#isEnabled plugins 'axios'}} 18 | Vue.http = Vue.prototype.$http = axios 19 | {{/isEnabled}} 20 | Vue.config.productionTip = false 21 | 22 | /* eslint-disable no-new */ 23 | new Vue({ 24 | components: { App }, 25 | {{#isEnabled plugins 'vue-router'}} 26 | router, 27 | {{/isEnabled}} 28 | {{#isEnabled plugins 'vuex'}} 29 | store, 30 | {{/isEnabled}} 31 | template: '' 32 | }).$mount('#app') 33 | -------------------------------------------------------------------------------- /template/src/main/index.dev.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is used specifically and only for development. It installs 3 | * `electron-debug` & `vue-devtools`. There shouldn't be any need to 4 | * modify this file, but it can be used to extend your development 5 | * environment. 6 | */ 7 | 8 | /* eslint-disable */ 9 | 10 | // Set environment for development 11 | process.env.NODE_ENV = 'development' 12 | 13 | // Install `electron-debug` with `devtron` 14 | require('electron-debug')({ showDevTools: true }) 15 | 16 | // Install `vue-devtools` 17 | require('electron').app.on('ready', () => { 18 | let installExtension = require('electron-devtools-installer') 19 | installExtension.default(installExtension.VUEJS_DEVTOOLS) 20 | .then(() => {}) 21 | .catch(err => { 22 | console.log('Unable to install `vue-devtools`: \n', err) 23 | }) 24 | }) 25 | 26 | // Require `main` process to boot app 27 | require('./index') 28 | -------------------------------------------------------------------------------- /docs/cn/SUMMARY.md: -------------------------------------------------------------------------------- 1 | # 概要 2 | 3 | * [简介](./README.md) 4 | * [起步](getting_started.md) 5 | * [项目结构](project_structure.md) 6 | * [文件树](file-tree.md) 7 | * [渲染器进程](renderer-process.md) 8 | * [主进程](main-process.md) 9 | * [Webpack 配置](webpack-configurations.md) 10 | * [开发](development.md) 11 | * [入口 index.html](entry_indexhtml.md) 12 | * [Vue 插件](vue_accessories.md) 13 | * [NPM 脚本](npm_scripts.md) 14 | * [CSS 框架的使用](using_css_frameworks.md) 15 | * [预处理器的使用](using_pre-processors.md) 16 | * [静态资源的使用](using-static-assets.md) 17 | * [读写本地文件](savingreading-local-files.md) 18 | * [建立你的应用](building_your_app.md) 19 | * [electron-packager 的使用](using-electron-packager.md) 20 | * [electron-builder 的使用](using-electron-builder.md) 21 | * [测试](testing.md) 22 | * [单元测试](unittesting.md) 23 | * [端到端测试](end-to-end_testing.md) 24 | * [更多](meta.md) 25 | * [常见问题](faqs.md) 26 | * [新版本](new-releases.md) 27 | * [迁移指南](migration-guide.md) 28 | * [贡献](contributing.md) 29 | -------------------------------------------------------------------------------- /docs/cn/webpack-configurations.md: -------------------------------------------------------------------------------- 1 | # Webpack 配置 2 | 3 | electron-vue 包含三个单独的、位于 `.electron-vue/` 目录中的 webpack 配置文件。除了可选de的使用 `web` 输出以外,`main` 和 `renderer` 在安装过程中都是相似的。两者都使用 `babel-preset-env` 来针对 `node@7` 的功能特性、使用`babili`、并把所有的模块都视为 `externals`。 4 | 5 | ### `.electron-vue/webpack.main.config.js` 6 | 7 | 针对 electron 的 `main` 进程。这种配置是相当简单的,但确实包括一些常见的 `webpack` 做法。 8 | 9 | ### `.electron-vue/webpack.renderer.config.js` 10 | 11 | 针对 electron 的 `renderer` 进程。此配置用来处理你的 Vue 应用程序,因此它包含 `vue-loader` 和许多其他可在官方 `vuejs-templates/webpack` 样板中找到的配置。 12 | 13 | ##### 白名单里的外部组件 14 | 15 | 一个关于此配置的重要的事情是,你可以将特定的模块列入白名单,而不是把它视为 webpack 的 `externals`。并没有很多情况需要这个功能,但在某些情况下,对于提供原始的 `*.vue` 组件的 Vue UI 库,他们需要被列入白名单,以至于 `vue-loader` 能够编译它们。另一个使用情况是使用 webpack 的 `alias`,例如设置 `vue` 来导入完整的 编译+运行环境 的构建。因此,`vue` 已经在白名单中了。 16 | 17 | ### `.electron-vue/webpack.web.config.js` 18 | 19 | 针对为浏览器构建你的 `renderer` 进程的源代码。如果你需要把代码发布到网上,此配置则是其强大的起步基础。 **electron-vue 不支持更多其他的 Web 输出。** 与 Web 输出相关的 Issues 很可能会被推迟或关闭。 20 | -------------------------------------------------------------------------------- /docs/en/building_your_app.md: -------------------------------------------------------------------------------- 1 | # Building Your App 2 | 3 | electron-vue supports both [electron-packager](https://github.com/electron-userland/electron-packager) and [electron-builder](https://github.com/electron-userland/electron-builder) to build and distribute your production ready application. Both build tools are backed by the amazing [@electron-userland](https://github.com/electron-userland) community and each have detailed documentation. During `vue-cli` scaffolding you will be asked which builder you will want to use. 4 | 5 | ## [`electron-packager`](using-electron-packager.md) 6 | 7 | If you are new to making electron applications or just need to create simple executables, then `electron-packager` is perfect for your needs. 8 | 9 | ## [`electron-builder`](using-electron-builder.md) 10 | 11 | If you are looking for full installers, auto-update support, CI building with Travis CI & AppVeyor, or automation of rebuilding native node modules, then `electron-builder` is what you will need. 12 | 13 | -------------------------------------------------------------------------------- /docs/cn/new-releases.md: -------------------------------------------------------------------------------- 1 | # 新版本 2 | 3 | electron-vue 自 2016年5月初 创建以来有了很大的发展,并引入了许多新奇的功能。你能相信有一段时间该项目还不支持 `vue-cli` 脚手架吗?新功能的开发计划不会停止。唯一的缺点是,每天都有华而不实的东西存在,进而把你的项目卡在一个老的脚手架上。尽管 electron-vue 利用了 `vue-cli` 的优势,遗憾的是,并没有一个结构化的方式来 _版本化_ (_version_) 样板 或 使其变得 _可更新_ (_updatable_)。 4 | 5 | electron-vue 的主要更新将通过 GitHub 的 里程碑 (Milestones) 进行,并将包含许多新的功能和错误的修复,这使得这些版本成为了最佳的 [迁移](/migration-guide.md) 契机,用来从任何现有项目转换为较新的架构。这些里程碑通常不是预先计划的,而是随着问题提交里的功能请求,在追踪问题的时候加上去的。 6 | 7 | ### 之前的里程碑 8 | 9 | #### [复用](https://github.com/SimulatedGREG/electron-vue/milestone/1?closed=1) 10 | 11 | * 迁移到 `webpack` 2 12 | * 支持 `electron-builder` 13 | * 支持 `main` 进程的捆绑 14 | * 一般的错误修复 15 | 16 | #### [简化](https://github.com/SimulatedGREG/electron-vue/issues/171) 17 | 18 | * 迁移到单一的 `package.json` 结构 19 | * 针对 `electron-builder` 用户的 Travis CI / AppVeyor 配置 20 | * `renderer` 进程的最小化网页输出 21 | * 迁移到 `axios` 22 | * 完全支持 `main` 进程捆绑 23 | * 重写开发和构建的脚本 24 | * 迁移到 `babili` 以避免完全反编译到 ES5 25 | * 在使用需要完整路径 \([`__static`](/using-static-assets.md)\) 的模块时支持 `static/` 资源 26 | -------------------------------------------------------------------------------- /docs/ja/SUMMARY.md: -------------------------------------------------------------------------------- 1 | # 概要 2 | 3 | - [導入](./README.md) 4 | - [はじめに](getting_started.md) 5 | - [プロジェクト構造](project_structure.md) 6 | - [ファイルツリー](file-tree.md) 7 | - [レンダラープロセス](renderer-process.md) 8 | - [メインプロセス](main-process.md) 9 | - [Webpack 構成](webpack-configurations.md) 10 | - [開発](development.md) 11 | - [index.html](entry_indexhtml.md) 12 | - [Vue プラグイン](vue_accessories.md) 13 | - [NPM スクリプト](npm_scripts.md) 14 | - [CSS フレームワークの使用](using_css_frameworks.md) 15 | - [プリプロセッサの使用](using_pre-processors.md) 16 | - [静的アセットの使用](using-static-assets.md) 17 | - [ローカルファイルの読み書き](savingreading-local-files.md) 18 | - [アプリケーション構築](building_your_app.md) 19 | - [electron-packager の使用](using-electron-packager.md) 20 | - [electron-builder の使用](using-electron-builder.md) 21 | - [テスト](testing.md) 22 | - [ユニットテスト](unittesting.md) 23 | - [エンドツーエンドテスト](end-to-end_testing.md) 24 | - [メタ](meta.md) 25 | - [FAQ](faqs.md) 26 | - [新しいリリース](new-releases.md) 27 | - [マイグレーションガイド](migration-guide.md) 28 | - [貢献](contributing.md) 29 | -------------------------------------------------------------------------------- /docs/cn/npm_scripts.md: -------------------------------------------------------------------------------- 1 | # NPM 脚本 2 | 3 | 为了帮助你消除开发过程中的冗余任务,请注意一些可用的 NPM 脚本。以下命令应该运行在项目的根目录下。当然,你可以使用 `yarn run ` 的方式运行下列任何命令。 4 | 5 | ### `npm run build` 6 | 7 | 为了产品和打包来构建你的应用程序。更多信息可以在 [**构建你的应用程序**](building_your_app.md) 部分找到。 8 | 9 | ### `npm run dev` 10 | 11 | 在开发环境中运行程序 12 | 13 | ### `npm run lint` 14 | 15 | 静态分析所有在 `src/` 和 `test/` 下面的 JS 以及 Vue 组件文件。 16 | 17 | ### `npm run lint:fix` 18 | 19 | 静态分析所有在 `src/` 和 `test/` 下面的 JS 以及 Vue 组件文件并且尝试修复问题。 20 | 21 | ### `npm run pack` 22 | 23 | 同时运行 `npm run pack:main` 和 `npm run pack:renderer`。 虽然这些命令是可用的,但很少情况下,你需要手动执行此操作,因为 `npm run build` 将处理此步骤。 24 | 25 | ### `npm run pack:main` 26 | 27 | 运行 webpack 来打包 `main` 进程的源代码。 28 | 29 | ### `npm run pack:renderer` 30 | 31 | 运行 webpack 来打包 `renderer` 进程的源代码。 32 | 33 | ### `npm run unit` 34 | 35 | 运行使用了 Karma + Jasmine 的单元测试。更多信息请见 [**单元测试**](unittesting.md)。 36 | 37 | ### `npm run e2e` 38 | 39 | 运行使用了 Spectron + Mocha 的端对端测试。更多信息请见 [**端对端测试**](unittesting.md)。 40 | 41 | ### `npm test` 42 | 43 | 运行 `npm run unit` 和 `npm run e2e`. 更多信息请见 [**测试**](unittesting.md)。 44 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Greg Holguin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /template/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: 'babel-eslint', 4 | parserOptions: { 5 | sourceType: 'module' 6 | }, 7 | env: { 8 | browser: true, 9 | node: true 10 | }, 11 | {{#if_eq eslintConfig 'standard'}} 12 | extends: 'standard', 13 | {{/if_eq}} 14 | {{#if_eq eslintConfig 'airbnb'}} 15 | extends: 'airbnb-base', 16 | {{/if_eq}} 17 | globals: { 18 | __static: true 19 | }, 20 | plugins: [ 21 | 'html' 22 | ], 23 | 'rules': { 24 | {{#if_eq eslintConfig 'standard'}} 25 | // allow paren-less arrow functions 26 | 'arrow-parens': 0, 27 | // allow async-await 28 | 'generator-star-spacing': 0, 29 | {{/if_eq}} 30 | {{#if_eq eslintConfig 'airbnb'}} 31 | 'global-require': 0, 32 | 'import/no-unresolved': 0, 33 | 'no-param-reassign': 0, 34 | 'no-shadow': 0, 35 | 'import/extensions': 0, 36 | 'import/newline-after-import': 0, 37 | 'no-multi-assign': 0, 38 | {{/if_eq}} 39 | // allow debugger during development 40 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /docs/ja/new-releases.md: -------------------------------------------------------------------------------- 1 | # 新しいリリース 2 | 3 | electron-vue は2016年5月に作成して以来、大きく進化し、多くの新しく素晴らしい機能を導入してきました。`vue-cli` のスキャフォールディングが提供されていない時があったことを信じられますか?新しい機能の開発はすぐに終了するつもりはありません。新しいオプション機能の唯一の欠点は、あなたのプロジェクトが古いスキャフォールディングから離れられないでいることです。electron-vue は `vue-cli` を使用しているため、残念ながら、ボイラープレートを*バージョンアップ* したり、*更新可能*にする構造化の方法はありません。 4 | 5 | electron-vue のメジャーアップデートは GitHub マイルストーンを介して行われ、一度に多くの新しい機能/バグ修正を含み、これらのリリースは既存のプロジェクトを新しくスキャフォールディングし、[移行](/migration-guide.md)するのに最適な時です。これらのマイルストーンは通常は計画されていませんが、機能要求が課題トラッカーに追加されると発生します。 6 | 7 | ### 過去のマイルストーン 8 | 9 | #### [複合化](https://github.com/SimulatedGREG/electron-vue/milestone/1?closed=1) 10 | 11 | - `webpack` 2 への移行 12 | - `electron-builder` のサポート 13 | - `main` プロセスバンドルのサポート 14 | - 全体的なバグ修正 15 | 16 | #### [最小化](https://github.com/SimulatedGREG/electron-vue/issues/171) 17 | 18 | - 単一の `package.json` 構造への移行 19 | - `electron-builder` ユーザー向けの Travis CI / AppVeyor 構成 20 | - `renderer` プロセスの最小 web 出力 21 | - `axios` への移行 22 | - `main` プロセスバンドルの完全サポート 23 | - 開発とビルドスクプリトの書き直し 24 | - ES5 へのトランスパイルの必要を取り除く `babili` への移行 25 | - フルパスを必要とするモジュールを使用する際の `static/` アセットをサポート ([`__static`](/using-static-assets.md)) 26 | -------------------------------------------------------------------------------- /docs/cn/main-process.md: -------------------------------------------------------------------------------- 1 | # 主进程 2 | 3 | > 在 Electron 中,运行 package.json 主脚本的过程称为主进程 (main process)。在主进程中运行的脚本可以通过创建网页来显示其图形化界面。 4 | 5 | **摘自** [**Electron 文档**](http://electron.atom.io/docs/tutorial/quick-start/#main-process) 6 | 7 | --- 8 | 9 | 由于 `main` 进程本质上是一个完整的 node 环境,所以除了以下两个文件之外,并没有什么初始的项目结构。 10 | 11 | #### `src/main/index.js` 12 | 13 | 这个文件是你应用程序的主文件,`electron` 也从这里启动。它也被用作 `webpack` 产品构建的入口文件。所有的 `main` 进程工作都应该从这里开始。 14 | 15 | #### `app/src/main/index.dev.js` 16 | 17 | 这个文件专门用于开发阶段,因为它会安装 `electron-debug` 和 `vue-devtools`。一般不需要修改此文件,但它可以用于扩展你开发的需求。 18 | 19 | ## 关于 `__dirname` 与 `__filename` 的使用 20 | 21 | 由于 `main` 进程是使用 `webpack` 来绑定的,所以使用 `__dirname` 和 `__filename` **将不会** 在产品阶段给你提供一个预期的值。若参考 [**文件树**](/file-tree.md) 你会注意到,在产品阶段,`main.js` 被放在了 `dist/electron` 文件夹里面。应根据此点相应地使用 `__dirname` 和 `__filename`。 22 | 23 | **如果你需要 `static/` 资源目录的路径,请务必阅读** [**使用静态资源**](/using-static-assets.md) **学习了解非常方便的 `__static` 变量。** 24 | 25 | 26 | ``` 27 | app.asar 28 | ├─ dist 29 | │ └─ electron 30 | │ ├─ static/ 31 | │ ├─ index.html 32 | │ ├─ main.js 33 | │ └─ renderer.js 34 | ├─ node_modules/ 35 | └─ package.json 36 | ``` 37 | -------------------------------------------------------------------------------- /docs/en/migration-guide.md: -------------------------------------------------------------------------------- 1 | # Migration Guide 2 | 3 | The following documentation attempts to explain how migrating your project _should_ be accomplished, but may not be a full proof method as overall project structure is always up for change. 4 | 5 | 1. Scaffold a fresh version of electron-vue using `vue init simulatedgreg/electron-vue my-project` 6 | 2. Copy over current project `src` files into the new scaffold's `src` directory 7 | 3. Copy over `package.json` dependencies from current project to the new scaffold's `package.json` 8 | 4. Install dependencies with `yarn` or `npm install` 9 | 5. Run project in development mode \(`yarn run dev` or `npm run dev`\) 10 | 6. Watch console for errors to fix 11 | 12 | Just as previously mentioned above, there isn't a full proof method for migrating to a new scaffold, but these are typically going to be the major steps to get you nearly all the way there. Any personal modifications to project structure or handling of assets will be up to you or your team to migrate. Make sure to check out the rest of the documentation as it will always reflect the current version of electron-vue from the `master` branch. 13 | 14 | -------------------------------------------------------------------------------- /docs/cn/file-tree.md: -------------------------------------------------------------------------------- 1 | # 文件树 2 | 3 | ### 在开发过程中 4 | 5 | **注意**: 某些文件或文件夹可能会根据在 `vue-cli` 脚手架中所选设置的不同而有所不同。 6 | 7 | ``` 8 | my-project 9 | ├─ .electron-vue 10 | │ └─ .js files 11 | ├─ build 12 | │ └─ icons/ 13 | ├─ dist 14 | │ ├─ electron/ 15 | │ └─ web/ 16 | ├─ node_modules/ 17 | ├─ src 18 | │ ├─ main 19 | │ │ ├─ index.dev.js 20 | │ │ └─ index.js 21 | │ ├─ renderer 22 | │ │ ├─ components/ 23 | │ │ ├─ router/ 24 | │ │ ├─ store/ 25 | │ │ ├─ App.vue 26 | │ │ └─ main.js 27 | │ └─ index.ejs 28 | ├─ static/ 29 | ├─ test 30 | │ ├─ e2e 31 | │ │ ├─ specs/ 32 | │ │ ├─ index.js 33 | │ │ └─ utils.js 34 | │ ├─ unit 35 | │ │ ├─ specs/ 36 | │ │ ├─ index.js 37 | │ │ └─ karma.config.js 38 | │ └─ .eslintrc 39 | ├─ .babelrc 40 | ├─ .eslintignore 41 | ├─ .eslintrc.js 42 | ├─ .gitignore 43 | ├─ package.json 44 | └─ README.md 45 | ``` 46 | 47 | #### 产品构建 48 | 49 | ``` 50 | app.asar 51 | ├─ dist 52 | │ └─ electron 53 | │ ├─ static/ 54 | │ ├─ index.html 55 | │ ├─ main.js 56 | │ └─ renderer.js 57 | ├─ node_modules/ 58 | └─ package.json 59 | ``` 60 | 61 | 可以说,几乎所有的东西都在最终的产品构建中被删除。在分发 electron 应用程序时,这几乎是强制性的,因为你不希望用户下载拥有庞大文件的臃肿的软件。 62 | -------------------------------------------------------------------------------- /docs/en/testing.md: -------------------------------------------------------------------------------- 1 | # Testing 2 | 3 | electron-vue supports both unit testing and end-to-end testing for the `renderer` process and is heavily inspired by the testing setup provided with the official `vuejs-templates/webpack` boilerplate. During `vue-cli` scaffolding you will have the option to include testing support. 4 | 5 | ## [Unit testing](unittesting.md) 6 | 7 | Run unit tests with Karma + Mocha 8 | 9 | ```bash 10 | npm run unit 11 | ``` 12 | 13 | ## [End-to-end testing](end-to-end_testing.md) 14 | 15 | Run end-to-end tests with Spectron + Mocha 16 | 17 | ```bash 18 | npm run e2e 19 | ``` 20 | 21 | ## Running all tests 22 | 23 | ```bash 24 | npm test 25 | ``` 26 | 27 | ### On the subject of CI testing 28 | 29 | If your decided to use `electron-builder` as your build tool when scaffolding, then you can easily test your application on both Travis CI & AppVeyor for `darwin`, `linux`, and `win32`. Inside both `.travis.yml` and `appveyor.yml` you will find commented sections you can quickly un-comment to enable testing. Make sure to read up on [**Automated Deployments using CI**](/using-electron-builder.md#automated-deployments-using-ci)** **for further information. 30 | 31 | -------------------------------------------------------------------------------- /docs/ja/webpack-configurations.md: -------------------------------------------------------------------------------- 1 | # Webpack構成 2 | 3 | electron-vue には `.electron-vue/` ディレクトリに置かれた3つの別々の webpack 設定ファイルが入っています。 `web` 出力のオプションは別として、 `main` と `renderer`はセットアップが似通っています。どちらも `node@7` の機能を対象にするために `babel-preset-env` と `babili` を使用し、全てのモジュールを `externals` として扱います。 4 | 5 | ### `.electron-vue/webpack.main.config.js` 6 | 7 | electron の `main` プロセスを対象にします。この構成はかなり最低限ですが、いくつかの一般的な `webpack` のプラクティスが含まれています。 8 | 9 | ### `.electron-vue/webpack.renderer.config.js` 10 | 11 | electron の `renderer` プロセスを対象にします。この構成は Vue アプリケーションを取り扱うので、 `vue-loader` や公式の `vuejs-templates/webpack` ボイラープレートで使用可能なその他多くの構成が含まれます。 12 | 13 | ##### 外部依存のホワイトリスト化 14 | 15 | この構成について考慮すべき重要なことの1つは、特定のモジュールを webpack `externals` として扱わないようにホワイトリストに登録できることです。この機能性が必要になるユースケースはあまりありませんが、 `*.vue` コンポーネントそのままを提供する Vue UI ライブラリーの場合は、ホワイトリストに登録が必要なため、 `vue-loader` はそれらをコンパイルできます。もう1つのユースケースは、フルコンパイラとランタイムビルドをインポートするために `vue` を設定するなどのような webpack の `alias` を使用する場合です。このため、 `vue` はすでにホワイトリストに入っています。 16 | 17 | ### `.electron-vue/webpack.web.config.js` 18 | 19 | ブラウザ用に `renderer` プロセスのソースコードをビルド対象にします。この設定は web に公開する必要がある場合に強力な開始基盤として提供されています。**electron-vue は提供されているもの以上の web 出力をサポートしていません。**web 出力に関する課題は延期されるかクローズする可能性が高いでしょう。 20 | -------------------------------------------------------------------------------- /docs/cn/savingreading-local-files.md: -------------------------------------------------------------------------------- 1 | # 读写本地文件 2 | 3 | 使用 `electron` 的一大好处是可以访问用户的文件系统。这使你可以读取和写入本地系统上的文件。为了避免 Chromium 的限制以及对应用程序内部文件的改写,请确保使用 `electron` 的 API,特别是 [`app.getPath(name)`](https://electron.atom.io/docs/api/app/#appgetpathname) 函数。这个帮助函数可以使你获得指向系统目录的文件路径,如用户的桌面、系统临时文件 等等。 4 | 5 | ### 使用案例 6 | 7 | 假设我们想为我们的应用程序提供本地的数据库存储。在这个例子中,我们将用 [`nedb`](https://github.com/louischatriot/nedb) 作为演示。 8 | 9 | ```bash 10 | yarn add nedb # 或 npm install nedb --save 11 | ``` 12 | 13 | **src/renderer/datastore.js** 14 | 15 | 这里,我们设置 NeDB 并将其指向我们的 `userData` 目录。这个空间专门为我们的应用程序所保留,所以,我们可以确信,其他程序 或 与其他用户的交互不应该篡改这个文件空间。至此,我们可以在 `renderer` 进程中导入 `datastore.js` 并使用它。 16 | 17 | ```js 18 | import Datastore from 'nedb' 19 | import path from 'path' 20 | import { remote } from 'electron' 21 | 22 | export default new Datastore({ 23 | autoload: true, 24 | filename: path.join(remote.app.getPath('userData'), '/data.db') 25 | }) 26 | ``` 27 | 28 | **src/renderer/main.js** 29 | 30 | 为了更进一步,我们可以将数据存储导入到 `src/renderer/main.js` 里,并将其附加到 Vue 的 原型 (prototype) 上。通过在所有组件文件中使用 `this.$db`,我们现在可以访问数据存储的 API。 31 | 32 | ```js 33 | import db from './datastore' 34 | 35 | /* 其它代码 */ 36 | 37 | Vue.prototype.$db = db 38 | ``` 39 | -------------------------------------------------------------------------------- /docs/en/meta.md: -------------------------------------------------------------------------------- 1 | # Meta 2 | 3 | ### Thank You 4 | 5 | Wow, thank you guys so much for helping make electron-vue one of the top 3`vue-cli`templates \(that I can find\) on GitHub. I never thought this project would ever take off like it has today. Thinking back, I originally made this boilerplate \(in **May 2016**\) for a personal closed sourced project and decided to open source \(the boilerplate itself\) when I knew I had a majority of the pieces together. Fast-forward to today and there have been so many new features implemented and amazing support from the community. I also want to give a special shoutout to those in the community helping answer issues when I'm not able to. You guys have absolutely no obligation to do anything but you do anyway, and I am grateful for that. 6 | 7 | If you are reading this, then I can almost assume you really do enjoy electron-vue. A lot of time was spent creating this boilerplate. If you are feeling generous, then feel free to leave a tip if you want. Surely future development of electron-vue is not dependent upon donations, but its always an option if you decide to use it. 8 | 9 | #### [**PayPal.me**](https://www.paypal.me/simulatedgreg/5) 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tests/scaffold.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const projectDir = process.env.SEMAPHORE_PROJECT_DIR 4 | const templateName = process.argv[2] 5 | 6 | const suppose = require('suppose') 7 | const template = require('./builds.json')[templateName] 8 | 9 | const YELLOW = '\x1b[33m' 10 | const END = '\x1b[0m' 11 | 12 | process.chdir(process.cwd() + '/builds') 13 | 14 | generate(templateName, template) 15 | 16 | setTimeout(() => { 17 | process.exit() 18 | }, 4000) 19 | 20 | function generate (key, build) { 21 | console.log(`${YELLOW}Generating \`${key}\`${END}`) 22 | 23 | suppose('vue', ['init', `${projectDir}`, key], { debug: process.stdout }) 24 | .when(/Application Name/g).respond(build[0]) 25 | .when(/Project description/g).respond(build[1]) 26 | .when(/plugins/g).respond(build[2]) 27 | .when(/ESLint/g).respond(build[3]) 28 | .when(/config/g).respond(build[4]) 29 | .when(/unit/g).respond(build[5]) 30 | .when(/end-to-end/g).respond(build[6]) 31 | .when(/build tool/g).respond(build[7]) 32 | .when(/author/g).respond(build[8]) 33 | .on('error', err => { 34 | console.log(err.message) 35 | }) 36 | .end(code => { 37 | process.exit(code) 38 | }) 39 | } 40 | 41 | -------------------------------------------------------------------------------- /docs/cn/project_structure.md: -------------------------------------------------------------------------------- 1 | # 项目结构 2 | 3 | 当涉及制作 electron 应用程序的问题时,项目结构会有些不同。如果你以前使用过官方的 [`vuejs-templates/webpack`](https://github.com/vuejs-templates/webpac) 设置,那么你对这个结构应该很熟悉。本文档在此章节将尝试解释样板代码的工作原理以及应用程序在构建中的一些区别。 4 | 5 | ### 单一的 `package.json` 设置 6 | 7 | 就在不久之前,两个 `package.json` 的设置是必需的,但是,感谢 [@electron-userland](https://github.com/electron-userland) 的努力,[`electron-packager`](https://github.com/electron-userland/electron-packager) 和 [`electron-builder`](https://github.com/electron-userland/electron-builder) 现在完全支持单一的 `package.json` 设置。 8 | 9 | #### `dependencies` 10 | 11 | 这些依赖项 **将会被** 包含在你最终产品的应用程序中。所以,如果你的应用程序需要某个模块才能运行,那么请在此安装! 12 | 13 | #### `devDependencies` 14 | 15 | 这些依赖项 **不会被** 包含在你最终产品的应用程序中。在这里,你可以安装专门用于开发的模块,如构建脚本、`webpack` 加载器等等。 16 | 17 | #### 安装原生 NPM 模块 18 | 19 | 我们需要确保我们本地的 npm 模块是针对 electron 来构建的。为了做到这一点,我们可以使用 [`electron-rebuild`](https://github.com/electron/electron-rebuild),但是为了使事情变得更简单,我们强烈建议使用 [`electron-builder`](https://github.com/electron-userland/electron-builder) 作为你的构建工具,因为它会为你处理很多任务。 20 | 21 | ### 关于 `main` 进程 22 | 23 | 在开发过程中,你可能会注意到 `src/main/index.dev.js`。该文件专门用于开发以及安装开发工具。原则上,该文件不应该被修改,但是可以被用来扩展你的开发需求。在构建的过程中,`webpack` 将介入其中并创建一个的捆绑,以 `src/main/index.js` 作为该捆绑的入口文件。 24 | -------------------------------------------------------------------------------- /docs/en/using_css_frameworks.md: -------------------------------------------------------------------------------- 1 | # Using CSS Frameworks 2 | 3 | Although this may seem like a no brainer, I'd suggest you import your third-party CSS libraries into webpack using the [`style-loader`](https://github.com/webpack/style-loader), which is already setup for you. 4 | 5 | ## Use Case 6 | 7 | Say you want to use [bootstrap](http://getbootstrap.com/), [bulma](http://bulma.io/), or [materialize](http://materializecss.com/) for your application. Go ahead and install your library from `npm` like you normally would, but instead of attaching the asset to `index.ejs` we will import the CSS in our JavaScript, specifically in `src/renderer/main.js`. 8 | 9 | #### Example 10 | 11 | Let's install `bulma` 12 | 13 | ```bash 14 | npm install bulma --save 15 | ``` 16 | 17 | Then inside `src/renderer/main.js` let's add this line. 18 | 19 | ```bash 20 | import 'bulma/css/bulma.css' 21 | ``` 22 | 23 | Alternatively, you can also include `bulma` from inside a component file. 24 | 25 | **App.vue** 26 | 27 | ```html 28 | 31 | ``` 32 | 33 | Now `webpack` will know to load in `bulma` for our application and make it available in our production builds. 34 | 35 | -------------------------------------------------------------------------------- /docs/cn/unittesting.md: -------------------------------------------------------------------------------- 1 | # 单元测试 2 | 3 | 对于进行单元测试,electron-vue 使用 [Karma](https://karma-runner.github.io/1.0/index.html) 作为测试的运行器,使用 [Mocha](https://mochajs.org/) \(与 [Chai](http://chaijs.com/)\ 作为测试框架。 4 | 5 | Mocha 和 Chai 分别使用 `karma-mocha` 和 `karma-chai` 进行集成,所以所有的 API(例如 `expect`)都可以在测试文件中全局使用。 6 | 7 | ### 运行测试 8 | 9 | ```bash 10 | # 开始 Karma 11 | npm run unit 12 | ``` 13 | 14 | ### 文件结构 15 | 16 | ``` 17 | my-project 18 | ├─ test 19 | | ├─ unit 20 | │ │ ├─ specs/ 21 | │ │ ├─ index.js 22 | └─ └─ └─ karma.conf.js 23 | ``` 24 | 25 | **在大多数情况下,你可以忽略** `index.js` **和** `karma.conf.js` **,只专注于编写** `specs/` **。** 26 | 27 | #### `specs/` 28 | 29 | 这个目录里面是编写实际测试代码的地方。由于 Webpack 的强大功能,你可以完全依照 ES2015 和 其支持的加载程序编写。 30 | 31 | #### `index.js` 32 | 33 | 这是 `karma-webpack` 使用的入口文件。该文件的目的是一次性收集加载所有的测试和源代码。 34 | 35 | #### `karma.conf.js` 36 | 37 | 在这里,你可以找到实际的 `karma` 配置,并使用 spec/coverage 记录器进行设置。你可以根据 [karma 官方文档](http://karma-runner.github.io/1.0/config/configuration-file.html) 进一步定制。 38 | 39 | ### Mocking Dependencies 40 | 41 | electron-vue 默认安装 [`inject-loader`](https://github.com/plasticine/inject-loader)。有关使用 Vue 组件文件的信息,请参阅 [`vue-loader' 的测试与仿真文档](http://vue-loader.vuejs.org/en/workflow/testing-with-mocks.html)。 42 | -------------------------------------------------------------------------------- /docs/ja/file-tree.md: -------------------------------------------------------------------------------- 1 | # ファイルツリー 2 | 3 | ### 開発中 4 | 5 | **注**: 一部のファイル/フォルダは `vue-cli` スキャフォールディングで選択した設定に応じて異なる場合があります。 6 | 7 | ``` 8 | my-project 9 | ├─ .electron-vue 10 | │ └─ .js files 11 | ├─ build 12 | │ └─ icons/ 13 | ├─ dist 14 | │ ├─ electron/ 15 | │ └─ web/ 16 | ├─ node_modules/ 17 | ├─ src 18 | │ ├─ main 19 | │ │ ├─ index.dev.js 20 | │ │ └─ index.js 21 | │ ├─ renderer 22 | │ │ ├─ components/ 23 | │ │ ├─ router/ 24 | │ │ ├─ store/ 25 | │ │ ├─ App.vue 26 | │ │ └─ main.js 27 | │ └─ index.ejs 28 | ├─ static/ 29 | ├─ test 30 | │ ├─ e2e 31 | │ │ ├─ specs/ 32 | │ │ ├─ index.js 33 | │ │ └─ utils.js 34 | │ ├─ unit 35 | │ │ ├─ specs/ 36 | │ │ ├─ index.js 37 | │ │ └─ karma.config.js 38 | │ └─ .eslintrc 39 | ├─ .babelrc 40 | ├─ .eslintignore 41 | ├─ .eslintrc.js 42 | ├─ .gitignore 43 | ├─ package.json 44 | └─ README.md 45 | ``` 46 | 47 | #### 本番ビルド 48 | 49 | ``` 50 | app.asar 51 | ├─ dist 52 | │ └─ electron 53 | │ ├─ static/ 54 | │ ├─ index.html 55 | │ ├─ main.js 56 | │ └─ renderer.js 57 | ├─ node_modules/ 58 | └─ package.json 59 | ``` 60 | 61 | おそらくお分かりの通り、ほとんどすべてが最終的な本番ビルドでは取り除かれます。electron アプリケーションを配布する際は、大きいファイルサイズのソフトウェアをユーザーにダウンロードさせたくないので、これはほとんど必須です。 62 | -------------------------------------------------------------------------------- /docs/en/SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Summary 2 | 3 | * [Introduction](./README.md) 4 | * [Getting Started](getting_started.md) 5 | * [Project Structure](project_structure.md) 6 | * [File Tree](file-tree.md) 7 | * [Renderer Process](renderer-process.md) 8 | * [Main Process](main-process.md) 9 | * [Webpack Configurations](webpack-configurations.md) 10 | * [Development](development.md) 11 | * [Entry index.html](entry_indexhtml.md) 12 | * [Vue Plugins](vue_accessories.md) 13 | * [NPM Scripts](npm_scripts.md) 14 | * [Using CSS Frameworks](using_css_frameworks.md) 15 | * [Using Pre-Processors](using_pre-processors.md) 16 | * [Using Static Assets](using-static-assets.md) 17 | * [Read & Write Local Files](savingreading-local-files.md) 18 | * [Debugging](debugging-production.md) 19 | * [Building Your App](building_your_app.md) 20 | * [Using electron-packager](using-electron-packager.md) 21 | * [Using electron-builder](using-electron-builder.md) 22 | * [Testing](testing.md) 23 | * [Unit Testing](unittesting.md) 24 | * [End-to-End Testing](end-to-end_testing.md) 25 | * [Meta](meta.md) 26 | * [FAQs](faqs.md) 27 | * [New Releases](new-releases.md) 28 | * [Migration Guide](migration-guide.md) 29 | * [Contributing](contributing.md) 30 | 31 | -------------------------------------------------------------------------------- /docs/ja/npm_scripts.md: -------------------------------------------------------------------------------- 1 | # NPM スクリプト 2 | 3 | 開発プロセスに関する冗長なタスクを排除するために、役立つ NPM スクリプトに注目してください。次のコマンドは、プロジェクトのルートディレクトリから実行する必要があります。そしてもちろん、以下のコマンドのどれでも `yarn run ` を使用して実行することが可能です。 4 | 5 | ### `npm run build` 6 | 7 | 本番用にアプリケーションをビルドし、パッケージングします。詳細は [**アプリケーションのビルド**](building_your_app.md) セクションを参照してください。 8 | 9 | ### `npm run dev` 10 | 11 | 開発用にアプリケーションを実行します。 12 | 13 | ### `npm run lint` 14 | 15 | 全ての `src/` と `test/` の JS と Vue コンポーネントファイルをリントします。 16 | 17 | ### `npm run lint:fix` 18 | 19 | 全ての `src/` と `test/` の JS と Vue コンポーネントファイルをリントし、問題を解決しようとします。 20 | 21 | ### `npm run pack` 22 | 23 | `npm run pack:main` と `npm run pack:renderer` の両方を実行します。これらのコマンドは利用可能ですが、`npm run build` がこのステップを処理するため、手動で実行する場面はそれほど多くありません。 24 | 25 | ### `npm run pack:main` 26 | 27 | `main` プロセスのソースコードをビルドするために webpack を実行します。 28 | 29 | ### `npm run pack:renderer` 30 | 31 | `renderer` プロセスのソースコードをビルドするために webpack を実行します。 32 | 33 | ### `npm run unit` 34 | 35 | Karma と Jasmine でユニットテストを実行します。詳細は[**ユニットテスト**](unittesting.md)を参照してください。 36 | 37 | ### `npm run e2e` 38 | 39 | Spectron と Mocha でE2Eテストを実行します。詳細は[**E2Eテスト**](end-to-end_testing.md)を参照してください。 40 | 41 | ### `npm test` 42 | 43 | `npm run unit` と `npm run e2e` の両方を実行します。詳細は[**テスト**](testing.md)を参照してください。 44 | -------------------------------------------------------------------------------- /docs/ja/main-process.md: -------------------------------------------------------------------------------- 1 | # メインプロセス 2 | 3 | > Electron では、package.json のメインスクリプトを実行するプロセスをメインプロセスと呼びます。メインプロセスで実行されるスクリプトは、Web ページを作成して GUI を表示できます。 4 | 5 | [**Electron ドキュメンテーション**](http://electron.atom.io/docs/tutorial/quick-start/#main-process)**より ** 6 | 7 | --- 8 | 9 | `main` プロセスは根本的に完全な Node 環境なので、2つのファイル以外の初期プロジェクト構造は存在しません。 10 | 11 | #### `src/main/index.js` 12 | 13 | このファイルはアプリケーションのメインファイルであり、 `electron` が起動するファイルです。本番向けの `webpack` のエントリーファイルとしても使われます。すべての `main` プロセスの作業はここから開始しなければなりません。 14 | 15 | #### `app/src/main/index.dev.js` 16 | 17 | このファイルは開発時にのみ `electron-debug` と `vue-devtools`をインストールするために使われます。このファイルを修正する必要はありませんが、開発の必要に応じて拡張することもできます。 18 | 19 | ## `__dirname` と `__filename` の使用について 20 | 21 | `main` プロセスは `webpack` を使用してバンドルされているため、`__dirname` と `__filename` を使用しても本番環境で期待した値は得られ **ないでしょう**。[**ファイルツリー**](/file-tree.md) を参照すると、本番環境では `main.js` が `dist/electron` フォルダの中に置かれていることがわかるでしょう。この知識に基づいて、`__dirname` と `__filename` を適切に使用してください。 22 | 23 | **`static/` アセットディレクトリへのパスが必要な場合は、**[**静的なアセットの使用**](/using-static-assets.md)** を参照して、とても便利な `__static` 変数について学んでください。** 24 | 25 | ``` 26 | app.asar 27 | ├─ dist 28 | │ └─ electron 29 | │ ├─ static/ 30 | │ ├─ index.html 31 | │ ├─ main.js 32 | │ └─ renderer.js 33 | ├─ node_modules/ 34 | └─ package.json 35 | ``` 36 | -------------------------------------------------------------------------------- /docs/ja/global_configuration.md: -------------------------------------------------------------------------------- 1 | # Global Configuration 2 | 3 | electron-vue uses the [webpack](https://github.com/webpack/webpack) module loader system for pre-processing, bundling, and building your app. The default settings are rather common and should meet most of your needs. An additional `config.js` is provided in the root directory for quick adjustments. Further customization can be made by directly adjusting `webpack.main.config.js` and `webpack.renderer.config.js`. 4 | 5 | #### `config.js` 6 | 7 | **Note**: Some options may differ based on the settings choosen during `vue-cli` scaffolding. 8 | 9 | ```js 10 | { 11 | // Name of electron app 12 | // Will be used in production builds 13 | name: 'app', 14 | // Use ESLint 15 | // Further changes can be made in `.eslintrc.js` 16 | eslint: true, 17 | // webpack-dev-server port 18 | port: 9080, 19 | // electron-packager options 20 | // See `Building you app` for more info 21 | building: { 22 | arch: 'x64', 23 | asar: true, 24 | dir: path.join(__dirname, 'app'), 25 | icon: path.join(__dirname, 'app/icons/icon'), 26 | ignore: /\b(src|index\.ejs|icons)\b/, 27 | name: pkg.name, 28 | out: path.join(__dirname, 'builds'), 29 | overwrite: true, 30 | platform: process.env.PLATFORM_TARGET || 'all' 31 | } 32 | } 33 | ``` 34 | -------------------------------------------------------------------------------- /docs/cn/global_configuration.md: -------------------------------------------------------------------------------- 1 | # Global Configuration 2 | 3 | electron-vue uses the [webpack](https://github.com/webpack/webpack) module loader system for pre-processing, bundling, and building your app. The default settings are rather common and should meet most of your needs. An additional `config.js` is provided in the root directory for quick adjustments. Further customization can be made by directly adjusting `webpack.main.config.js` and `webpack.renderer.config.js`. 4 | 5 | #### `config.js` 6 | **Note**: Some options may differ based on the settings choosen during `vue-cli` scaffolding. 7 | 8 | ```js 9 | { 10 | // Name of electron app 11 | // Will be used in production builds 12 | name: 'app', 13 | 14 | // Use ESLint 15 | // Further changes can be made in `.eslintrc.js` 16 | eslint: true, 17 | 18 | // webpack-dev-server port 19 | port: 9080, 20 | 21 | // electron-packager options 22 | // See `Building you app` for more info 23 | building: { 24 | arch: 'x64', 25 | asar: true, 26 | dir: path.join(__dirname, 'app'), 27 | icon: path.join(__dirname, 'app/icons/icon'), 28 | ignore: /\b(src|index\.ejs|icons)\b/, 29 | name: pkg.name, 30 | out: path.join(__dirname, 'builds'), 31 | overwrite: true, 32 | platform: process.env.PLATFORM_TARGET || 'all' 33 | } 34 | } 35 | ``` 36 | -------------------------------------------------------------------------------- /docs/en/global_configuration.md: -------------------------------------------------------------------------------- 1 | # Global Configuration 2 | 3 | electron-vue uses the [webpack](https://github.com/webpack/webpack) module loader system for pre-processing, bundling, and building your app. The default settings are rather common and should meet most of your needs. An additional `config.js` is provided in the root directory for quick adjustments. Further customization can be made by directly adjusting `webpack.main.config.js` and `webpack.renderer.config.js`. 4 | 5 | #### `config.js` 6 | **Note**: Some options may differ based on the settings choosen during `vue-cli` scaffolding. 7 | 8 | ```js 9 | { 10 | // Name of electron app 11 | // Will be used in production builds 12 | name: 'app', 13 | 14 | // Use ESLint 15 | // Further changes can be made in `.eslintrc.js` 16 | eslint: true, 17 | 18 | // webpack-dev-server port 19 | port: 9080, 20 | 21 | // electron-packager options 22 | // See `Building you app` for more info 23 | building: { 24 | arch: 'x64', 25 | asar: true, 26 | dir: path.join(__dirname, 'app'), 27 | icon: path.join(__dirname, 'app/icons/icon'), 28 | ignore: /\b(src|index\.ejs|icons)\b/, 29 | name: pkg.name, 30 | out: path.join(__dirname, 'builds'), 31 | overwrite: true, 32 | platform: process.env.PLATFORM_TARGET || 'all' 33 | } 34 | } 35 | ``` 36 | -------------------------------------------------------------------------------- /docs/ja/savingreading-local-files.md: -------------------------------------------------------------------------------- 1 | # ローカルファイルの読み書き 2 | 3 | `electron` を使用する利点の一つは、ユーザーのファイルシステムにアクセスできることです。これにより、ローカルシステム上のファイルを読み書きすることができます。Chromium の制限を回避し、アプリケーションの内部ファイルに書き込むには、`electron` の API 、特に [`app.getPath(name)`](https://electron.atom.io/docs/api/app/#appgetpathname) 関数を使用してください。このヘルパーメソッドは、ユーザーのデスクトップ、システムの一時ファイルなどのシステムディレクトリへのファイルパスを取得できます。 4 | 5 | ### ユースケース 6 | 7 | アプリケーション用のローカルデータベースストアを用意したいとしましょう。この例では、[`nedb`](https://github.com/louischatriot/nedb) を使って説明します。 8 | 9 | ```bash 10 | yarn add nedb # or npm install nedb --save 11 | ``` 12 | 13 | **src/renderer/datastore.js** 14 | 15 | ここでは NeDB を設定し、パスを `userData` ディレクトリに向けます。このファイルスペースは、アプリケーション専用に確保されているため、他のプログラムや他のユーザーのやりとりがこのファイルスペースを改ざんしないだろうという確信を得ることができます。ここから、 `renderer` プロセスで `datastore.js` をインポートし、使うことができます。 16 | 17 | ```js 18 | import Datastore from 'nedb' 19 | import path from 'path' 20 | import { remote } from 'electron' 21 | export default new Datastore({ 22 | autoload: true, 23 | filename: path.join(remote.app.getPath('userData'), '/data.db') 24 | }) 25 | ``` 26 | 27 | **src/renderer/main.js** 28 | 29 | さらに手順を進めると、データストアを `src/renderer/main.js` にインポートし、 Vue のプロトタイプに設定することができます。そうすることで、全てのコンポーネントファイルで `this.$db` を通してデータストア API にアクセスすることができるようになりました。 30 | 31 | ```js 32 | import db from './datastore' 33 | /* 他のコード */ 34 | Vue.prototype.$db = db 35 | ``` 36 | -------------------------------------------------------------------------------- /docs/ja/unittesting.md: -------------------------------------------------------------------------------- 1 | # ユニットテスト 2 | 3 | electron-vue はユニットテストのためにテストランナーの [Karma](https://karma-runner.github.io/1.0/index.html) とテストフレームワークの [Mocha](https://mochajs.org/) ([Chai](http://chaijs.com/) と一緒に) を利用しています。 4 | 5 | Mocha と Chai はそれぞれ `karma-mocha` と `karma-chai` を使用して統合されているため、`expect` などの全ての API はテストファイルで全て使用可能です。 6 | 7 | ### テストの実行 8 | 9 | ```bash 10 | # Karma を始める 11 | npm run unit 12 | ``` 13 | 14 | ### ファイル構造 15 | 16 | ``` 17 | my-project 18 | ├─ test 19 | | ├─ unit 20 | │ │ ├─ specs/ 21 | │ │ ├─ index.js 22 | └─ └─ └─ karma.conf.js 23 | ``` 24 | 25 | **ほとんどの場合、**`index.js`** と **`karma.conf.js`** は無視して **`specs/`** を書くことだけに集中できます。** 26 | 27 | #### `specs/` 28 | 29 | このディレクトリの中に実際のテストが書かれています。webpackのおかげで、ES2015とサポートされているローダーにフルアクセスできます。 30 | 31 | #### `index.js` 32 | 33 | これは `karma-webpack` で使われるエントリーファイルです。このファイルの目的は、全てのテストとソースコードをワンショットで集めることです。 34 | 35 | #### `karma.conf.js` 36 | 37 | ここでは、スペック/カバレッジレポーターで設定された実際の `karma` 構成を見つけることができます。さらなるカスタマイズは[公式の karma のドキュメント](http://karma-runner.github.io/1.0/config/configuration-file.html)に従って行うことができます。 38 | 39 | ### 依存関係のモック化 40 | 41 | electron-vue にはデフォルトでインストールされた [`inject-loader`](https://github.com/plasticine/inject-loader) が付属しています。Vue コンポーネントファイルでの使用については、[`vue-loader` のドキュメントのモックを使用したテスト](http://vue-loader.vuejs.org/ja/workflow/testing-with-mocks.html)を参照してください。 42 | -------------------------------------------------------------------------------- /docs/cn/vue_accessories.md: -------------------------------------------------------------------------------- 1 | # Vue 插件 2 | 3 | electron-vue 包含以下 `vue` 插件,可以使用 `vue-cli` 脚手架安装... 4 | 5 | * [axios](https://github.com/mzabriskie/axios)\(网络请求\) 6 | * [vue-electron](https://github.com/SimulatedGREG/vue-electron) \(将 electron API 附加到 Vue 对象\) 7 | * [vue-router](https://github.com/vuejs/vue-router) \(单页应用路由\) 8 | * [vuex](https://github.com/vuejs/vuex) \(flux 启发的应用程序架构\) 9 | 10 | --- 11 | 12 | ### [`axios`](https://github.com/mzabriskie/axios) 13 | 14 | > 基于 Promise,用于浏览器和 node.js 的 HTTP 客户端 15 | 16 | 如果你熟悉 `vue-resource`,那么你也会觉得 `axios` 并不陌生,因为大部分 API 几乎是一样的。你可以在 `main` 进程脚本中轻松导入 `axios`,或者在 `renderer` 进程中使用 `this.$http` 或 `Vue.http`。 17 | 18 | ### [`vue-electron`](https://github.com/SimulatedGREG/vue-electron) 19 | 20 | > 将 electron API 附加到 Vue 对象的 vue 插件,使所有组件可以访问它们。 21 | 22 | 一个可以轻松通过 `this.$electron` 访问 electron API 的简单的 `vue` 插件,不再需要将 `electron` 导入到每一个组件中。 23 | 24 | ### [`vue-router`](https://github.com/vuejs/vue-router) 25 | 26 | > `vue-router` 是 [Vue.js](http://vuejs.org/) 的官方路由。它与 Vue.js 的核心深度整合,使 Vue.js 单页应用程序的构建变得轻而易举。 27 | 28 | 本项目所提供的项目结构应该与官方样板 `vuejs-templates/webpack` 中提供的设置很相似。 29 | 30 | ### [`vuex`](https://github.com/vuejs/vuex) 31 | 32 | > Vuex 是 Vue.js 应用程序的 **状态管理模式 + 库**。它作为程序中所有组件的集中存储,其规则确保了状态量只能以可预测的方式被改变。 33 | 34 | 本项目所提供的项目结构相当简单,但我们鼓励使用 `vuex` 的模块模式来帮助组织你的数据存储。外加的 `@/store/modules/index.js` 让你的 `vuex` 存储能够一次性导入所有的模块。 35 | -------------------------------------------------------------------------------- /docs/cn/getting_started.md: -------------------------------------------------------------------------------- 1 | # 起步 2 | 3 | ## 脚手架 4 | 5 | 该样板代码被构建为 [`vue-cli`](https://github.com/vuejs/vue-cli) 的一个模板,并且包含多个选项,可以自定义你最终的脚手架程序。本项目需要使用 `node@^7` 或更高版本。electron-vue 官方推荐 [`yarn`](https://yarnpkg.org) 作为软件包管理器,因为它可以更好地处理依赖关系,并可以使用 `yarn clean` 帮助减少最后构建文件的大小。 6 | 7 | ```bash 8 | # 安装 vue-cli 和 脚手架样板代码 9 | npm install -g vue-cli 10 | vue init simulatedgreg/electron-vue my-project 11 | 12 | # 安装依赖并运行你的程序 13 | cd my-project 14 | yarn # 或者 npm install 15 | yarn run dev # 或者 npm run dev 16 | ``` 17 | 18 | #### 关于 electron 19 | 20 | 虽然是可选的,仍旧我们建议在创建项目之后锁定你 electron 的版本。这样可以防止在同一项目上工作的其他开发者使用不同的版本进行开发。electron 经常发布新版本,所以一些功能特性总是会发生相应的变化。[更多信息](http://electron.atom.io/docs/tutorial/electron-versioning/)。 21 | 22 | 23 | #### Windows 用户注意事项 24 | 25 | 如果在 `npm install` 期间遇到关于 `node-gyp` 的错误,那么你很有可能没有在你的系统上安装正确的构建工具。构建工具包括 Python 和 Visual Studio 等等。感谢 [@felixrieseberg](https://github.com/felixrieseberg),有几个软件包可以帮助简化此过程。 26 | 27 | 我们需要检查的第一项是 npm 的版本,并确保它是最新的。这个可以使用 [`npm-windows-upgrade`](https://github.com/felixrieseberg/npm-windows-upgrade) 来完成。如果你使用 `yarn`,则可以跳过此项检查。 28 | 29 | 若上一项检查完成,我们可以继续设置所需的构建工具。使用 [`windows-build-tools`](https://github.com/felixrieseberg/windows-build-tools) 来为我们完成大部分烦人的工作。全局安装此工具将依次设置 Visual C++ 软件包、Python 等等。 30 | 31 | 到现在为止,所有工具都应该成功安装了,如果没有,那么你就会需要安装一个干净的 Visual Studio。请注意,这些并不是 electron-vue 自身的问题 \(Windows 有时候可能会很难用 ¯\\\_\(ツ\)\_/¯\)。 32 | -------------------------------------------------------------------------------- /template/.electron-vue/dev-client.js: -------------------------------------------------------------------------------- 1 | const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true') 2 | 3 | hotClient.subscribe(event => { 4 | /** 5 | * Reload browser when HTMLWebpackPlugin emits a new index.html 6 | * 7 | * Currently disabled until jantimon/html-webpack-plugin#680 is resolved. 8 | * https://github.com/SimulatedGREG/electron-vue/issues/437 9 | * https://github.com/jantimon/html-webpack-plugin/issues/680 10 | */ 11 | // if (event.action === 'reload') { 12 | // window.location.reload() 13 | // } 14 | 15 | /** 16 | * Notify `mainWindow` when `main` process is compiling, 17 | * giving notice for an expected reload of the `electron` process 18 | */ 19 | if (event.action === 'compiling') { 20 | document.body.innerHTML += ` 21 | 34 | 35 |
36 | Compiling Main Process... 37 |
38 | ` 39 | } 40 | }) 41 | -------------------------------------------------------------------------------- /docs/cn/entry_indexhtml.md: -------------------------------------------------------------------------------- 1 | # 入口 `index.html` 2 | 3 | 在产品阶段,electron-vue 使用 [**`html-webpack-plugin`**](https://github.com/ampedandwired/html-webpack-plugin) 创建 `index.html`。在开发过程中,你将在 `src/` 目录中找到一个 `index.ejs`。在这里,你可以更改 HTML 入口文件。 4 | 5 | 如果你不熟悉这个插件的工作原理,那么我鼓励你看看它的 [文档](https://www.npmjs.com/package/html-webpack-plugin)。简而言之,这个插件会自动将产品阶段的资源(包括 `renderer.js` 和 `styles.css`)注入到最终压缩版的 `index.html` 中。 6 | 7 | ### 开发阶段的 `index.ejs` 8 | 9 | ```html 10 | 11 | 12 | 13 | 14 | <%= htmlWebpackPlugin.options.title %> 15 | <%= ... %> 16 | 17 | 18 |
19 | 20 | 21 | 22 | ``` 23 | 24 | ### 产品阶段的 `index.html` \(非压缩版\) 25 | 26 | ```html 27 | 28 | 29 | 30 | 31 | app 32 | 33 | 34 | 35 |
36 | 37 | 38 | 39 | ``` 40 | 41 | ### 关于 CDNs 的使用 42 | 43 | 虽然使用 CDN 提供的资源有益于你的应用程序的最终版本的大小,但我建议不要使用它们。主要原因是,通过这样做,你其实是在假设你的应用程序始终可以访问互联网,而 Electron 应用程序并不总是如此。这成为使用 CSS 框架(如 bootstrap)的一个相当重要的问题,因为没有互联网,你的应用程序将迅速变得没有任何样式并且乱七八糟。 44 | 45 | > “我不在乎,我还是想用CDN。” 46 | 47 | 如果你坚持使用 CDN,那么你仍可以通过将标签添加到 `src/index.ejs` 文件中达到目的。只是当你的应用程序处于离线模式时,请确保设置适当的 UI/UX 流程。 48 | -------------------------------------------------------------------------------- /docs/en/file-tree.md: -------------------------------------------------------------------------------- 1 | # File Tree 2 | 3 | ### During development 4 | 5 | **Note**: Some files/folders may differ based on the settings chosen during `vue-cli` scaffolding. 6 | 7 | ``` 8 | my-project 9 | ├─ .electron-vue 10 | │ └─ .js files 11 | ├─ build 12 | │ └─ icons/ 13 | ├─ dist 14 | │ ├─ electron/ 15 | │ └─ web/ 16 | ├─ node_modules/ 17 | ├─ src 18 | │ ├─ main 19 | │ │ ├─ index.dev.js 20 | │ │ └─ index.js 21 | │ ├─ renderer 22 | │ │ ├─ components/ 23 | │ │ ├─ router/ 24 | │ │ ├─ store/ 25 | │ │ ├─ App.vue 26 | │ │ └─ main.js 27 | │ └─ index.ejs 28 | ├─ static/ 29 | ├─ test 30 | │ ├─ e2e 31 | │ │ ├─ specs/ 32 | │ │ ├─ index.js 33 | │ │ └─ utils.js 34 | │ ├─ unit 35 | │ │ ├─ specs/ 36 | │ │ ├─ index.js 37 | │ │ └─ karma.config.js 38 | │ └─ .eslintrc 39 | ├─ .babelrc 40 | ├─ .eslintignore 41 | ├─ .eslintrc.js 42 | ├─ .gitignore 43 | ├─ package.json 44 | └─ README.md 45 | ``` 46 | 47 | #### Production builds 48 | 49 | ``` 50 | app.asar 51 | ├─ dist 52 | │ └─ electron 53 | │ ├─ static/ 54 | │ ├─ index.html 55 | │ ├─ main.js 56 | │ └─ renderer.js 57 | ├─ node_modules/ 58 | └─ package.json 59 | ``` 60 | 61 | As you can probably tell, almost everything is stripped down in final production builds. This is almost mandatory when distributing electron apps, as you do not want your users to download bloated software with a large file size. 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /docs/ja/project_structure.md: -------------------------------------------------------------------------------- 1 | # プロジェクト構造 2 | 3 | electron アプリケーションの作成に関しては、プロジェクト構造は少し変わっています。これまで公式の [`vuejs-templates/webpack`](https://github.com/vuejs-templates/webpack) セットアップを使用していたのならば、構造はかなり似通っていると感じるでしょう。このセクションのドキュメントではどのようにボイラープレートが動作するかの概要とアプリケーションをビルドする際の違いを説明しようと思います。 4 | 5 | ### 単一の `package.json` によるセットアップ 6 | 7 | そんなに前のことではありませんが、2つの `package.json` によるセットアップが必要でした。しかし、 [@electron-userland](https://github.com/electron-userland) の努力のおかげで、 [`electron-packager`](https://github.com/electron-userland/electron-packager) と [`electron-builder`](https://github.com/electron-userland/electron-builder) の両方が完全に単一の `package.json` によるセットアップをサポートしています。 8 | 9 | #### `dependencies` 10 | 11 | これらの依存関係は最終的な本番アプリケーションに含まれ**ます**。つまり、アプリケーションが動作するのに必要なモジュールがある場合は、ここにインストールしてください! 12 | 13 | #### `devDependencies` 14 | 15 | これらの依存関係は最終的な本番アプリケーションに含まれ**ません**。ビルドスクリプトや`webpack` ローダーなどの開発に必要な特定のモジュールをインストールします。 16 | 17 | #### ネイティブ NPM モジュールのインストール 18 | 19 | ネイティブ npm モジュールが electron に対してビルドされていることを確認する必要があります。それをするためには、 [`electron-rebuild`](https://github.com/electron/electron-rebuild) を使用できます。しかし、単純化のため、これらのタスクをうまく処理するビルドツールに [`electron-builder`](https://github.com/electron-userland/electron-builder) を使用することを強くお勧めします。 20 | 21 | ### `main` プロセスについて 22 | 23 | 開発中に `src/main/index.dev.js` に気付くかもしれません。このファイルは特に開発のために使用され、開発ツールのインストールにも使用されます。このファイルを変更する必要はありませんが、開発の必要に応じて拡張するために使用することができます。ビルド時、`webpack` は `src/main/index.js` 自身をエントリーファイルとしてバンドルを作成します。 24 | -------------------------------------------------------------------------------- /docs/cn/end-to-end_testing.md: -------------------------------------------------------------------------------- 1 | # 端对端测试 2 | 3 | 对于端到端测试,electron-vue 使用 [Spectron](http://electron.atom.io/spectron/) 和 测试框架 [Mocha](https://mochajs.org/) \(以及 [Chai](http://chaijs.com/)\)。Mocha 和 Chai 的 API (包括 `expect`、`should` 以及 `assert` 在内) 均在全局范围内可用。 4 | 5 | ### 运行测试 6 | 7 | ```bash 8 | # 开始 Mocha 9 | npm run e2e 10 | ``` 11 | 12 | ##### 注意 13 | 14 | 在运行端到端测试之前,为了使 Spectron 在测试的时候可用,请调用 `npm run pack` 来创建一个产品构建。 15 | 16 | ### 文件结构 17 | 18 | ``` 19 | my-project 20 | ├─ test 21 | | ├─ e2e 22 | │ │ ├─ specs/ 23 | │ │ ├─ index.js 24 | └─ └─ └─ utils.js 25 | ``` 26 | 27 | **在大多数情况下,你可以忽略** `index.js` **,只专注于编写** `specs/` **。** 28 | 29 | #### `specs/` 30 | 31 | 这个目录里面是编写实际测试代码的地方。由于 `babel-register` 的强大功能,你可以完全依照 ES2015 进行编写。 32 | 33 | #### `index.js` 34 | 35 | 这是 Mocha 入口文件,并收集加载在 `specs/` 内的所有测试代码用于测试。 36 | 37 | #### `utils.js` 38 | 39 | 在这里,你会发现一些通用的函数,你可以在 `specs/` 中使用。其基本功能包括处理 electron 创建/销毁过程的 `beforeEach` 和 `afterEach`。 40 | 41 | ### 关于 Spectron 42 | 43 | Spectron 是使用 [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/) 和 [WebDriverIO](http://webdriver.io/) 来操作 DOM 元素的 [electron](http://electron.atom.io) 官方测试框架。 44 | 45 | #### WebDriverIO 的使用 46 | 47 | 如 Spectron 的 [文档](https://github.com/electron/spectron#client) 中所述,你可以通过访问 `this.app.client` 来访问 [WebDriverIO APIs](http://webdriver.io/api.html)。 由于 electron-vue 使用了 Mocha,`this` 在 `afterEach`、`beforeEach` 和 `it` 之间共享。 因此,值得注意的是,ES2015 的 箭头函数 (arrow function) 不能在某些情况下使用,因为 `this` 的语境将被覆盖 \([更多信息](https://mochajs.org/#arrow-functions)\)。 48 | -------------------------------------------------------------------------------- /docs/ja/entry_indexhtml.md: -------------------------------------------------------------------------------- 1 | # `index.html` 2 | 3 | electron-vue は本番ビルドで `index.html` を作成するために [**`html-webpack-plugin`**](https://github.com/ampedandwired/html-webpack-plugin) を使用します。開発中は `src/` ディレクトリの`index.ejs` となります。ここではエントリーとなる HTML ファイルを変更することができます。 4 | 5 | このプラグインがどのように動作するかわからない場合は、その[ドキュメント](https://www.npmjs.com/package/html-webpack-plugin)を見ることを勧めます。しかし要するに、このプラグインは自動的に `renderer.js` と `styles.css` を含む本番アセットを最終的にファイルサイズを小さくし、 `index.html` に挿入します。 6 | 7 | ### 開発中の `index.ejs` 8 | 9 | ```html 10 | 11 | 12 | 13 | 14 | <%= htmlWebpackPlugin.options.title %> 15 | <%= ... %> 16 | 17 | 18 |
19 | 20 | 21 | 22 | ``` 23 | 24 | ### 本番の(ファイルサイズを小さくしていない) `index.html` 25 | 26 | ```html 27 | 28 | 29 | 30 | 31 | app 32 | 33 | 34 | 35 |
36 | 37 | 38 | 39 | ``` 40 | 41 | ### CDN の利用について 42 | 43 | CDN から提供されるアセットを利用することは、アプリケーションの最終的なビルドサイズにとっては素晴らしい利点があるかもしれませんが、それらを使用することは勧めません。主な理由は、そうすることによってアプリケーションが必ずインターネットにアクセスできると仮定することになりますが、Electron アプリケーションの場合は必ずしもそうとは限りません。これは bootstrap のような CSS フレームワークではかなり重大な問題となり、アプリケーションはすぐに整っていない状態になるでしょう。 44 | 45 | > "私は気にしません、それでも CDN を使いたいです" 46 | 47 | それでも CDN を利用すると決めた場合は、 `src/index.ejs` ファイルにタグを追加することでできます。ただアプリケーションがオフラインの時の UI/UX フローを適切に設定してください。 48 | -------------------------------------------------------------------------------- /docs/en/npm_scripts.md: -------------------------------------------------------------------------------- 1 | # NPM Scripts 2 | 3 | To help eliminate redundant tasks around the development process, please take note of some of the NPM scripts available to you. The following commands should be ran from your project's root directory. And of course, you can run any of the below commands using `yarn run `. 4 | 5 | ### `npm run build` 6 | 7 | Build your app for production and package. More info can be found in the [**Building Your App**](building_your_app.md) section. 8 | 9 | ### `npm run dev` 10 | 11 | Run app in development. 12 | 13 | ### `npm run lint` 14 | 15 | Lint all your `src/`'s and `test/`'s JS & Vue component files. 16 | 17 | ### `npm run lint:fix` 18 | 19 | Lint all your `src/`'s and `test/`'s JS & Vue component files and attempt to fix issues. 20 | 21 | ### `npm run pack` 22 | 23 | Run both `npm run pack:main` & `npm run pack:renderer`. Although these commands are available, there are not many cases where you will need to manually do this as `npm run build` will handle this step. 24 | 25 | ### `npm run pack:main` 26 | 27 | Run webpack to bundle `main` process source code. 28 | 29 | ### `npm run pack:renderer` 30 | 31 | Run webpack to bundle `renderer` process source code. 32 | 33 | ### `npm run unit` 34 | 35 | Run unit tests with Karma + Jasmine. More information on [**Unit Testing**](unittesting.md). 36 | 37 | ### `npm run e2e` 38 | 39 | Run end-to-end tests with Spectron + Mocha. More information on [**End-to-end Testing**](end-to-end_testing.md). 40 | 41 | ### `npm test` 42 | 43 | Runs both `npm run unit` & `npm run e2e`. More information on [**Testing**](testing.md). 44 | 45 | -------------------------------------------------------------------------------- /docs/ja/vue_accessories.md: -------------------------------------------------------------------------------- 1 | # Vue プラグイン 2 | 3 | electron-vue には `vue-cli` でのスキャフォールディングの間にインストールできる次の `vue` プラグインが入っています... 4 | 5 | - [axios ](https://github.com/mzabriskie/axios)(web リクエスト) 6 | - [vue-electron](https://github.com/SimulatedGREG/vue-electron) (electron API を Vue オブジェクトに付け加える) 7 | - [vue-router](https://github.com/vuejs/vue-router) (シングルページアプリケーションのルーティング) 8 | - [vuex](https://github.com/vuejs/vuex) (Flux にインスパイアされたアプリケーションアーキテクチャ) 9 | 10 | --- 11 | 12 | ### [`axios`](https://github.com/mzabriskie/axios) 13 | 14 | > ブラウザーと Node.js のための Promise ベースの HTTP クライアント 15 | 16 | `vue-resource` をよく知っている場合、 `axios` はほとんどの API がほぼ同じであるため、とても馴染みやすいでしょう。`main` プロセススクリプトで簡単に `axios` をインポートしたり、 `renderer` プロセスで `this.$http` や `Vue.http` を使用することができます。 17 | 18 | ### [`vue-electron`](https://github.com/SimulatedGREG/vue-electron) 19 | 20 | > electron API を Vue オブジェクトに付け加え、全てのコンポーネントからアクセス可能にする vue プラグイン。 21 | 22 | electron API に `this.$electron` で簡単にアクセスできるようにするシンプルな `vue` プラグインです。全てのコンポーネントで `electron` をインポートする必要はありません。 23 | 24 | ### [`vue-router`](https://github.com/vuejs/vue-router) 25 | 26 | > `vue-router` は [Vue.js](http://jp.vuejs.org/) 公式のルーターです。Vue.js でシングルページアプリケーションを構築するために Vue.js のコアと深く結びついています。 27 | 28 | 提供されるプロジェクト構造は公式で提供されている `vuejs-templates/webpack` のボイラープレートの設定と似ているため馴染みやすいでしょう。 29 | 30 | ### [`vuex`](https://github.com/vuejs/vuex) 31 | 32 | > Vuex は Vue.js アプリケーション向けの**状態管理パターンであり、ライブラリ**でもあります。アプリケーション内の全てのコンポーネントの集中型ストアとして機能し、状態を予測可能な方法でのみ変更できることを保証するルールを備えています。 33 | 34 | 提供されるプロジェクト構造はかなり最低限ですが、`vuex` のモジュールパターンを使用してデータストアを整理することを勧めます。`@/store/modules/index.js` は `vuex` のストアが全てのモジュールをワンショットでインポートできるようにします。 35 | -------------------------------------------------------------------------------- /docs/ja/getting_started.md: -------------------------------------------------------------------------------- 1 | # はじめに 2 | 3 | ## スキャフォールディング 4 | 5 | このボイラープレートは [vue-cli](https://github.com/vuejs/vue-cli) のテンプレートとして作成され、スキャフォールディングされたアプリケーションをカスタマイズするためのオプションが含まれています。`node@^7` かそれ以上のバージョンを使用する必要があります。 electron-vue はパッケージマネージャの [`yarn`](https://yarnpkg.org) を公式に推奨しています。 依存関係をよりよく処理し、`yarn clean` により最終的なビルドサイズを減らすことができます。 6 | 7 | ```bash 8 | # vue-cli をインストールしボイラープレートをスキャフォールディングします 9 | npm install -g vue-cli 10 | vue init simulatedgreg/electron-vue my-project 11 | # 依存関係をインストールし、アプリケーションを実行します 12 | cd my-project 13 | yarn # or npm install 14 | yarn run dev # or npm run dev 15 | ``` 16 | 17 | #### electron について 18 | 19 | オプションとはいっても、プロジェクトをスキャフォールディングした後は electron のバージョンを固定することをお勧めします。これは、同じプロジェクトで作業している開発者が異なるバージョンで開発することを防ぐことに役立ちます。electron はリリースを頻繁に行うため、機能は常に変更対象となります。 [詳細な情報はこちら](http://electron.atom.io/docs/tutorial/electron-versioning/)。 20 | 21 | #### Windows ユーザーのための注意 22 | 23 | `npm install` 中に `node-gyp` に関するエラーが発生した場合、システムに適切なビルドツールがインストールされていない可能性が非常に高いです。ビルドツールには、Python や Visual Studio などのアイテムが含まれています。[@felixrieseberg](https://github.com/felixrieseberg) のおかげで、このプロセスを簡潔にするのに役立つパッケージがいくつかあります。 24 | 25 | 最初に確認する項目は npm のバージョンで、古いバージョンでないことを確認します。これは [`npm-windows-upgrade`](https://github.com/felixrieseberg/npm-windows-upgrade) を使用することで達成できます。`yarn` を使用する場合は、この確認をスキップすることができます。 26 | 27 | それが完了したら、引き続きビルドツールをセットアップします。[`windows-build-tools`](https://github.com/felixrieseberg/windows-build-tools) を使用することで、めんどくさいことの大半は完了します。これをグローバルにインストールすると Visual C ++パッケージ、 Python などがセットアップされます。 28 | 29 | この時点では正常にインストールされるはずですが、そうでない場合は Visual Studio をクリーンインストールする必要があります。これらは electron-vue 自身の問題ではないことに注意してください(Windows は時々面倒になることがあります ¯\\\_\(ツ\)\_/¯\)。 30 | -------------------------------------------------------------------------------- /docs/ja/end-to-end_testing.md: -------------------------------------------------------------------------------- 1 | # エンドツーエンドテスト 2 | 3 | electron-vue はエンドツーエンドテストのために [Spectron](http://electron.atom.io/spectron/) とテストフレームワークの [Mocha](https://mochajs.org/) ([Chai](http://chaijs.com/) と一緒に) を利用しています。Mocha と Chai の APIは、`expect`、`should`、`assert`を含め、グローバルスコープで利用可能です。 4 | 5 | ### テストの実行 6 | 7 | ```bash 8 | # Mocha を始める 9 | npm run e2e 10 | ``` 11 | 12 | ##### 注意 13 | 14 | エンドツーエンドテストを実行する前に、Spectron がテスト中に使用する本番ビルドを作成するために、`npm run pack` が呼び出されます。 15 | 16 | ### ファイル構造 17 | 18 | ``` 19 | my-project 20 | ├─ test 21 | | ├─ e2e 22 | │ │ ├─ specs/ 23 | │ │ ├─ index.js 24 | └─ └─ └─ utils.js 25 | ``` 26 | 27 | **ほとんどの場合、 **`index.js`** は無視して、 **`specs/`** を書くことだけに集中できます。** 28 | 29 | #### `specs/` 30 | 31 | このディレクトリの中に実際のテストが書かれています。`babel-register` の機能のおかげで、ES2015にフルアクセスできます。 32 | 33 | #### `index.js` 34 | 35 | このファイルは Mocha のメインエントリーとして機能し、テスト用に `specs/` で書かれた全てのテストを集めます。 36 | 37 | #### `utils.js` 38 | 39 | ここでは、`specs/` 全体で使用することができる汎用関数を見つけることができます。基本関数には、 electron の作成/破壊プロセスを処理する `beforeEach` と `afterEach` が含まれます。 40 | 41 | ### Spectron について 42 | 43 | Spectron は 公式の [electron](http://electron.atom.io) テストフレームワークであり、DOM 要素を操作するために [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/) と [WebDriverIO](http://webdriver.io/) の両方を使用します。 44 | 45 | #### WebDriverIO の使用 46 | 47 | Spectron の[ドキュメント](https://github.com/electron/spectron#client)に記載されている通り、[WebDriverIO API](http://webdriver.io/api.html) へのアクセスは `this.app.client` を通してすることができます。 electron-vue は Mocha を使用しているため、`this` のコンテキストは `afterEach`、`beforeEach`、`it` の間で共有されます。このため、ES2015 のアロー関数は、`this` のコンテキストが上書きされるため、特定の状況では使用できないことに注意することが重要です([詳細はこちら](https://mochajs.org/#arrow-functions))。 48 | -------------------------------------------------------------------------------- /tests/builds.json: -------------------------------------------------------------------------------- 1 | { 2 | "default": [ 3 | "\n", 4 | "\n", 5 | "\n", 6 | "\n", 7 | "\n", 8 | "\n", 9 | "\n", 10 | "\n", 11 | "\n" 12 | ], 13 | "eslint-airbnb": [ 14 | "\n", 15 | "\n", 16 | "\n", 17 | "\n", 18 | "\u001b[B\n", 19 | "\n", 20 | "\n", 21 | "\n", 22 | "\n" 23 | ], 24 | "eslint-none": [ 25 | "\n", 26 | "\n", 27 | "\n", 28 | "\n", 29 | "\u001b[B\u001b[B\n", 30 | "\n", 31 | "\n", 32 | "\n", 33 | "\n" 34 | ], 35 | "no-router": [ 36 | "\n", 37 | "\n", 38 | "\u001b[B\u001b[B \n", 39 | "\n", 40 | "\n", 41 | "\n", 42 | "\n", 43 | "\n", 44 | "\n" 45 | ], 46 | "no-vuex": [ 47 | "\n", 48 | "\n", 49 | "\u001b[B\u001b[B\u001b[B \n", 50 | "\n", 51 | "\n", 52 | "\n", 53 | "\n", 54 | "\n", 55 | "\n" 56 | ], 57 | "no-router-vuex": [ 58 | "\n", 59 | "\n", 60 | "\u001b[B\u001b[B \u001b[B \n", 61 | "\n", 62 | "\n", 63 | "\n", 64 | "\n", 65 | "\n", 66 | "\n" 67 | ], 68 | "no-unit": [ 69 | "\n", 70 | "\n", 71 | "\n", 72 | "\n", 73 | "\n", 74 | "n\n", 75 | "\n", 76 | "\n", 77 | "\n" 78 | ], 79 | "no-end-to-end": [ 80 | "\n", 81 | "\n", 82 | "\n", 83 | "\n", 84 | "\n", 85 | "\n", 86 | "n\n", 87 | "\n", 88 | "\n" 89 | ], 90 | "builder": [ 91 | "\n", 92 | "\n", 93 | "\n", 94 | "\n", 95 | "\n", 96 | "\n", 97 | "\n", 98 | "\u001b[B\n", 99 | "\n" 100 | ] 101 | } 102 | -------------------------------------------------------------------------------- /template/.travis.yml: -------------------------------------------------------------------------------- 1 | {{#testing unit e2e}} 2 | # Commented sections below can be used to run tests on the CI server 3 | # https://simulatedgreg.gitbooks.io/electron-vue/content/en/testing.html#on-the-subject-of-ci-testing 4 | {{/testing}} 5 | osx_image: xcode8.3 6 | sudo: required 7 | dist: trusty 8 | language: c 9 | matrix: 10 | include: 11 | - os: osx 12 | - os: linux 13 | env: CC=clang CXX=clang++ npm_config_clang=1 14 | compiler: clang 15 | cache: 16 | directories: 17 | - node_modules 18 | - "$HOME/.electron" 19 | - "$HOME/.cache" 20 | addons: 21 | apt: 22 | packages: 23 | - libgnome-keyring-dev 24 | - icnsutils 25 | {{#testing unit e2e}} 26 | #- xvfb 27 | {{/testing}} 28 | before_install: 29 | - mkdir -p /tmp/git-lfs && curl -L https://github.com/github/git-lfs/releases/download/v1.2.1/git-lfs-$([ 30 | "$TRAVIS_OS_NAME" == "linux" ] && echo "linux" || echo "darwin")-amd64-1.2.1.tar.gz 31 | | tar -xz -C /tmp/git-lfs --strip-components 1 && /tmp/git-lfs/git-lfs pull 32 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils; fi 33 | install: 34 | {{#testing unit e2e}} 35 | #- export DISPLAY=':99.0' 36 | #- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & 37 | {{/testing}} 38 | - nvm install 7 39 | - curl -o- -L https://yarnpkg.com/install.sh | bash 40 | - source ~/.bashrc 41 | - npm install -g xvfb-maybe 42 | - yarn 43 | script: 44 | {{#unit}} 45 | #- xvfb-maybe node_modules/.bin/karma start test/unit/karma.conf.js 46 | {{/unit}} 47 | {{#e2e}} 48 | #- yarn run pack && xvfb-maybe node_modules/.bin/mocha test/e2e 49 | {{/e2e}} 50 | - yarn run build 51 | branches: 52 | only: 53 | - master 54 | -------------------------------------------------------------------------------- /docs/en/unittesting.md: -------------------------------------------------------------------------------- 1 | # Unit Testing 2 | 3 | electron-vue makes use of the [Karma](https://karma-runner.github.io/1.0/index.html) test runner and the [Mocha](https://mochajs.org/) test framework \(with [Chai](http://chaijs.com/)\) for unit testing. 4 | 5 | Both Mocha and Chai are integrated using `karma-mocha` and `karma-chai` respectively, so all APIs such as `expect` are globally available in test files. 6 | 7 | ### Running Tests 8 | 9 | ```bash 10 | # Begin Karma 11 | npm run unit 12 | ``` 13 | 14 | ### File Structure 15 | 16 | ``` 17 | my-project 18 | ├─ test 19 | | ├─ unit 20 | │ │ ├─ specs/ 21 | │ │ ├─ index.js 22 | └─ └─ └─ karma.conf.js 23 | ``` 24 | 25 | **For the most part, you can ignore both **`index.js`** and **`karma.conf.js`** and focus solely on writing **`specs/`**.** 26 | 27 | #### `specs/` 28 | 29 | Inside this directory is where actual tests are written. Thanks to the power of webpack, you have full access to ES2015 and supported loaders. 30 | 31 | #### `index.js` 32 | 33 | This is the entry file used by `karma-webpack`. The purpose of this file is to gather all test and source code in a "one-shot" manner. 34 | 35 | #### `karma.conf.js` 36 | 37 | Here you will find the actual `karma` configuration, set up with spec/coverage reporters. Further customization can be made in accordance to the [official karma documentation](http://karma-runner.github.io/1.0/config/configuration-file.html). 38 | 39 | ### Mocking Dependencies 40 | 41 | electron-vue comes with [`inject-loader`](https://github.com/plasticine/inject-loader) installed by default. For usage with Vue component files see [`vue-loader` docs on testing with mocks](http://vue-loader.vuejs.org/en/workflow/testing-with-mocks.html). 42 | 43 | -------------------------------------------------------------------------------- /docs/en/new-releases.md: -------------------------------------------------------------------------------- 1 | # New Releases 2 | 3 | electron-vue has evolved greatly since its initial creation in May of 2016 and has introduced many new fantastic features. Can you believe there was a time `vue-cli` scaffolding wasn't supported? Development of new features is not planned to end anytime soon. The only down side to new bells & whistles every now and then is having your project stuck on an older scaffold. Since electron-vue takes advantage of `vue-cli` there unfortunately isn't a structured way to _version_ the boilerplate or make it _updatable_. 4 | 5 | Major updates of electron-vue will be made through GitHub Milestones and will include many new features/bug fixes at a time, making these releases the optimal time to [migrate](/migration-guide.md) any existing projects to a newer scaffold. These milestones are not usually planned, but arise as feature requests add up in the issue tracker. 6 | 7 | ### Past Milestones 8 | 9 | #### [Multiplex](https://github.com/SimulatedGREG/electron-vue/milestone/1?closed=1) 10 | 11 | * Migration to `webpack` 2 12 | * Support for `electron-builder` 13 | * Support for `main` process bundling 14 | * General bugfixing 15 | 16 | #### [Minimize](https://github.com/SimulatedGREG/electron-vue/issues/171) 17 | 18 | * Migration to single `package.json` structure 19 | * Travis CI / AppVeyor configs for `electron-builder` users 20 | * Minimal web output of `renderer` process 21 | * Migration to `axios` 22 | * Full support for `main` process bundling 23 | * Rewrite of development and build scripts 24 | * Migration to `babili` to remove the need of transpiling down completely to ES5 25 | * Support for `static/` assets when using modules that require a full path \([`__static`](/using-static-assets.md)\) 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /docs/en/webpack-configurations.md: -------------------------------------------------------------------------------- 1 | # Webpack Configurations 2 | 3 | electron-vue comes packed with three separate webpack config files located in the `.electron-vue/` directory. Aside for the optional use of the `web` output, both `main` and `renderer` are similar in setup. Both make use of `babel-preset-env` to target `node@7` features, use `babili`, and treat all modules as `externals`. 4 | 5 | ### `.electron-vue/webpack.main.config.js` 6 | 7 | Targets electron's `main` process. This configuration is rather bare, but does include some common `webpack` practices. 8 | 9 | ### `.electron-vue/webpack.renderer.config.js` 10 | 11 | Targets electron's `renderer` process. This configuration handles your Vue application, so it includes `vue-loader` and many other configurations that are available in the official `vuejs-templates/webpack` boilerplate. 12 | 13 | ##### White-listing Externals 14 | 15 | One important thing to consider about this config is that you can whitelist specific modules to not treat as webpack `externals`. There aren't many use cases where this functionality is needed, but for the case of Vue UI libraries that provide raw `*.vue` components they will need to be whitelisted, so `vue-loader` is able to compile them. Another use case would be using webpack `alias`es, such as setting `vue` to import the full Compiler + Runtime build. Because of this, `vue` is already in the whitelist. 16 | 17 | ### `.electron-vue/webpack.web.config.js` 18 | 19 | Targets building your `renderer` process source code for the browser. This config is provided as a strong starting base if you are in need of publishing to web. **electron-vue does not support web output further than what is provided.** Issues related to web output will most likely be deferred or closed. 20 | 21 | -------------------------------------------------------------------------------- /template/test/unit/karma.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const path = require('path') 4 | const merge = require('webpack-merge') 5 | const webpack = require('webpack') 6 | 7 | const baseConfig = require('../../.electron-vue/webpack.renderer.config') 8 | const projectRoot = path.resolve(__dirname, '../../src/renderer') 9 | 10 | // Set BABEL_ENV to use proper preset config 11 | process.env.BABEL_ENV = 'test' 12 | 13 | let webpackConfig = merge(baseConfig, { 14 | devtool: '#inline-source-map', 15 | plugins: [ 16 | new webpack.DefinePlugin({ 17 | 'process.env.NODE_ENV': '"testing"' 18 | }) 19 | ] 20 | }) 21 | 22 | // don't treat dependencies as externals 23 | delete webpackConfig.entry 24 | delete webpackConfig.externals 25 | delete webpackConfig.output.libraryTarget 26 | 27 | // apply vue option to apply isparta-loader on js 28 | webpackConfig.module.rules 29 | .find(rule => rule.use.loader === 'vue-loader').use.options.loaders.js = 'babel-loader' 30 | 31 | module.exports = config => { 32 | config.set({ 33 | browsers: ['visibleElectron'], 34 | client: { 35 | useIframe: false 36 | }, 37 | coverageReporter: { 38 | dir: './coverage', 39 | reporters: [ 40 | { type: 'lcov', subdir: '.' }, 41 | { type: 'text-summary' } 42 | ] 43 | }, 44 | customLaunchers: { 45 | 'visibleElectron': { 46 | base: 'Electron', 47 | flags: ['--show'] 48 | } 49 | }, 50 | frameworks: ['mocha', 'chai'], 51 | files: ['./index.js'], 52 | preprocessors: { 53 | './index.js': ['webpack', 'sourcemap'] 54 | }, 55 | reporters: ['spec', 'coverage'], 56 | singleRun: true, 57 | webpack: webpackConfig, 58 | webpackMiddleware: { 59 | noInfo: true 60 | } 61 | }) 62 | } 63 | -------------------------------------------------------------------------------- /docs/cn/using-electron-packager.md: -------------------------------------------------------------------------------- 1 | # [`electron-packager`](https://github.com/electron-userland/electron-packager) 的使用 2 | 3 | 所有 `electron-packager` 生成的文件都可以在 `build` 文件夹中找到。 4 | 5 | #### 针对所有平台的构建 6 | 7 | 请注意,并非所有操作系统都可以为所有其他平台进行构建。 8 | 9 | ```bash 10 | npm run build 11 | ``` 12 | 13 | #### 针对特定平台的构建 14 | 15 | 平台包括 `darwin`、 `mas`、 `linux` 和 `win32`。 16 | 17 | ```bash 18 | # build for darwin (macOS) 19 | npm run build:darwin 20 | ``` 21 | 22 | #### 清除 23 | 24 | 从 `build` 删除所有的构建文件。 25 | 26 | ```bash 27 | npm run build:clean 28 | ``` 29 | 30 | ### 非 Windows 用户注意事项 31 | 32 | 如果你想在非 Windows 平台上为 Windows 构建时 **使用自定义图标**,你必须安装 [wine](https://www.winehq.org/)。[更多信息](https://github.com/electron-userland/electron-packager#building-windows-apps-from-non-windows-platforms)。 33 | 34 | ### 默认的构建配置 35 | 36 | 可以在 `.electron-vue/build.config.js` 中使用基于 `electron-packager` 的 [各种选项](https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options) 进行进一步定制。你可以设置 `package.json` 里的 `productName` 来设置构建后的程序名称。 37 | 38 | ```js 39 | { 40 | // 针对 'x64' 架构 41 | arch: 'x64', 42 | 43 | // 使用 'electron/asar' 压缩应用 44 | asar: true, 45 | 46 | // 应用程序的目录 47 | dir: path.join(__dirname, '../'), 48 | 49 | // 设置 electron 程序的图标 50 | // 基于平台添加文件的扩展 51 | // 52 | // 如果针对 Linux 进行构建, 请阅读 53 | // https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#icon 54 | icon: path.join(__dirname, '../build/icons/icon'), 55 | 56 | // 忽略可能造成最后程序很大的文件 57 | ignore: /(^\/(src|test|\.[a-z]+|README|yarn|static|dist\/web))|\.gitkeep/, 58 | 59 | // 把构建结果存储到 `builds` 60 | out: path.join(__dirname, '../build'), 61 | 62 | // 重写现有构建 63 | overwrite: true, 64 | 65 | // 指定平台的环境变量 66 | platform: process.env.BUILD_TARGET || 'all' 67 | } 68 | ``` 69 | -------------------------------------------------------------------------------- /docs/en/main-process.md: -------------------------------------------------------------------------------- 1 | # Main Process 2 | 3 | > In Electron, the process that runs package.json’s main script is called the main process. The script that runs in the main process can display a GUI by creating web pages. 4 | 5 | **From the **[**Electron Documentation**](http://electron.atom.io/docs/tutorial/quick-start/#main-process) 6 | 7 | --- 8 | 9 | Since the `main` process is essentially a full node environment, there is no initial project structure other than two files. 10 | 11 | #### `src/main/index.js` 12 | 13 | This file is your application's main file, the file in which `electron` boots with. It is also used as `webpack`'s entry file for production. All `main` process work should start from here. 14 | 15 | #### `app/src/main/index.dev.js` 16 | 17 | This file is used specifically and only for development as it installs `electron-debug` & `vue-devtools`. There shouldn't be any need to modify this file, but it can be used to extend your development needs. 18 | 19 | ## On the subject of using `__dirname` & `__filename` 20 | 21 | Since the `main` process is bundled using `webpack`, the use of `__dirname` & `__filename` **will not** provide an expected value in production. Referring to the [**File Tree**](/file-tree.md), you'll notice that in production the `main.js` is placed inside the `dist/electron` folder. Based on this knowledge, use `__dirname` & `__filename` accordingly. 22 | 23 | **If you are in need of a path to your `static/` assets directory, make sure to read up on **[**Using Static Assets**](/using-static-assets.md)** to learn about the super handy `__static` variable.** 24 | 25 | ``` 26 | app.asar 27 | ├─ dist 28 | │ └─ electron 29 | │ ├─ static/ 30 | │ ├─ index.html 31 | │ ├─ main.js 32 | │ └─ renderer.js 33 | ├─ node_modules/ 34 | └─ package.json 35 | ``` 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/en/savingreading-local-files.md: -------------------------------------------------------------------------------- 1 | # Read & Write Local Files 2 | 3 | One great benefit of using `electron` is the ability to access the user's file system. This enables you to read and write files on the local system. To help avoid Chromium restrictions and writing to your application's internal files, make sure to take use of `electron`'s APIs, specifically the [`app.getPath(name)`](https://electron.atom.io/docs/api/app/#appgetpathname) function. This helper method can get you file paths to system directories such as the user's desktop, system temporary files, etc. 4 | 5 | ### Use Case 6 | 7 | Let's say we want to have a local database store for our application. In this example we'll demonstrate with [`nedb`](https://github.com/louischatriot/nedb). 8 | 9 | ```bash 10 | yarn add nedb # or npm install nedb --save 11 | ``` 12 | 13 | **src/renderer/datastore.js** 14 | 15 | Here we setup NeDB and point it to our `userData` directory. This space is reserved specifically for our application, so we can have confidence other programs or other user interactions should not tamper with this file space. From here we can import `datastore.js` in our `renderer` process and consume it. 16 | 17 | ```js 18 | import Datastore from 'nedb' 19 | import path from 'path' 20 | import { remote } from 'electron' 21 | 22 | export default new Datastore({ 23 | autoload: true, 24 | filename: path.join(remote.app.getPath('userData'), '/data.db') 25 | }) 26 | ``` 27 | 28 | **src/renderer/main.js** 29 | 30 | To take this a step further, we can then import our datastore into `src/renderer/main.js` and attach it to the Vue prototype. Doing so, we are now able to access the datastore API through the usage of `this.$db` in all component files. 31 | 32 | ```js 33 | import db from './datastore' 34 | 35 | /* Other Code */ 36 | 37 | Vue.prototype.$db = db 38 | ``` 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /docs/cn/using-static-assets.md: -------------------------------------------------------------------------------- 1 | # 静态资源的使用 2 | 3 | 如果你以前使用过官方的 `vuejs-templates/webpack` 样板,那么你应该对 `static/` 目录很熟悉。这里面,你可以放置可供 `main` 和 `renderer` 进程使用的静态资源。在 Vue 应用程序中使用这些资源很简单,但是使用 `fs` 和其他需要完整路径的模块可能会有点棘手。 幸运的是,electron-vue 提供了一个 `__static` 变量,它可以在开发和产品阶段生成 `static/` 目录的路径。 4 | 5 | ### Vue 组件里 `src` 标签的使用案例 6 | 7 | 假设我有一个组件需要下载一个图像,但是直到一些其他任务完成后这个图像的地址才能知道。简单起见,让我们用一个 `data` 变量来绑定图像的来源。 8 | 9 | **SomeComponent.vue** 10 | 11 | ```html 12 | 15 | 16 | 24 | ``` 25 | 26 | 此处,`webpack` 并不会捆绑图像 `unsplash.png`,并且应用程序可以看到 `static/imgs/unsplash.png` 目录里的资源。感谢 `vue-loader` 为我们完成了所有繁琐的工作。 27 | 28 | ### JS 搭配 `fs`、`path` 和 `__static` 的使用案例 29 | 30 | 假设我们有一个静态资源,我们需要使用 `fs` 将它读入到我们的应用程序中,但是我们如何在开发和产品阶段为 `static/` 目录获得可靠的路径呢?electron-vue 提供了一个名为 `__static` 的全局变量,它将产生一个指向 `static/` 目录的正确路径。以下是我们在开发和产品阶段如何使用它读取一个简单的文本文件。 31 | 32 | **static/someFile.txt** 33 | 34 | ```txt 35 | foobar 36 | ``` 37 | 38 | **SomeFile.js \(** `main` **或** `renderer` **进程\)** 39 | 40 | ```js 41 | import fs from 'fs' 42 | import path from 'path' 43 | 44 | let fileContents = fs.readFileSync(path.join(__static, '/someFile.txt'), 'utf8') 45 | 46 | console.log(fileContents) 47 | // => "foobar" 48 | ``` 49 | 50 | 请注意,在产品阶段,默认情况下,所有文件都包含 [`asar`](https://github.com/electron/asar),因为它是被极力推荐的。因此,`static/` 文件夹中的资源只能在 `electron` 内部访问,因为只有 `electron` 了解此行为。由此,如果你打算将文件分发给用户,例如在外部程序中打开文件,那么,首先你需要将这些资源从应用程序复制到用户的文档空间或桌面中。从那里,你可以使用 electron 的 API [`shell.openItem()`](https://electron.atom.io/docs/api/shell/#shellopenitemfullpath) 来打开这些资源。 51 | 52 | 这种情况的一种替代方法,是配置 `electron-packager` 或 `electron-builder`,设置特定文件,用来 “解压缩” 在产品阶段的 `asar` 存档。electron-vue 并没有计划支持这种方法; 任何与此或与如何设定此事项相关的问题将被关闭。 53 | -------------------------------------------------------------------------------- /docs/ja/using-electron-packager.md: -------------------------------------------------------------------------------- 1 | # [`electron-packager`](https://github.com/electron-userland/electron-packager) の使用 2 | 3 | `electron-packager` によって作成された全てのビルドは `build` フォルダ内にあります。 4 | 5 | #### 全てのプラットフォーム用にビルド 6 | 7 | すべてのオペレーティングシステムが他のすべてのプラットフォーム用に構築できるとは限りません。 8 | 9 | ```bash 10 | npm run build 11 | ``` 12 | 13 | #### 特定のプラットフォーム用のビルド 14 | 15 | プラットフォームには `darwin`、 `mas`、 `linux` と `win32` があります。 16 | 17 | ```bash 18 | # darwin 用にビルドする(macOS) 19 | npm run build:darwin 20 | ``` 21 | 22 | #### クリーニング 23 | 24 | `build` から全てのビルドを削除します。 25 | 26 | ```bash 27 | npm run build:clean 28 | ``` 29 | 30 | ### Windows以外のユーザーのためのメモ 31 | 32 | Windows 以外のプラットフォームを使用して**カスタムアイコン付きで** Windows 用にビルドしたい場合、[wine](https://www.winehq.org/) をインストールする必要があります。[詳細な情報はこちら](https://github.com/electron-userland/electron-packager#building-windows-apps-from-non-windows-platforms)。 33 | 34 | ### デフォルトのビルド構成 35 | 36 | [こちら](https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options) に記載のある `electron-packager` のオプションの通りに `.electron-vue/build.config.js` でさらなるカスタマイズが可能です。ビルドされたアプリケーションに適用される名前は `package.json` の `productName` の値が設定されます。 37 | 38 | ```js 39 | { 40 | // 'x64' アーキテクチャを対象にします 41 | arch: 'x64', 42 | // 'electron/asar' を使用してアプリケーションを圧縮します 43 | asar: true, 44 | // アプリケーションのディレクトリ 45 | dir: path.join(__dirname, '../'), 46 | // electron のアプリケーションアイコンを設定します 47 | // ファイル拡張子はプラットフォームに基づいて追加されます 48 | // 49 | // Linux 用にビルドする場合、以下を参照してください 50 | // https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#icon 51 | icon: path.join(__dirname, '../build/icons/icon'), 52 | // 最終的なビルドサイズを膨らませるファイルを無視する 53 | ignore: /(^\/(src|test|\.[a-z]+|README|yarn|static|dist\/web))|\.gitkeep/, 54 | // ビルドファイルを `builds` に保存する 55 | out: path.join(__dirname, '../build'), 56 | // ビルドファイルを上書きする 57 | overwrite: true, 58 | // プラットフォームを設定する環境変数 59 | platform: process.env.BUILD_TARGET || 'all' 60 | } 61 | ``` 62 | -------------------------------------------------------------------------------- /template/src/main/index.js: -------------------------------------------------------------------------------- 1 | {{#if_eq eslintConfig 'standard'}} 2 | 'use strict' 3 | 4 | {{/if_eq}} 5 | import { app, BrowserWindow } from 'electron'{{#if_eq eslintConfig 'airbnb'}} // eslint-disable-line{{/if_eq}} 6 | 7 | /** 8 | * Set `__static` path to static files in production 9 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html 10 | */ 11 | if (process.env.NODE_ENV !== 'development') { 12 | global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\'){{#if_eq eslintConfig 'airbnb'}} // eslint-disable-line{{/if_eq}} 13 | } 14 | 15 | let mainWindow 16 | const winURL = process.env.NODE_ENV === 'development' 17 | ? `http://localhost:9080` 18 | : `file://${__dirname}/index.html` 19 | 20 | function createWindow () { 21 | /** 22 | * Initial window options 23 | */ 24 | mainWindow = new BrowserWindow({ 25 | height: 563, 26 | useContentSize: true, 27 | width: 1000 28 | }) 29 | 30 | mainWindow.loadURL(winURL) 31 | 32 | mainWindow.on('closed', () => { 33 | mainWindow = null 34 | }) 35 | } 36 | 37 | app.on('ready', createWindow) 38 | 39 | app.on('window-all-closed', () => { 40 | if (process.platform !== 'darwin') { 41 | app.quit() 42 | } 43 | }) 44 | 45 | app.on('activate', () => { 46 | if (mainWindow === null) { 47 | createWindow() 48 | } 49 | }) 50 | {{#if_eq builder 'builder'}} 51 | 52 | /** 53 | * Auto Updater 54 | * 55 | * Uncomment the following code below and install `electron-updater` to 56 | * support auto updating. Code Signing with a valid certificate is required. 57 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-electron-builder.html#auto-updating 58 | */ 59 | 60 | /* 61 | import { autoUpdater } from 'electron-updater' 62 | 63 | autoUpdater.on('update-downloaded', () => { 64 | autoUpdater.quitAndInstall() 65 | }) 66 | 67 | app.on('ready', () => { 68 | if (process.env.NODE_ENV === 'production') autoUpdater.checkForUpdates() 69 | }) 70 | */ 71 | {{/if_eq}} 72 | -------------------------------------------------------------------------------- /docs/cn/renderer-process.md: -------------------------------------------------------------------------------- 1 | # 渲染器进程 2 | 3 | > 由于 Electron 使用 Chromium 显示网页,那么,Chromium 的多进程架构也被使用。Electron 中的每个网页都在自己的进程中运行,称为渲染器进程 (renderer process)。 4 | > 5 | > 在正常的浏览器中,网页通常运行在沙盒封装化的环境中,并且不允许访问本机资源。然而,Electron 用户有权在网页中使用 Node.js 的 API,从而允许较低级别的操作系统交互。 6 | 7 | **选自** [**Electron 文档**](http://electron.atom.io/docs/tutorial/quick-start/#renderer-process) 8 | 9 | --- 10 | 11 | ## 关于 `vue` 和 `vuex` 12 | 13 | ### vue 组件 14 | 15 | 如果你不熟悉 Vue 组件,请阅读 [此处](http://vuejs.org/v2/guide/single-file-components.html)。组件的使用使我们大型、复杂的应用程序更加有组织化。每个组件都有能力封装自己的 CSS、模板 和 JavaScript 的功能。 16 | 17 | 组件存放在 `src/renderer/components` 里。创建子组件时,一个常用的组织化实践是将它们放置在一个使用其父组件名称的新文件夹中。在协调不同的路由时,这一点特别有用。 18 | 19 | ``` 20 | src/renderer/components 21 | ├─ ParentComponentA 22 | │ ├─ ChildComponentA.vue 23 | │ └─ ChildComponentB.vue 24 | └─ ParentComponentA.vue 25 | ``` 26 | 27 | ### vue 路由 28 | 29 | 有关 `vue-router` 的更多信息请点击 [这里](https://github.com/vuejs/vue-router)。 简而言之,我们鼓励使用 `vue-router`,因为创建 单页应用程序 (Single Page Application) 在制作 electron 程序的时候更加实用。你真的想管理一堆 BrowserWindows,然后在其之间传达信息吗?恐怕不会。 30 | 31 | 路由被保存在 `src/renderer/router/index.js` 里并定义如下... 32 | 33 | ```js 34 | { 35 | path: '', 36 | name: '', 37 | component: require('@/components/View') 38 | } 39 | ``` 40 | 41 | ... 其中 `` 和 `` 都是变量。然后,这些路由使用 `src/renderer/App.vue` 的 `` 指令附加到组件树上。 42 | 43 | ##### 注意 44 | 45 | 在使用 `vue-router` 时,不要使用 [**HTML5 历史模式**](http://router.vuejs.org/en/essentials/history-mode.html)。 此模式严格用于通过 `http` 协议提供文件,并且不能正常使用 `file` 协议,但是 electron 在产品构建中使用此协议提供文件。默认的 `hash` 模式正是我们所需要的。 46 | 47 | ### vuex 模块 48 | 49 | 描述 `vuex` 并不是简单的事情,所以请阅读 [这里](http://vuex.vuejs.org/en/intro.html),以便更好地了解它试图解决的问题及其工作原理。 50 | 51 | electron-vue 利用 `vuex` 的模块结构创建多个数据存储,并保存在 `src/renderer/store/modules` 中。 52 | 53 | 拥有多个数据存储对于组织化来说可能很好,但你必须导入每一个数据,这也可能令人厌烦。但是不要担心,因为 `src/renderer/store/modules/index.js` 对我们来说是麻烦的工作!这个简单的脚本让 `src/renderer/store/index.js` 一次性导入我们所有的模块。如果所有这些都没有,只要知道你可以轻松地复制给定的 `Counter.js` 模块,它将以 "神奇" 的方式被加载进来。 54 | -------------------------------------------------------------------------------- /docs/en/project_structure.md: -------------------------------------------------------------------------------- 1 | # Project Structure 2 | 3 | When it comes to making electron apps, project structure is a little different. If you have used the official [`vuejs-templates/webpack`](https://github.com/vuejs-templates/webpack) setup before, then the structure should feel quite familiar. The documentation in this section attempts to explain a general overview of how the boilerplate works and the differences when your application is built. 4 | 5 | ### Single `package.json` Setup 6 | 7 | There was a time not too long ago where a two `package.json` setup was neccessary, but thanks to efforts from [@electron-userland](https://github.com/electron-userland), both [`electron-packager`](https://github.com/electron-userland/electron-packager) and [`electron-builder`](https://github.com/electron-userland/electron-builder) now fully support a single `package.json` setup. 8 | 9 | #### `dependencies` 10 | 11 | These dependencies **will** be included in your final production app. So if your application needs a certain module to function, then install it here! 12 | 13 | #### `devDependencies` 14 | 15 | These dependencies **will not** be included in your final production app. Here you can install modules needed specifically for development like build scripts, `webpack` loaders, etc. 16 | 17 | #### Installing Native NPM Modules 18 | 19 | We need to make sure our native npm modules are built against electron. To do that, we can use [`electron-rebuild`](https://github.com/electron/electron-rebuild), but to make things simpler, it is highly recommended to use [`electron-builder`](https://github.com/electron-userland/electron-builder) for your build tool as a lot of these tasks are handled for you. 20 | 21 | ### On the subject of the `main` process 22 | 23 | During development you may notice `src/main/index.dev.js`. This file is used specifically for development and is used to install dev-tools. This file should not have to be modified, but can be used to extend your development needs. Upon building, `webpack` will step in and create a bundle with `src/main/index.js` as its entry file. 24 | -------------------------------------------------------------------------------- /docs/cn/using_pre-processors.md: -------------------------------------------------------------------------------- 1 | # 预处理器的使用 2 | 3 | 将 [`vue-loader`](https://github.com/vuejs/vue-loader) 与 [`webpack`](https://github.com/webpack/webpack) 一起使用的好处之一是能够直接在你的 Vue 组件文件中预处理你的 HTML/CSS/JS,而无需其他工作。请查询 [**这里**](https://vuejs.org/v2/guide/single-file-components.html) 相关的详细信息。 4 | 5 | ## 使用案例 6 | 7 | 假设我们需要使用 Sass/SCSS 来预处理我们的 CSS。首先,我们需要安装正确的 `webpack` 加载器来处理这种语法。 8 | 9 | #### 安装 `sass-loader` 10 | 11 | ```bash 12 | npm install --save-dev sass-loader node-sass 13 | ``` 14 | 15 | 一旦安装了我们需要的加载器,一切就都差不多完成了。`vue-loader` 将神奇地做好其余的工作。现在我们可以轻松地将 `lang="sass"` 或 `lang="scss"` 添加到我们的 Vue 组件文件中。注意,我们还安装了 `node-sass`,因为它是 `sass-loader` 的依赖包。 16 | 17 | #### 应用 `lang` 属性 18 | 19 | 所以... 20 | 21 | ```html 22 | 27 | ``` 28 | 29 | ... 现在变成了 ... 30 | 31 | ```html 32 | 37 | ``` 38 | 39 | 相同的原理适用于任何其他预处理器。那么,也许你的 JS 需要 coffeescript?只需安装 [coffeescript-loader](https://github.com/webpack/coffee-loader),并将属性 `lang=“coffeescript”` 应用到你的 ` 37 | 38 | 39 | ``` 40 | 41 | ### On the subject of using CDNs 42 | 43 | Although the benefits of using assets served from a CDN can be great for your application's final build size, I would advised against using them. The main reason being is that by doing so you are assuming the application always has access to the internet, which is not always the case for Electron apps. This becomes a rather major issue with CSS frameworks like bootstrap, as your app will quickly become an un-styled mess. 44 | 45 | > "I don't care, I still want to use a CDN" 46 | 47 | If you are determined to still use a CDN, then you can still do so by adding the tags to your `src/index.ejs` file. Just make sure to set up proper UI/UX flows for when you app is offline. 48 | 49 | -------------------------------------------------------------------------------- /docs/ja/using-static-assets.md: -------------------------------------------------------------------------------- 1 | # 静的アセットの使用 2 | 3 | もし以前に `vuejs-templates/webpack` ボイラープレートを使用したことがある場合、 `static/` ディレクトリに詳しいでしょう。ここは `main` プロセスや `renderer` プロセスが使用する静的アセットを配置する場所です。 これらのアセットを Vue アプリケーション内で使用するのは簡単ですが、フルパスを必要とする `fs` や他のモジュールで使用するのには少し難解です。幸いなことに、electron-vue は開発と本番で `static/` ディレクトリまでのパスを返却する `__static` 変数を提供しています。 4 | 5 | ### Vue コンポーネント内で `src` タグを使用する場合 6 | 7 | 画像を読み込むコンポーネントがありますが、他のタスクが完了するまで画像のパスが分からないとします。物事を簡単にするために、 `` の src をバインドするために、 `data` 変数を使用しましょう。 8 | 9 | **SomeComponent.vue** 10 | 11 | ```html 12 | 15 | 23 | ``` 24 | 25 | `webpack` は `unsplash.png` をバンドルしません。アプリケーションは `static/imgs/unsplash.png` ディレクトリ内を調べます。`vue-loader` のおかげで、全てのめんどくさいことを代わりにやってくれます。 26 | 27 | ### JS で `fs`、`path`、`__static` を使用する場合 28 | 29 | `fs` を使用してアプリケーションに読み込む必要のある静的アセットがある場合、開発と本番の両方で `static/` ディレクトリまでの信頼できるパスを取得するにはどのようにすれば良いでしょうか?electron-vue は `static/` ディレクトリまでの適切なパスを返却する `__static` という名前のグローバル変数を提供しています。ここでは、開発と本番の両方で簡単なテキストファイルを読むためにそれを使う方法を示します。 30 | 31 | **static/someFile.txt** 32 | 33 | ```txt 34 | foobar 35 | ``` 36 | 37 | **SomeFile.js (**`main`** プロセスもしくは **`renderer`** プロセス)** 38 | 39 | ```js 40 | import fs from 'fs' 41 | import path from 'path' 42 | let fileContents = fs.readFileSync(path.join(__static, '/someFile.txt'), 'utf8') 43 | console.log(fileContents) 44 | // => "foobar" 45 | ``` 46 | 47 | 本番では全てのファイルが強く推奨されている通り、デフォルトで [`asar`](https://github.com/electron/asar) でパッケージングされていることに注意してください。このため、この挙動を認識しているので、`static/` フォルダ内のアセットは `electron` 内でのみアクセスできます。例えば外部プログラムで開けるようにユーザにファイルを配布したい場合、これらのアプリケーションのアセットをユーザのドキュメントスペースまたはデスクトップにコピーする必要があります。そこからそれらのアセットを開くために [`shell.openItem()`](https://electron.atom.io/docs/api/shell/#shellopenitemfullpath) という electron API を使用することができます。 48 | 49 | この状況の別の解決策は特定のファイルを本番の `asar` アーカイブから "解凍" するように `electron-packager`/`electron-builder` を構成することです。electron-vue はこの方法をサポートする予定はありません。これに関連する課題、または設定方法に関する課題は終了します。 50 | -------------------------------------------------------------------------------- /template/src/renderer/components/LandingPage/SystemInformation.vue: -------------------------------------------------------------------------------- 1 | 34 | 35 | 53 | 54 | 80 | -------------------------------------------------------------------------------- /docs/en/debugging-production.md: -------------------------------------------------------------------------------- 1 | # Debugging 2 | 3 | ### Main Process 4 | 5 | When running your application in development you may have noticed a message from the `main` process mentioning a remote debugger. Ever since the release of `electron@^1.7.2`, remote debugging over the Inspect API was introduced and can be easily accessed by opening the provided link with Google Chrome or through another debugger that can remotely attach to the process using the default port of 5858, such as Visual Studio Code. 6 | 7 | ```bash 8 | ┏ Electron ------------------- 9 | 10 | Debugger listening on port 5858. 11 | Warning: This is an experimental feature and could change at any time. 12 | To start debugging, open the following URL in Chrome: 13 | chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:5858/22271e96-df65-4bab-9207-da8c71117641 14 | 15 | ┗ ---------------------------- 16 | ``` 17 | 18 | ### Production Builds 19 | 20 | ###### Notice 21 | 22 | Although it is possible to debug your application in production, please do know that production code is minified and highly unreadable compared to what you find during development. 23 | 24 | ##### `renderer` Process 25 | 26 | There isn't much of a big difference here than it is in development. You can simply invoke the dev tools using the [`BrowserWindow` APIs](https://electron.atom.io/docs/api/web-contents/#contentsopendevtoolsoptions). Using the initial electron-vue setup, you can add the following snippet of code inside `src/main/index.js` , just after the `new BrowserWindow` construction, to force the dev tools to open on launch. 27 | 28 | ```js 29 | mainWindow.webContents.openDevTools() 30 | ``` 31 | 32 | ##### `main` Process 33 | 34 | Similar to what is mentioned above, you can also attach an external debugger to the `main` process to remotely debug your application. In order to activate the debugger in production you can add the follow snippet after the `app` import inside `src/main/index.js`. Then you can navigate Google Chrome to `chrome://inspect` and get connected. 35 | 36 | ```js 37 | app.commandLine.appendSwitch('inspect', '5858') 38 | ``` 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /template/.electron-vue/webpack.main.config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | process.env.BABEL_ENV = 'main' 4 | 5 | const path = require('path') 6 | const { dependencies } = require('../package.json') 7 | const webpack = require('webpack') 8 | 9 | const BabiliWebpackPlugin = require('babili-webpack-plugin') 10 | 11 | let mainConfig = { 12 | entry: { 13 | main: path.join(__dirname, '../src/main/index.js') 14 | }, 15 | externals: [ 16 | ...Object.keys(dependencies || {}) 17 | ], 18 | module: { 19 | rules: [ 20 | {{#if eslint}} 21 | { 22 | test: /\.(js)$/, 23 | enforce: 'pre', 24 | exclude: /node_modules/, 25 | use: { 26 | loader: 'eslint-loader', 27 | options: { 28 | formatter: require('eslint-friendly-formatter') 29 | } 30 | } 31 | }, 32 | {{/if}} 33 | { 34 | test: /\.js$/, 35 | use: 'babel-loader', 36 | exclude: /node_modules/ 37 | }, 38 | { 39 | test: /\.node$/, 40 | use: 'node-loader' 41 | } 42 | ] 43 | }, 44 | node: { 45 | __dirname: process.env.NODE_ENV !== 'production', 46 | __filename: process.env.NODE_ENV !== 'production' 47 | }, 48 | output: { 49 | filename: '[name].js', 50 | libraryTarget: 'commonjs2', 51 | path: path.join(__dirname, '../dist/electron') 52 | }, 53 | plugins: [ 54 | new webpack.NoEmitOnErrorsPlugin() 55 | ], 56 | resolve: { 57 | extensions: ['.js', '.json', '.node'] 58 | }, 59 | target: 'electron-main' 60 | } 61 | 62 | /** 63 | * Adjust mainConfig for development settings 64 | */ 65 | if (process.env.NODE_ENV !== 'production') { 66 | mainConfig.plugins.push( 67 | new webpack.DefinePlugin({ 68 | '__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"` 69 | }) 70 | ) 71 | } 72 | 73 | /** 74 | * Adjust mainConfig for production settings 75 | */ 76 | if (process.env.NODE_ENV === 'production') { 77 | mainConfig.plugins.push( 78 | new BabiliWebpackPlugin(), 79 | new webpack.DefinePlugin({ 80 | 'process.env.NODE_ENV': '"production"' 81 | }) 82 | ) 83 | } 84 | 85 | module.exports = mainConfig 86 | -------------------------------------------------------------------------------- /docs/en/end-to-end_testing.md: -------------------------------------------------------------------------------- 1 | # End-to-End Testing 2 | 3 | electron-vue makes use of [Spectron](http://electron.atom.io/spectron/) and the [Mocha](https://mochajs.org/) \(with [Chai](http://chaijs.com/)\) test framework for end-to-end testing. Mocha & Chai APIs, including `expect`, `should`, and `assert`, are made available in global scope. 4 | 5 | ### Running tests 6 | 7 | ```bash 8 | # Begin Mocha 9 | npm run e2e 10 | ``` 11 | 12 | ##### Note 13 | 14 | Before running end-to-end tests, a `npm run pack` is called to create a production build that Spectron can consume during tests. 15 | 16 | ### File Structure 17 | 18 | ``` 19 | my-project 20 | ├─ test 21 | | ├─ e2e 22 | │ │ ├─ specs/ 23 | │ │ ├─ index.js 24 | └─ └─ └─ utils.js 25 | ``` 26 | 27 | **For the most part, you can ignore **`index.js`** and focus solely on writing **`specs/`**.** 28 | 29 | #### `specs/` 30 | 31 | Inside this directory is where actual tests are written. Thanks to the power of `babel-register`, you have full access to ES2015. 32 | 33 | #### `index.js` 34 | 35 | This file acts as the main entry to Mocha and gathers all tests written in `specs/` for testing. 36 | 37 | #### `utils.js` 38 | 39 | Here you will find generic functions that could be of use throughout your `specs/`. Base functions include a `beforeEach` and `afterEach` that handle the electron creation/destruction process. 40 | 41 | ### On the subject of Spectron 42 | 43 | Spectron is the official [electron](http://electron.atom.io) testing framework that uses both [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/) and [WebDriverIO](http://webdriver.io/) for manipulating DOM elements. 44 | 45 | #### Using WebDriverIO 46 | 47 | As stated in the Spectron [documentation](https://github.com/electron/spectron#client), access to [WebDriverIO APIs](http://webdriver.io/api.html) can be accessed through `this.app.client`. Since electron-vue uses Mocha, the context of `this` is shared between `afterEach`, `beforeEach`, and `it`. Because of this, it is important to note that ES2015 arrow functions cannot not be used in certain situations as the context of `this` will be overwritten \([more info](https://mochajs.org/#arrow-functions)\). 48 | 49 | -------------------------------------------------------------------------------- /docs/cn/faqs.md: -------------------------------------------------------------------------------- 1 | # 常见问题 2 | 3 | * [为什么运行 `npm run dev` 之后我的 electron 应用程序是空白的?](#why-is-my-electron-app-blank-after-running-npm-run-dev) 4 | * [为什么我的 electron 程序显示了文件浏览器?](#why-does-my-electron-app-show-a-file-explorer) 5 | * [为什么没有 `vue-devtools` 或 `devtron`?](#why-is-vue-devtoolsdevtron-missing) 6 | * [在哪里放置我的静态资源?](#where-do-i-put-static-assets) 7 | * [为什么 `npm run lint` 会出现错误?](#why-did-npm-run-lint-end-with-an-error) 8 | * [为什么我无法在网页浏览器中加载应用程序?](#why-cant-i-load-my-app-in-a-web-browser) 9 | * [如何导入 `jquery`?](#how-do-import-jquery) 10 | * [如何调试 `main` 进程?](#how-can-i-debug-the-main-process) 11 | 12 | --- 13 | 14 | ## 为什么运行 `npm run dev` 之后我的 electron 程序是空白的? 15 | 16 | #### 简要 17 | 18 | 请确认你没有设置可能篡改 `webpack-dev-server` 的个人 **代理**。 19 | 20 | ## 为什么我的 electron 程序显示了文件浏览器? 21 | 22 | #### 简要 23 | 24 | 你的 `src/renderer` 包含错误。请检查 控制台 (console),修复错误,然后用 `CommandOrControl+R` 刷新 electron。 25 | 26 | ##### 详述 27 | 28 | 如果你的 `src/renderer` 中出现错误,则会在首次运行时与 ESLint 产生冲突。接着,一个无效的 webpack 的 `renderer.js` 会被生成出来,它会打断 `HtmlWebpackPlugin` 创建 `index.html`。由于 `webpack-dev-server` 没有 `index.html` 可以提供服务,所以服务器失败,程序返回到文件浏览器。 29 | 30 | ## 为什么没有 `vue-devtools` 或 `devtron`? 31 | 32 | 如果缺少 `vue-devtools` 或 `devtron`,请确保首次启动时,关闭并重新打开开发者工具面板。另外,请检查你的终端,检查是否在安装过程中有任何可能的错误消息。 33 | 34 | ## 在哪里放置我的静态资源? 35 | 36 | [**静态资源的使用**](/using-static-assets.md) 37 | 38 | ## 为什么 `npm run lint` 会出现错误? 39 | 40 | eslint 的默认属性是将控制台的错误打印出来,如果发现脚本以非零值退出结束时 \(它会产生 npm 错误\)。这是正常的行为。 41 | 42 | ## 为什么我无法在网页浏览器中加载应用程序? 43 | 44 | [\#195](https://github.com/SimulatedGREG/electron-vue/issues/195) 45 | 46 | ## 如何导入 `jquery`? 47 | 48 | 如果你想使用 `bootstrap`,我将不得不在此打住你。在同一环境中使用 `vue` 和 `jquery` 并不是一个好的做法,这导致两个框架的相互冲突。我强烈建议使用一个 `bootstrap` 的替代方法,并使用 `vue` 提供的 JavaScript 的功能。一些建议包括使用 [`bootstrap-vue`](https://github.com/bootstrap-vue/bootstrap-vue) 和 [`vue-strap`](https://github.com/yuche/vue-strap)。若有任何原因使你必须使用 `jquery`,记得从 `webpack` 的文档里寻求有关 `ProvidePlugin` 的指导,或者参见 [\#192](https://github.com/SimulatedGREG/electron-vue/issues/192)。 49 | 50 | ## 如何调试 `main` 进程? 51 | 52 | 当使用 `electron@^1.7.2` 时,你可以打开 Goog​​le Chrome,然后转到 `chrome://inspect`,在应用程序以开发模式运行时,弹出远程的 electron 进程。 53 | 54 | [Electron 文档](https://github.com/electron/electron/blob/master/docs/tutorial/debugging-main-process.md) 55 | -------------------------------------------------------------------------------- /docs/ja/using_pre-processors.md: -------------------------------------------------------------------------------- 1 | # プリプロセッサの使用 2 | 3 | [`webpack`](https://github.com/webpack/webpack) で [`vue-loader`](https://github.com/vuejs/vue-loader) を使用することの大きな利点の一つは、特に努力せずに Vue コンポーネントファイル内で HTML/CSS/JS を直接前もって処理できることです。詳細は[**こちら**](https://jp.vuejs.org/v2/guide/single-file-components.html)を確認してください。 4 | 5 | ## ユースケース 6 | 7 | CSS の前処理に Sass/SCSS を使う必要があるとします。まず、この構文を処理するために適切な `webpack` ローダーをインストールする必要があります。 8 | 9 | #### `sass-loader` のインストール 10 | 11 | ```bash 12 | npm install --save-dev sass-loader node-sass 13 | ``` 14 | 15 | 必要なローダーがインストールされると、完成です。`vue-loader` は魔法のように残り作業をやってくれます。これで、Vue コンポーネントファイルに `lang="sass"` または `lang="scss"` を簡単に追加できます。 `sass-loader` の依存パッケージであるため、 `node-sass` もインストールしたことに注意してください。 16 | 17 | #### `lang` 属性を適用する 18 | 19 | これを... 20 | 21 | ```html 22 | 27 | ``` 28 | 29 | ...こうします... 30 | 31 | ```html 32 | 37 | ``` 38 | 39 | 他のプリプロセッサにも同じ原則が適用されます。JS に coffeescript が必要かもしれませんね?[coffeescript-loader](https://github.com/webpack/coffee-loader) をインストールして、 ` 24 | ``` 25 | 26 | Here `webpack` will not bundle the `unsplash.png` image and the application will look inside the `static/imgs/unsplash.png` directory for the asset. Thanks to `vue-loader`, all of the dirty work is done for us. 27 | 28 | ### Use Case within JS with `fs`,`path` and `__static` 29 | 30 | Let's say we have a static asset that we need to read into our application using `fs`, but how do we get a reliable path, in both development and production, to the `static/` directory? electron-vue provides a global variable named `__static` that will yield a proper path to the `static/` directory. Here's how we can use it to read a simple text file in both development and production. 31 | 32 | **static/someFile.txt** 33 | 34 | ```txt 35 | foobar 36 | ``` 37 | 38 | **SomeFile.js \(**`main`** or **`renderer`** process\)** 39 | 40 | ```js 41 | import fs from 'fs' 42 | import path from 'path' 43 | 44 | let fileContents = fs.readFileSync(path.join(__static, '/someFile.txt'), 'utf8') 45 | 46 | console.log(fileContents) 47 | // => "foobar" 48 | ``` 49 | 50 | Please note that in production all files are packed with [`asar`](https://github.com/electron/asar) by default as it is highly recommended. Because of this, assets within the `static/` folder can only be accessed within `electron` since it is aware of this behavior. So if you are planning to distribute files to your users, that can for example open in a external program, you would first need to copy those assets from your application into the user's document space or desktop. From there you could use the [`shell.openItem()`](https://electron.atom.io/docs/api/shell/#shellopenitemfullpath) electron API to open those assets. 51 | 52 | An alternative method to this situation would be to configure `electron-packager`/`electron-builder` to set specific files to "unpack" from the `asar` archive in production. electron-vue has no plans to support this method; any issues related to this or how to set this up will be closed. 53 | 54 | -------------------------------------------------------------------------------- /docs/en/faqs.md: -------------------------------------------------------------------------------- 1 | # FAQs 2 | 3 | * [Why is my electron app blank after running `npm run dev`?](#why-is-my-electron-app-blank-after-running-npm-run-dev) 4 | * [Why does my electron app show a file explorer?](#why-does-my-electron-app-show-a-file-explorer) 5 | * [Why is `vue-devtools`/`devtron` missing?](#why-is-vue-devtoolsdevtron-missing) 6 | * [Where do I put Static Assets?](#where-do-i-put-static-assets) 7 | * [Why did `npm run lint` end with an error?](#why-did-npm-run-lint-end-with-an-error) 8 | * [Why can't I load my app in a web browser?](#why-cant-i-load-my-app-in-a-web-browser) 9 | * [How do I import `jquery`?](#how-do-import-jquery) 10 | * [How can I debug the `main` process?](#how-can-i-debug-the-main-process) 11 | 12 | --- 13 | 14 | ## Why is my electron app blank after running `npm run dev`? 15 | 16 | #### TL;DR 17 | 18 | Make sure you don't have a personal **proxy** setup that could tamper with `webpack-dev-server`. 19 | 20 | ## Why does my electron app show a file explorer? 21 | 22 | #### TL;DR 23 | 24 | Your `src/renderer` contains error\(s\). Check console, fix errors, then refresh electron with `CommandOrControl+R`. 25 | 26 | ##### Long answer 27 | 28 | If error\(s\) are present in you `src/renderer` this creates conflicts with ESLint on first run. In turn, an INVALID webpack `renderer.js` is produced which interrupts `HtmlWebpackPlugin` from creating `index.html`. Since `webpack-dev-server` doesn't have the `index.html` ready to serve, the server falls back to the file explorer. 29 | 30 | ## Why is `vue-devtools`/`devtron` missing? 31 | 32 | Make sure to close and reopen the developer tools panel on first launch if they are missing. Also check your terminal check for any error messages that may occur during installation. 33 | 34 | ## Where do I put Static Assets? 35 | 36 | [**Using Static Assets**](/using-static-assets.md) 37 | 38 | ## Why did `npm run lint` end with an error? 39 | 40 | The default nature of eslint is to print linting errors to console, and if there is any found the script will end with a non-zero exit \(which produces npm errors\). This is normal behavior. 41 | 42 | ## Why can't I load my app in a web browser? 43 | 44 | [\#195](https://github.com/SimulatedGREG/electron-vue/issues/195) 45 | 46 | ## How do import `jquery`? 47 | 48 | If you are wanting to use `bootstrap`, I'm going to have to stop you right there. Using both `vue` and `jquery` in the same environment is a bad practice and leads to the two frameworks colliding with each other. I would highly recommend using a `bootstrap` alternative that uses `vue` for its JavaScript functionality. Some recommendations include [`bootstrap-vue`](https://github.com/bootstrap-vue/bootstrap-vue) and [`vue-strap`](https://github.com/yuche/vue-strap). For whatever reason you must use `jquery`, seek guidance from `webpack`'s documentation about the `ProvidePlugin` or see [\#192](https://github.com/SimulatedGREG/electron-vue/issues/192). 49 | 50 | ## How can I debug the `main` process? 51 | 52 | When using `electron@^1.7.2` you can open up Google Chrome, head to `chrome://inspect`, and then pop open the remote electron process while your application is running in development mode. 53 | 54 | [Electron Documentation](https://github.com/electron/electron/blob/master/docs/tutorial/debugging-main-process.md) 55 | 56 | -------------------------------------------------------------------------------- /docs/ja/using-electron-builder.md: -------------------------------------------------------------------------------- 1 | # [`electron-builder`](https://github.com/electron-userland/electron-builder)の使用  2 | 3 | `electron-builder` によって作成された全てのビルドは `build` ディレクトリ内にあります。 4 | 5 | #### ビルド 6 | 7 | ```bash 8 | npm run build 9 | ``` 10 | 11 | #### 解凍されたディレクトリのビルド 12 | 13 | フルインストーラなしで簡単な実行可能ファイルを作成します。迅速なテストに役立ちます。 14 | 15 | ```bash 16 | npm run build:dir 17 | ``` 18 | 19 | ### デフォルトのビルド構成 20 | 21 | [こちら](https://github.com/electron-userland/electron-builder/wiki/Options)にある `electron-builders` のオプションに従って、`package.json` でさらにカスタマイズすることができます。 22 | 23 | ```js 24 | "build": { 25 | "productName": "ElectronVue", 26 | "appId": "org.simulatedgreg.electron-vue", 27 | "dmg": { 28 | "contents": [ 29 | { 30 | "x": 410, 31 | "y": 150, 32 | "type": "link", 33 | "path": "/Applications" 34 | }, 35 | { 36 | "x": 130, 37 | "y": 150, 38 | "type": "file" 39 | } 40 | ] 41 | }, 42 | "directories": { 43 | "output": "build" 44 | }, 45 | "files": [ 46 | "dist/electron", 47 | "node_modules/", 48 | "package.json" 49 | ], 50 | "mac": { 51 | "icon": "build/icons/icon.icns" 52 | }, 53 | "win": { 54 | "icon": "build/icons/icon.ico" 55 | }, 56 | "linux": { 57 | "icon": "build/icons" 58 | } 59 | } 60 | ``` 61 | 62 | ## CI を使用した自動デプロイ 63 | 64 | electron-vue の `electron-builder` 構成を使用する場合、自動デプロイのために `appveyor.yml` と `.travis.yml` も提供されます。両方の設定ファイルは electron アプリケーションのビルドや GitHub リリース、 Bintray などへ生成物をプッシュするために設定されています。Travis CI は `linux` と `darwin` (macOS) の両方のビルドに使用される一方、AppVeyor は `win32` のビルドに使用されます。どちらのサービスも OSS プロジェクトに対しては無料です。 65 | 66 | #### Travis CI/AppVeyor のセットアップ 67 | 68 | 1. [Travis CI](https://travis-ci.org/getting_started) / [AppVeyor](https://www.appveyor.com/) でアカウントを作成します 69 | 2. electron-vue プロジェクトがある GitHub リポジトリにリンクします 70 | 3. [https://github.com/settings/tokens](https://github.com/settings/tokens) にアクセスし、**Generate new token ** を押します(Travis CI と AppVeyor 両方で同じトークンが使用可能です) 71 | 1. **Token description** を設定します 72 | 2. **public_repo ** スコープにチェックをつけます 73 | 3. **Generate token** を押します 74 | 4. 新しいトークンをコピーして後々使うために保存します 75 | 5. Travis CI / AppVeyor でリポジトリ設定を開き、新しい**環境変数**を追加します 76 | 1. 変数の名前を `GH_TOKEN` に設定します 77 | 2. 変数の値を作成したばかりのGitHubアクセストークンに設定します 78 | 3. 新しい変数を**保存**し、暗号化が有効になっていることを確認します 79 | 80 | この時点で、全てがセットアップされました。Travis CI/AppVeyor はデフォルトで `master` ブランチへのプッシュを監視します。プッシュが行われると、Travis CI/AppVeyor はリポジトリをサーバーにクローンし、ビルドプロセスを開始します。最終ステージでは、`electron-builder` は環境変数の `GH_TOKEN` を見て、ドラフトのリリースを作成し、作成物を GitHub のパブリックリポジトリにアップロードします。この時点から、ドラフトのリリースを編集して、それを世界に公開することができます。 リリースを公開した後、`package.json` を更新して、将来のリリースに新しいバージョン番号が付いていることを確認してください。 81 | 82 | #### 自動アップデート 83 | 84 | アプリケーションが自動アップデートを受信できるようにすることは、優れた機能ですが、[**コードサイニング**](https://github.com/electron-userland/electron-builder/wiki/Code-Signing)が必要であることを知ってください。[こちら](https://github.com/electron-userland/electron-builder/wiki/Code-Signing)で説明されている `electron-builder` が必要とするものに基づいて、いくつかの環境変数を追加することでコードサイニングを設定可能です。いったん証明書を設定すると、 `electron-updater` をインストールし、自動アップデートを有効にするために、`src/main/index.js` の一番下のコードをコメントアウトすることができます。 85 | 86 | ほとんどの人と同じように、コード署名証明書がない場合は、GitHub API を使用して新しいリリースをチェックすることができます。新しいリリースが検出されたら、アプリケーション内で、新しいビルドをダウンロードしてインストールできるダウンロードページをユーザーに示す通知を提供します。`electron-builder` が提供する素晴らしいインストーラーのおかげで、ユーザーは現在のバージョンをアンインストールする必要がなくなり、新しいインストールは Web ストレージまたは `userData` ファイルをそのまま維持しながら古いものを置き換えます。 87 | -------------------------------------------------------------------------------- /docs/en/renderer-process.md: -------------------------------------------------------------------------------- 1 | # Renderer Process 2 | 3 | > Since Electron uses Chromium for displaying web pages, Chromium’s multi-process architecture is also used. Each web page in Electron runs in its own process, which is called the renderer process. 4 | > 5 | > In normal browsers, web pages usually run in a sandboxed environment and are not allowed access to native resources. Electron users, however, have the power to use Node.js APIs in web pages allowing lower level operating system interactions. 6 | 7 | **From the **[**Electron Documentation**](http://electron.atom.io/docs/tutorial/quick-start/#renderer-process) 8 | 9 | --- 10 | 11 | ## On the subject of `vue` and `vuex` 12 | 13 | ### vue components 14 | 15 | If you are unfamiliar with Vue components, please give [this](http://vuejs.org/v2/guide/single-file-components.html) a read. Using components gives our large complex applications more organization. Each component has the ability to encapsulate its own CSS, template, and JavaScript functionality. 16 | 17 | Components are stored in `src/renderer/components`. When creating child components, a common organization practice is to place them inside a new folder with the name of its parent component. This is especially useful when coordinating different routes. 18 | 19 | ``` 20 | src/renderer/components 21 | ├─ ParentComponentA 22 | │ ├─ ChildComponentA.vue 23 | │ └─ ChildComponentB.vue 24 | └─ ParentComponentA.vue 25 | ``` 26 | 27 | ### vue routes 28 | 29 | For more information about `vue-router` click [here](https://github.com/vuejs/vue-router). In short, it is encouraged to use `vue-router` as creating a Single Page Application is much more practical when making Electron applications. Do you really want to manage a bunch of BrowserWindows and then communicating information between everything? Probably not. 30 | 31 | Routes are held in `src/renderer/router/index.js` and defined like so... 32 | 33 | ```js 34 | { 35 | path: '', 36 | name: '', 37 | component: require('@/components/View') 38 | } 39 | ``` 40 | 41 | ...where both `` and `` are variables. These routes are then attached to the component tree using the `` directive in `src/renderer/App.vue`. 42 | 43 | ##### Notice 44 | 45 | When using `vue-router`, do not use [**HTML5 History Mode**](http://router.vuejs.org/en/essentials/history-mode.html). This mode is strictly meant for serving files over the `http` protocol and does not work properly with the `file` protocol that Electron serves files with in production builds. The default `hash` mode is just what we need. 46 | 47 | ### vuex modules 48 | 49 | Describing `vuex` is not the easiest thing to do, so please read [this](http://vuex.vuejs.org/en/intro.html) for a better understanding of what problem it tries to solve and how it works. 50 | 51 | electron-vue takes advantage of `vuex`'s module structure to create multiple data stores, which are saved in `src/renderer/store/modules`. 52 | 53 | Having multiple data stores can be great for organization, but it can also be annoying to have to import each and every one. But don't fret, as `src/renderer/store/modules/index.js` does the dirty work for us! This little script lets `src/renderer/store/index.js` import all of our modules in a one-shot manner. If all that didn't make sense, just know you can easily duplicate the given `Counter.js` module and it will be loaded in "magically". 54 | -------------------------------------------------------------------------------- /template/src/renderer/components/LandingPage.vue: -------------------------------------------------------------------------------- 1 | 31 | 32 | 45 | 46 | 129 | -------------------------------------------------------------------------------- /template/.electron-vue/webpack.web.config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | process.env.BABEL_ENV = 'web' 4 | 5 | const path = require('path') 6 | const webpack = require('webpack') 7 | 8 | const BabiliWebpackPlugin = require('babili-webpack-plugin') 9 | const CopyWebpackPlugin = require('copy-webpack-plugin') 10 | const ExtractTextPlugin = require('extract-text-webpack-plugin') 11 | const HtmlWebpackPlugin = require('html-webpack-plugin') 12 | 13 | let webConfig = { 14 | devtool: '#cheap-module-eval-source-map', 15 | entry: { 16 | web: path.join(__dirname, '../src/renderer/main.js') 17 | }, 18 | module: { 19 | rules: [ 20 | {{#if eslint}} 21 | { 22 | test: /\.(js|vue)$/, 23 | enforce: 'pre', 24 | exclude: /node_modules/, 25 | use: { 26 | loader: 'eslint-loader', 27 | options: { 28 | formatter: require('eslint-friendly-formatter') 29 | } 30 | } 31 | }, 32 | {{/if}} 33 | { 34 | test: /\.css$/, 35 | use: ExtractTextPlugin.extract({ 36 | fallback: 'style-loader', 37 | use: 'css-loader' 38 | }) 39 | }, 40 | { 41 | test: /\.html$/, 42 | use: 'vue-html-loader' 43 | }, 44 | { 45 | test: /\.js$/, 46 | use: 'babel-loader', 47 | include: [ path.resolve(__dirname, '../src/renderer') ], 48 | exclude: /node_modules/ 49 | }, 50 | { 51 | test: /\.vue$/, 52 | use: { 53 | loader: 'vue-loader', 54 | options: { 55 | extractCSS: true, 56 | loaders: { 57 | sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1', 58 | scss: 'vue-style-loader!css-loader!sass-loader' 59 | } 60 | } 61 | } 62 | }, 63 | { 64 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 65 | use: { 66 | loader: 'url-loader', 67 | query: { 68 | limit: 10000, 69 | name: 'imgs/[name].[ext]' 70 | } 71 | } 72 | }, 73 | { 74 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 75 | use: { 76 | loader: 'url-loader', 77 | query: { 78 | limit: 10000, 79 | name: 'fonts/[name].[ext]' 80 | } 81 | } 82 | } 83 | ] 84 | }, 85 | plugins: [ 86 | new ExtractTextPlugin('styles.css'), 87 | new HtmlWebpackPlugin({ 88 | filename: 'index.html', 89 | template: path.resolve(__dirname, '../src/index.ejs'), 90 | minify: { 91 | collapseWhitespace: true, 92 | removeAttributeQuotes: true, 93 | removeComments: true 94 | }, 95 | nodeModules: false 96 | }), 97 | new webpack.DefinePlugin({ 98 | 'process.env.IS_WEB': 'true' 99 | }), 100 | new webpack.HotModuleReplacementPlugin(), 101 | new webpack.NoEmitOnErrorsPlugin() 102 | ], 103 | output: { 104 | filename: '[name].js', 105 | path: path.join(__dirname, '../dist/web') 106 | }, 107 | resolve: { 108 | alias: { 109 | '@': path.join(__dirname, '../src/renderer'), 110 | 'vue$': 'vue/dist/vue.esm.js' 111 | }, 112 | extensions: ['.js', '.vue', '.json', '.css'] 113 | }, 114 | target: 'web' 115 | } 116 | 117 | /** 118 | * Adjust webConfig for production settings 119 | */ 120 | if (process.env.NODE_ENV === 'production') { 121 | webConfig.devtool = '' 122 | 123 | webConfig.plugins.push( 124 | new BabiliWebpackPlugin(), 125 | new CopyWebpackPlugin([ 126 | { 127 | from: path.join(__dirname, '../static'), 128 | to: path.join(__dirname, '../dist/web/static'), 129 | ignore: ['.*'] 130 | } 131 | ]), 132 | new webpack.DefinePlugin({ 133 | 'process.env.NODE_ENV': '"production"' 134 | }), 135 | new webpack.LoaderOptionsPlugin({ 136 | minimize: true 137 | }) 138 | ) 139 | } 140 | 141 | module.exports = webConfig 142 | -------------------------------------------------------------------------------- /template/.electron-vue/build.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | process.env.NODE_ENV = 'production' 4 | 5 | const { say } = require('cfonts') 6 | const chalk = require('chalk') 7 | const del = require('del') 8 | {{#if_eq builder 'packager'}} 9 | const packager = require('electron-packager') 10 | {{else}} 11 | const { spawn } = require('child_process') 12 | {{/if_eq}} 13 | const webpack = require('webpack') 14 | const Multispinner = require('multispinner') 15 | 16 | {{#if_eq builder 'packager'}}const buildConfig = require('./build.config'){{/if_eq}} 17 | const mainConfig = require('./webpack.main.config') 18 | const rendererConfig = require('./webpack.renderer.config') 19 | const webConfig = require('./webpack.web.config') 20 | 21 | const doneLog = chalk.bgGreen.white(' DONE ') + ' ' 22 | const errorLog = chalk.bgRed.white(' ERROR ') + ' ' 23 | const okayLog = chalk.bgBlue.white(' OKAY ') + ' ' 24 | const isCI = process.env.CI || false 25 | 26 | if (process.env.BUILD_TARGET === 'clean') clean() 27 | else if (process.env.BUILD_TARGET === 'web') web() 28 | else build() 29 | 30 | function clean () { 31 | del.sync(['build/*', '!build/icons', '!build/icons/icon.*']) 32 | console.log(`\n${doneLog}\n`) 33 | process.exit() 34 | } 35 | 36 | function build () { 37 | greeting() 38 | 39 | del.sync(['dist/electron/*', '!.gitkeep']) 40 | 41 | const tasks = ['main', 'renderer'] 42 | const m = new Multispinner(tasks, { 43 | preText: 'building', 44 | postText: 'process' 45 | }) 46 | 47 | let results = '' 48 | 49 | m.on('success', () => { 50 | process.stdout.write('\x1B[2J\x1B[0f') 51 | console.log(`\n\n${results}`) 52 | console.log(`${okayLog}take it away ${chalk.yellow('`electron-{{builder}}`')}\n`) 53 | {{#if_eq builder 'packager'}}bundleApp(){{else}}process.exit(){{/if_eq}} 54 | }) 55 | 56 | pack(mainConfig).then(result => { 57 | results += result + '\n\n' 58 | m.success('main') 59 | }).catch(err => { 60 | m.error('main') 61 | console.log(`\n ${errorLog}failed to build main process`) 62 | console.error(`\n${err}\n`) 63 | process.exit(1) 64 | }) 65 | 66 | pack(rendererConfig).then(result => { 67 | results += result + '\n\n' 68 | m.success('renderer') 69 | }).catch(err => { 70 | m.error('renderer') 71 | console.log(`\n ${errorLog}failed to build renderer process`) 72 | console.error(`\n${err}\n`) 73 | process.exit(1) 74 | }) 75 | } 76 | 77 | function pack (config) { 78 | return new Promise((resolve, reject) => { 79 | webpack(config, (err, stats) => { 80 | if (err) reject(err.stack || err) 81 | else if (stats.hasErrors()) { 82 | let err = '' 83 | 84 | stats.toString({ 85 | chunks: false, 86 | colors: true 87 | }) 88 | .split(/\r?\n/) 89 | .forEach(line => { 90 | err += ` ${line}\n` 91 | }) 92 | 93 | reject(err) 94 | } else { 95 | resolve(stats.toString({ 96 | chunks: false, 97 | colors: true 98 | })) 99 | } 100 | }) 101 | }) 102 | } 103 | 104 | {{#if_eq builder 'packager'}} 105 | function bundleApp () { 106 | packager(buildConfig, (err, appPaths) => { 107 | if (err) { 108 | console.log(`\n${errorLog}${chalk.yellow('`electron-packager`')} says...\n`) 109 | console.log(err + '\n') 110 | } else { 111 | console.log(`\n${doneLog}\n`) 112 | } 113 | }) 114 | } 115 | 116 | {{/if_eq}} 117 | function web () { 118 | del.sync(['dist/web/*', '!.gitkeep']) 119 | webpack(webConfig, (err, stats) => { 120 | if (err || stats.hasErrors()) console.log(err) 121 | 122 | console.log(stats.toString({ 123 | chunks: false, 124 | colors: true 125 | })) 126 | 127 | process.exit() 128 | }) 129 | } 130 | 131 | function greeting () { 132 | const cols = process.stdout.columns 133 | let text = '' 134 | 135 | if (cols > 85) text = 'lets-build' 136 | else if (cols > 60) text = 'lets-|build' 137 | else text = false 138 | 139 | if (text && !isCI) { 140 | say(text, { 141 | colors: ['yellow'], 142 | font: 'simple3d', 143 | space: false 144 | }) 145 | } else console.log(chalk.yellow.bold('\n lets-build')) 146 | console.log() 147 | } 148 | -------------------------------------------------------------------------------- /docs/en/using-electron-builder.md: -------------------------------------------------------------------------------- 1 | # Using [`electron-builder`](https://github.com/electron-userland/electron-builder) 2 | 3 | All builds produced by `electron-builder` can be found within the `build` directory. 4 | 5 | #### Building 6 | 7 | ```bash 8 | npm run build 9 | ``` 10 | 11 | #### Building unpacked directory 12 | 13 | Produce simple executable without full installer. Useful for quick testing. 14 | 15 | ```bash 16 | npm run build:dir 17 | ``` 18 | 19 | ### Default building configuration 20 | 21 | Further customization can be made at `package.json` in accordance to `electron-builders`'s options found [here](https://github.com/electron-userland/electron-builder/wiki/Options). 22 | 23 | ```js 24 | "build": { 25 | "productName": "ElectronVue", 26 | "appId": "org.simulatedgreg.electron-vue", 27 | "dmg": { 28 | "contents": [ 29 | { 30 | "x": 410, 31 | "y": 150, 32 | "type": "link", 33 | "path": "/Applications" 34 | }, 35 | { 36 | "x": 130, 37 | "y": 150, 38 | "type": "file" 39 | } 40 | ] 41 | }, 42 | "directories": { 43 | "output": "build" 44 | }, 45 | "files": [ 46 | "dist/electron", 47 | "node_modules/", 48 | "package.json" 49 | ], 50 | "mac": { 51 | "icon": "build/icons/icon.icns" 52 | }, 53 | "win": { 54 | "icon": "build/icons/icon.ico" 55 | }, 56 | "linux": { 57 | "icon": "build/icons" 58 | } 59 | } 60 | ``` 61 | 62 | ## Automated Deployments using CI 63 | 64 | When using electron-vue's `electron-builder` configuration, you are also provided a `appveyor.yml` and `.travis.yml` for automated deployments. Both config files are setup for building your electron application and pushing artifacts to a GitHub release, Bintray, etc. Travis CI is used to build both `linux` and `darwin` \(macOS\) while AppVeyor is used to build `win32`. Both services are free for OSS projects. 65 | 66 | #### Setting up Travis CI/AppVeyor 67 | 68 | 1. Create an account over at [Travis CI](https://travis-ci.org/getting_started) / [AppVeyor](https://www.appveyor.com/) 69 | 2. Link your GitHub repository that has your electron-vue project 70 | 3. Visit [https://github.com/settings/tokens](https://github.com/settings/tokens) and hit **Generate new token **\(the same token can be used for both Travis CI & AppVeyor\) 71 | 1. Set a **Token description** 72 | 2. Check the **public\_repo **scope 73 | 3. Hit **Generate token** 74 | 4. Copy your new token and save for later 75 | 5. Open your repository settings on Travis CI / AppVeyor to add a new **Environment Variable** 76 | 1. Set the name of the variable to `GH_TOKEN` 77 | 2. Set the value of the variable to the GitHub access token you just created 78 | 3. **Save** the new variable and ensure encryption is enabled 79 | 80 | At this point, everything should be setup. Travis CI/AppVeyor by default will watch for any pushes to your `master` branch. When a push is made, Travis CI/AppVeyor will then clone down your repository to its server and begin the build process. During the final stages, `electron-builder` with see the `GH_TOKEN` environment variable and create a draft release and upload the artifacts to your public GitHub repository. From this point, you can edit the draft release and then publish it to the world. After publishing your release, make sure future releases are marked with a new version number by updating your `package.json`. 81 | 82 | #### Auto Updating 83 | 84 | Enabling your application to receive automatic updates is a super nice feature to have, but know that [**Code Signing**](https://github.com/electron-userland/electron-builder/wiki/Code-Signing) is required. You can setup code signing by adding a few more environment variables based on what `electron-builder` needs described [here](https://www.electron.build/code-signing). Once you have your certificates setup, you can then install `electron-updater` and comment out the chunk of code at the bottom of `src/main/index.js` to enable auto updating. 85 | 86 | If you are like most people and do not have a fancy code signing certificate, then you can always use the GitHub API to check for new releases. When a new release is detected, provide a notification within your application to point users to a download page where they can download and install the new build. Thanks to the amazing installer that `electron-builder` provides, user's do not have to uninstall the current version and the new installation will replace the old while still persisting any web storage or `userData` files. 87 | 88 | -------------------------------------------------------------------------------- /docs/cn/README.md: -------------------------------------------------------------------------------- 1 | ![](../images/logo.png) 2 | 3 | > 基于 vue (基本上是它听起来的样子) 来构造 electron 应用程序的样板代码。 4 | 5 | [![Build Status](https://semaphoreci.com/api/v1/simulatedgreg/electron-vue/branches/master/badge.svg)](https://semaphoreci.com/simulatedgreg/electron-vue) 6 | 7 | [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) 8 | 9 | [![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](http://forthebadge.com) [![forthebadge](http://forthebadge.com/images/badges/uses-js.svg)](http://forthebadge.com) [![forthebadge](http://forthebadge.com/images/badges/makes-people-smile.svg)](http://forthebadge.com) 10 | 11 | ## 概要 12 | 13 | 该项目的目的,是为了要避免使用 vue 手动建立起 electron 应用程序。electron-vue 充分利用 `vue-cli` 作为脚手架工具,加上拥有 `vue-loader` 的 `webpack`、`electron-packager` 或是 `electron-builder`,以及一些最常用的插件,如`vue-router`、`vuex` 等等。 14 | 15 | 16 | #### 在 [这里](https://simulatedgreg.gitbooks.io/electron-vue/content/index.html) 查看其文档。 17 | 18 | 你会在本样板代码中找到的东西... 19 | 20 | * 基本的项目结构与 **单一的** `package.json` 设置 21 | * 详细的 [文档](https://simulatedgreg.gitbooks.io/electron-vue/content/) 22 | * 使用 [vue-cli](https://github.com/vuejs/vue-cli) 作为项目脚手架 23 | * 立即可用的 Vue 插件 \([axios](https://github.com/mzabriskie/axios), [vue-electron](https://github.com/SimulatedGREG/vue-electron), [vue-router](https://github.com/vuejs/vue-router), [vuex](https://github.com/vuejs/vuex)\)\* 24 | * 预装开发工具 [vue-devtools](https://github.com/vuejs/vue-devtools) 和 [devtron](https://github.com/electron/devtron) 25 | * 使用 [electron-packager](https://github.com/electron-userland/electron-packager) 或 [electron-builder](https://github.com/electron-userland/electron-builder) 轻松打包你的应用程序\* 26 | * `appveyor.yml` 与 `.travis.yml` 配置用于 [electron-builder](https://github.com/electron-userland/electron-builder) 的自动部署\* 27 | * 能够生成用于浏览器的网页输出 28 | * 便利的 [NPM 脚本](/npm_scripts.md) 29 | * 使用携带模块热更新 (Hot Module Replacement) 的 [webpack](https://github.com/webpack/webpack) 和 [vue-loader](https://github.com/vuejs/vue-loader) 30 | * 在工作在 electron 的 `main` 主进程时重启进程 31 | * 支持使用 [vue-loader](https://github.com/vuejs/vue-loader/) 的 HTML/CSS/JS 预处理器 32 | * 默认支持 [`stage-0`](https://babeljs.io/docs/plugins/preset-stage-0/) 的 ES6 33 | * 使用 [`babili`](https://github.com/babel/babili) 避免完全反编译到 ES5 34 | * ESLint \(支持 [`standard`](https://github.com/feross/standard) 和 [`airbnb-base`](https://github.com/airbnb/javascript)\)\* 35 | * 单元测试 \(使用 Karma + Mocha\)\* 36 | * 端到端测试 \(使用 Spectron + Mocha\)\* 37 | 38 | \* 在`vue-cli`脚手架中可定制 39 | 40 | ### 起步 41 | 42 | 该样板代码被构建为 [`vue-cli`](https://github.com/vuejs/vue-cli) 的一个模板,并且包含多个选项,可以自定义你最终的脚手架程序。本项目需要使用 `node@^7` 或更高版本。electron-vue 官方推荐 [`yarn`](https://yarnpkg.org) 作为软件包管理器,因为它可以更好地处理依赖关系,并可以使用 `yarn clean` 帮助减少最后构建文件的大小。 43 | 44 | ```bash 45 | # 安装 vue-cli 和 脚手架样板代码 46 | npm install -g vue-cli 47 | vue init simulatedgreg/electron-vue my-project 48 | 49 | # 安装依赖并运行你的程序 50 | cd my-project 51 | yarn # 或者 npm install 52 | yarn run dev # 或者 npm run dev 53 | ``` 54 | 55 | ##### 你是一个 Windows 用户? 56 | 57 | 请务必查看 [**Windows 用户注意事项**](https://simulatedgreg.gitbooks.io/electron-vue/content/en/getting_started.html#a-note-for-windows-users) 来确保你拥有 electron 和其他依赖关系所需的所有必要构建工具。 58 | 59 | ##### 希望使用 Vue 1? 60 | 61 | 只需指向 `1.0` 分支即可。请注意,electron-vue 已经正式废除了 `vue@^1` 的使用,因此,这些更改也同样会反映到项目结构、功能和文档上 \([**遗留文档**](https://github.com/SimulatedGREG/electron-vue/tree/1.0/docs)\)。 62 | 63 | ```bash 64 | vue init simulatedgreg/electron-vue#1.0 my-project 65 | ``` 66 | 67 | ### 下一步 68 | 69 | 请务必查看 [这个文档](https://simulatedgreg.gitbooks.io/electron-vue/content/)。在这里,你将找到有关项目配置、项目结构和构建应用程序的有用信息。这里还有一个方便的 [常见问题](https://simulatedgreg.gitbooks.io/electron-vue/content/en/faqs.html) 的部分。 70 | 71 | ## 基于 electron-vue 的作品 72 | 73 | 看看一些基于 electron-vue 建造的了不起的的项目。想要在此列出你自己的项目吗?请随时提交 pull 请求。 74 | 75 | * [**Surfbird**](https://github.com/surfbirdapp/surfbird): 一个基于 Electron 和 Vue 的 Twitter 客户端 76 | * [**Lulumi-browser**](https://github.com/qazbnm456/lulumi-browser): Lulumi-browser 是一个轻量级的浏览器,基于 Vue.js 2 和 Electron 77 | * [**Space-Snake**](https://github.com/ilyagru/Space-Snake): 使用 Electron 和 Vue.js 构建的桌面游戏。 78 | * [**Forrest**](https://github.com/stefanjudis/forrest): 一个 npm 脚本的桌面客户端 79 | * [**miikun**](https://github.com/hiro0218/miikun): 一个简单的 Markdown 编辑器 80 | * [**Dakika**](https://github.com/Madawar/Dakika): 超省时的应用程序,使写作变得轻而易举 81 | * [**Dynamoc**](https://github.com/ieiayaobb/dynamoc): Dynamoc 是一个 dynamodb-local、 dynalite 和 AWS dynamodb 的图形化界面客户端 82 | * [**Dockeron**](https://github.com/dockeron/dockeron): Dockeron 项目, 基于 Electron + Vue.js 的 Docker 桌面客户端 83 | * [**Easysubs**](https://github.com/matiastucci/easysubs): 快速简单地下载字幕 84 | * [**Data-curator**](https://github.com/ODIQueensland/data-curator):分享可用的開放數據。 85 | -------------------------------------------------------------------------------- /template/.electron-vue/dev-runner.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const chalk = require('chalk') 4 | const electron = require('electron') 5 | const path = require('path') 6 | const { say } = require('cfonts') 7 | const { spawn } = require('child_process') 8 | const webpack = require('webpack') 9 | const WebpackDevServer = require('webpack-dev-server') 10 | const webpackHotMiddleware = require('webpack-hot-middleware') 11 | 12 | const mainConfig = require('./webpack.main.config') 13 | const rendererConfig = require('./webpack.renderer.config') 14 | 15 | let electronProcess = null 16 | let manualRestart = false 17 | let hotMiddleware 18 | 19 | function logStats (proc, data) { 20 | let log = '' 21 | 22 | log += chalk.yellow.bold(`┏ ${proc} Process ${new Array((19 - proc.length) + 1).join('-')}`) 23 | log += '\n\n' 24 | 25 | if (typeof data === 'object') { 26 | data.toString({ 27 | colors: true, 28 | chunks: false 29 | }).split(/\r?\n/).forEach(line => { 30 | log += ' ' + line + '\n' 31 | }) 32 | } else { 33 | log += ` ${data}\n` 34 | } 35 | 36 | log += '\n' + chalk.yellow.bold(`┗ ${new Array(28 + 1).join('-')}`) + '\n' 37 | 38 | console.log(log) 39 | } 40 | 41 | function startRenderer () { 42 | return new Promise((resolve, reject) => { 43 | rendererConfig.entry.renderer = [path.join(__dirname, 'dev-client')].concat(rendererConfig.entry.renderer) 44 | 45 | const compiler = webpack(rendererConfig) 46 | hotMiddleware = webpackHotMiddleware(compiler, { 47 | log: false, 48 | heartbeat: 2500 49 | }) 50 | 51 | compiler.plugin('compilation', compilation => { 52 | compilation.plugin('html-webpack-plugin-after-emit', (data, cb) => { 53 | hotMiddleware.publish({ action: 'reload' }) 54 | cb() 55 | }) 56 | }) 57 | 58 | compiler.plugin('done', stats => { 59 | logStats('Renderer', stats) 60 | }) 61 | 62 | const server = new WebpackDevServer( 63 | compiler, 64 | { 65 | contentBase: path.join(__dirname, '../'), 66 | quiet: true, 67 | before (app, ctx) { 68 | app.use(hotMiddleware) 69 | ctx.middleware.waitUntilValid(() => { 70 | resolve() 71 | }) 72 | } 73 | } 74 | ) 75 | 76 | server.listen(9080) 77 | }) 78 | } 79 | 80 | function startMain () { 81 | return new Promise((resolve, reject) => { 82 | mainConfig.entry.main = [path.join(__dirname, '../src/main/index.dev.js')].concat(mainConfig.entry.main) 83 | 84 | const compiler = webpack(mainConfig) 85 | 86 | compiler.plugin('watch-run', (compilation, done) => { 87 | logStats('Main', chalk.white.bold('compiling...')) 88 | hotMiddleware.publish({ action: 'compiling' }) 89 | done() 90 | }) 91 | 92 | compiler.watch({}, (err, stats) => { 93 | if (err) { 94 | console.log(err) 95 | return 96 | } 97 | 98 | logStats('Main', stats) 99 | 100 | if (electronProcess && electronProcess.kill) { 101 | manualRestart = true 102 | process.kill(electronProcess.pid) 103 | electronProcess = null 104 | startElectron() 105 | 106 | setTimeout(() => { 107 | manualRestart = false 108 | }, 5000) 109 | } 110 | 111 | resolve() 112 | }) 113 | }) 114 | } 115 | 116 | function startElectron () { 117 | electronProcess = spawn(electron, ['--inspect=5858', '.']) 118 | 119 | electronProcess.stdout.on('data', data => { 120 | electronLog(data, 'blue') 121 | }) 122 | electronProcess.stderr.on('data', data => { 123 | electronLog(data, 'red') 124 | }) 125 | 126 | electronProcess.on('close', () => { 127 | if (!manualRestart) process.exit() 128 | }) 129 | } 130 | 131 | function electronLog (data, color) { 132 | let log = '' 133 | data = data.toString().split(/\r?\n/) 134 | data.forEach(line => { 135 | log += ` ${line}\n` 136 | }) 137 | if (/[0-9A-z]+/.test(log)) { 138 | console.log( 139 | chalk[color].bold('┏ Electron -------------------') + 140 | '\n\n' + 141 | log + 142 | chalk[color].bold('┗ ----------------------------') + 143 | '\n' 144 | ) 145 | } 146 | } 147 | 148 | function greeting () { 149 | const cols = process.stdout.columns 150 | let text = '' 151 | 152 | if (cols > 104) text = 'electron-vue' 153 | else if (cols > 76) text = 'electron-|vue' 154 | else text = false 155 | 156 | if (text) { 157 | say(text, { 158 | colors: ['yellow'], 159 | font: 'simple3d', 160 | space: false 161 | }) 162 | } else console.log(chalk.yellow.bold('\n electron-vue')) 163 | console.log(chalk.blue(' getting ready...') + '\n') 164 | } 165 | 166 | function init () { 167 | greeting() 168 | 169 | Promise.all([startRenderer(), startMain()]) 170 | .then(() => { 171 | startElectron() 172 | }) 173 | .catch(err => { 174 | console.error(err) 175 | }) 176 | } 177 | 178 | init() 179 | -------------------------------------------------------------------------------- /docs/ja/README.md: -------------------------------------------------------------------------------- 1 | ![](../images/logo.png) 2 | 3 | > vue で構築された electron アプリケーションを作成するためのボイラープレートです(名前から分かるように)。 4 | 5 | [![Build Status](https://semaphoreci.com/api/v1/simulatedgreg/electron-vue/branches/master/badge.svg)](https://semaphoreci.com/simulatedgreg/electron-vue) 6 | 7 | [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) 8 | 9 | [![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](http://forthebadge.com) [![forthebadge](http://forthebadge.com/images/badges/uses-js.svg)](http://forthebadge.com) [![forthebadge](http://forthebadge.com/images/badges/makes-people-smile.svg)](http://forthebadge.com) 10 | 11 | ## 概要 12 | 13 | このプロジェクトは vue を使用した electron アプリケーションの手動セットアップをなくすことを目標としています。electron-vue はスキャフォールディングのために `vue-cli` 、 `vue-loader` と `webpack`、 `electron-packager` または `electron-builder`、 `vue-router` や `vuex` などの最も使われているプラグインを使用します。 14 | 15 | #### ドキュメントは [こちら](https://simulatedgreg.gitbooks.io/electron-vue/content/index.html)を確認してください。 16 | 17 | このボイラープレートで見つけることができるもの... 18 | 19 | - **単一の** `package.json` セットアップによる基本的なプロジェクト構造 20 | - 詳細な[ドキュメント](https://simulatedgreg.gitbooks.io/electron-vue/content/) 21 | - [vue-cli](https://github.com/vuejs/vue-cli) を使用したプロジェクトスキャフォールディング 22 | - Vue プラグイン ([axios](https://github.com/mzabriskie/axios), [vue-electron](https://github.com/SimulatedGREG/vue-electron), [vue-router](https://github.com/vuejs/vue-router), [vuex](https://github.com/vuejs/vuex))を使用する準備ができています* 23 | - 開発のために [vue-devtools](https://github.com/vuejs/vue-devtools) や [devtron](https://github.com/electron/devtron) ツールのインストール 24 | - [electron-packager](https://github.com/electron-userland/electron-packager) や [electron-builder](https://github.com/electron-userland/electron-builder) を使用して簡単にアプリケーションをパッケージングする機能* 25 | - [electron-builder](https://github.com/electron-userland/electron-builder) による自動デプロイのための `appveyor.yml` と `.travis.yml` の設定* 26 | - ブラウザ用の Web 出力を生成する機能 27 | - 便利な [NPM scripts](/npm_scripts.md) 28 | - Hot Module Replacement を伴う [webpack](https://github.com/webpack/webpack) と [vue-loader](https://github.com/vuejs/vue-loader) の使用 29 | - electron の `main` プロセスで動いているプロセスの再起動 30 | - [vue-loader](https://github.com/vuejs/vue-loader/) による HTML/CSS/JS プリプロセッサのサポート 31 | - ES6 のデフォルトは [`stage-0`](https://babeljs.io/docs/plugins/preset-stage-0/) です 32 | - ES5 へトランスパイルする必要をなくすために [`babili`](https://github.com/babel/babili) の使用 33 | - ESLint ([`standard`](https://github.com/feross/standard) と [`airbnb-base`](https://github.com/airbnb/javascript) スタイルのサポート)* 34 | - (Karma と Mocha を使用した)ユニットテスト* 35 | - (Spectron と Mocha を使用した)エンドツーエンドテスト* 36 | 37 | *の箇所は `vue-cli` のスキャフォールディング中にカスタマイズ可能です 38 | 39 | ### はじめに 40 | 41 | このボイラープレートは [`vue-cli`](https://github.com/vuejs/vue-cli) のテンプレートとして作成され、スキャフォールディングされたアプリケーションをカスタマイズするためのオプションが含まれています。`node@^7` かそれ以上のバージョンを使用する必要があります。electron-vue はパッケージマネージャの [`yarn`](https://yarnpkg.org) を公式に推奨しています。依存関係をよりよく処理し、`yarn clean` により最終的なビルドサイズを減らすことができます。 42 | 43 | ```bash 44 | # vue-cli をインストールしボイラープレートをスキャフォールディングします 45 | npm install -g vue-cli 46 | vue init simulatedgreg/electron-vue my-project 47 | # 依存関係をインストールし、アプリケーションを実行します 48 | cd my-project 49 | yarn # or npm install 50 | yarn run dev # or npm run dev 51 | ``` 52 | 53 | ##### Windows ユーザーですか? 54 | 55 | [**Windows ユーザーのための注意**](https://simulatedgreg.gitbooks.io/electron-vue/content/ja/getting_started.html#a-note-for-windows-users)を確認し、electron や他の依存関係で必要なビルドツールが全てあることを確認してください。 56 | 57 | ##### Vue 1 を使いたいですか? 58 | 59 | `1.0` ブランチを参照してください。electron-vue は `vue@^1` の使用を公式に推奨していないため、プロジェクトの構造、機能やドキュメントは これらの変更を反映していることに注意してください([**旧版のドキュメント**](https://github.com/SimulatedGREG/electron-vue/tree/1.0/docs))。 60 | 61 | ```bash 62 | vue init simulatedgreg/electron-vue#1.0 my-project 63 | ``` 64 | 65 | ### 次のステップ 66 | 67 | [ドキュメント](https://simulatedgreg.gitbooks.io/electron-vue/content/) を確認してください。こちらから設定、プロジェクト構造、アプリケーションのビルドに関する有益な情報を得ることができます。便利な [FAQ](https://simulatedgreg.gitbooks.io/electron-vue/content/ja/faqs.html) セクションもあります。 68 | 69 | ## electron-vue で作られたもの 70 | 71 | electron-vue で作られたいくつかの素晴らしいプロジェクトを見てみましょう。自身のプロジェクトをリストに追加したいですか?遠慮なくプルリクエストを送ってください。 72 | 73 | - [**Surfbird**](https://github.com/surfbirdapp/surfbird): Electron と Vue で作られた Twitter クライアント 74 | - [**Lulumi-browser**](https://github.com/qazbnm456/lulumi-browser): Lulumi-browser は Vue.js 2 と Electron でコーディングされた軽量なブラウザです。 75 | - [**Space-Snake**](https://github.com/ilyagru/Space-Snake): Electron と Vue.js で作られたデスクトップゲーム。 76 | - [**Forrest**](https://github.com/stefanjudis/forrest): npm scripts デスクトップクライアント 77 | - [**miikun**](https://github.com/hiro0218/miikun): シンプルなマークダウンエディター 78 | - [**Dakika**](https://github.com/Madawar/Dakika): 議事録を簡単に取ることができるアプリケーション 79 | - [**Dynamoc**](https://github.com/ieiayaobb/dynamoc): Dynamoc は dynamodb-local、 dynalite と AWS dynamodb のための GUI クライアントです 80 | - [**Dockeron**](https://github.com/dockeron/dockeron): Docker のために Electron と Vue.js で作られた dockeron プロジェクト 81 | - [**Easysubs**](https://github.com/matiastucci/easysubs): 字幕を早く簡単な方法でダウンロードする 82 | - [**Data-curator**](https://github.com/ODIQueensland/data-curator):利用可能な公開データを共有します。 83 | -------------------------------------------------------------------------------- /template/.electron-vue/webpack.renderer.config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | process.env.BABEL_ENV = 'renderer' 4 | 5 | const path = require('path') 6 | const { dependencies } = require('../package.json') 7 | const webpack = require('webpack') 8 | 9 | const BabiliWebpackPlugin = require('babili-webpack-plugin') 10 | const CopyWebpackPlugin = require('copy-webpack-plugin') 11 | const ExtractTextPlugin = require('extract-text-webpack-plugin') 12 | const HtmlWebpackPlugin = require('html-webpack-plugin') 13 | 14 | /** 15 | * List of node_modules to include in webpack bundle 16 | * 17 | * Required for specific packages like Vue UI libraries 18 | * that provide pure *.vue files that need compiling 19 | * https://simulatedgreg.gitbooks.io/electron-vue/content/en/webpack-configurations.html#white-listing-externals 20 | */ 21 | let whiteListedModules = ['vue'] 22 | 23 | let rendererConfig = { 24 | devtool: '#cheap-module-eval-source-map', 25 | entry: { 26 | renderer: path.join(__dirname, '../src/renderer/main.js') 27 | }, 28 | externals: [ 29 | ...Object.keys(dependencies || {}).filter(d => !whiteListedModules.includes(d)) 30 | ], 31 | module: { 32 | rules: [ 33 | {{#if eslint}} 34 | { 35 | test: /\.(js|vue)$/, 36 | enforce: 'pre', 37 | exclude: /node_modules/, 38 | use: { 39 | loader: 'eslint-loader', 40 | options: { 41 | formatter: require('eslint-friendly-formatter') 42 | } 43 | } 44 | }, 45 | {{/if}} 46 | { 47 | test: /\.css$/, 48 | use: ExtractTextPlugin.extract({ 49 | fallback: 'style-loader', 50 | use: 'css-loader' 51 | }) 52 | }, 53 | { 54 | test: /\.html$/, 55 | use: 'vue-html-loader' 56 | }, 57 | { 58 | test: /\.js$/, 59 | use: 'babel-loader', 60 | exclude: /node_modules/ 61 | }, 62 | { 63 | test: /\.node$/, 64 | use: 'node-loader' 65 | }, 66 | { 67 | test: /\.vue$/, 68 | use: { 69 | loader: 'vue-loader', 70 | options: { 71 | extractCSS: process.env.NODE_ENV === 'production', 72 | loaders: { 73 | sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1', 74 | scss: 'vue-style-loader!css-loader!sass-loader' 75 | } 76 | } 77 | } 78 | }, 79 | { 80 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 81 | use: { 82 | loader: 'url-loader', 83 | query: { 84 | limit: 10000, 85 | name: 'imgs/[name]--[folder].[ext]' 86 | } 87 | } 88 | }, 89 | { 90 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, 91 | loader: 'url-loader', 92 | options: { 93 | limit: 10000, 94 | name: 'media/[name]--[folder].[ext]' 95 | } 96 | }, 97 | { 98 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 99 | use: { 100 | loader: 'url-loader', 101 | query: { 102 | limit: 10000, 103 | name: 'fonts/[name]--[folder].[ext]' 104 | } 105 | } 106 | } 107 | ] 108 | }, 109 | node: { 110 | __dirname: process.env.NODE_ENV !== 'production', 111 | __filename: process.env.NODE_ENV !== 'production' 112 | }, 113 | plugins: [ 114 | new ExtractTextPlugin('styles.css'), 115 | new HtmlWebpackPlugin({ 116 | filename: 'index.html', 117 | template: path.resolve(__dirname, '../src/index.ejs'), 118 | minify: { 119 | collapseWhitespace: true, 120 | removeAttributeQuotes: true, 121 | removeComments: true 122 | }, 123 | nodeModules: process.env.NODE_ENV !== 'production' 124 | ? path.resolve(__dirname, '../node_modules') 125 | : false 126 | }), 127 | new webpack.HotModuleReplacementPlugin(), 128 | new webpack.NoEmitOnErrorsPlugin() 129 | ], 130 | output: { 131 | filename: '[name].js', 132 | libraryTarget: 'commonjs2', 133 | path: path.join(__dirname, '../dist/electron') 134 | }, 135 | resolve: { 136 | alias: { 137 | '@': path.join(__dirname, '../src/renderer'), 138 | 'vue$': 'vue/dist/vue.esm.js' 139 | }, 140 | extensions: ['.js', '.vue', '.json', '.css', '.node'] 141 | }, 142 | target: 'electron-renderer' 143 | } 144 | 145 | /** 146 | * Adjust rendererConfig for development settings 147 | */ 148 | if (process.env.NODE_ENV !== 'production') { 149 | rendererConfig.plugins.push( 150 | new webpack.DefinePlugin({ 151 | '__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"` 152 | }) 153 | ) 154 | } 155 | 156 | /** 157 | * Adjust rendererConfig for production settings 158 | */ 159 | if (process.env.NODE_ENV === 'production') { 160 | rendererConfig.devtool = '' 161 | 162 | rendererConfig.plugins.push( 163 | new BabiliWebpackPlugin(), 164 | new CopyWebpackPlugin([ 165 | { 166 | from: path.join(__dirname, '../static'), 167 | to: path.join(__dirname, '../dist/electron/static'), 168 | ignore: ['.*'] 169 | } 170 | ]), 171 | new webpack.DefinePlugin({ 172 | 'process.env.NODE_ENV': '"production"' 173 | }), 174 | new webpack.LoaderOptionsPlugin({ 175 | minimize: true 176 | }) 177 | ) 178 | } 179 | 180 | module.exports = rendererConfig 181 | -------------------------------------------------------------------------------- /template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "{{ name }}", 3 | {{#if_eq builder 'packager'}} 4 | "productName": "{{ name }}", 5 | {{/if_eq}} 6 | "version": "0.0.0", 7 | "author": "{{ author }}", 8 | "description": "{{ description }}", 9 | "license": null, 10 | "main": "./dist/electron/main.js", 11 | "scripts": { 12 | {{#if_eq builder 'packager'}} 13 | "build": "node .electron-vue/build.js", 14 | "build:darwin": "cross-env BUILD_TARGET=darwin node .electron-vue/build.js", 15 | "build:linux": "cross-env BUILD_TARGET=linux node .electron-vue/build.js", 16 | "build:mas": "cross-env BUILD_TARGET=mas node .electron-vue/build.js", 17 | "build:win32": "cross-env BUILD_TARGET=win32 node .electron-vue/build.js", 18 | {{else}} 19 | "build": "node .electron-vue/build.js && electron-builder", 20 | "build:dir": "node .electron-vue/build.js && electron-builder --dir", 21 | {{/if_eq}} 22 | "build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js", 23 | "build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js", 24 | "dev": "node .electron-vue/dev-runner.js", 25 | {{#if e2e}} 26 | "e2e": "npm run pack && mocha test/e2e", 27 | {{/if}} 28 | {{#if eslint}} 29 | "lint": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter src{{#testing unit e2e}} test{{/testing}}", 30 | "lint:fix": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter --fix src{{#testing unit e2e}} test{{/testing}}", 31 | {{/if}} 32 | "pack": "npm run pack:main && npm run pack:renderer", 33 | "pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js", 34 | "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js", 35 | {{#testing unit e2e}} 36 | "test": "{{#unit}}npm run unit{{/unit}}{{#unit}}{{#e2e}} && {{/e2e}}{{/unit}}{{#e2e}}npm run e2e{{/e2e}}", 37 | {{/testing}} 38 | {{#if unit}} 39 | "unit": "karma start test/unit/karma.conf.js", 40 | {{/if}} 41 | "postinstall": "{{#if eslint}}npm run lint:fix{{/if}}" 42 | }, 43 | {{#if_eq builder 'builder'}} 44 | "build": { 45 | "productName": "{{ name }}", 46 | "appId": "org.simulatedgreg.electron-vue", 47 | "directories": { 48 | "output": "build" 49 | }, 50 | "files": [ 51 | "dist/electron/**/*" 52 | ], 53 | "dmg": { 54 | "contents": [ 55 | { 56 | "x": 410, 57 | "y": 150, 58 | "type": "link", 59 | "path": "/Applications" 60 | }, 61 | { 62 | "x": 130, 63 | "y": 150, 64 | "type": "file" 65 | } 66 | ] 67 | }, 68 | "mac": { 69 | "icon": "build/icons/icon.icns" 70 | }, 71 | "win": { 72 | "icon": "build/icons/icon.ico" 73 | }, 74 | "linux": { 75 | "icon": "build/icons" 76 | } 77 | }, 78 | {{/if_eq}} 79 | "dependencies": { 80 | "vue": "^2.3.3"{{deps plugins}} 81 | }, 82 | "devDependencies": { 83 | "babel-core": "^6.25.0", 84 | "babel-loader": "^7.1.1", 85 | "babel-plugin-transform-runtime": "^6.23.0", 86 | "babel-preset-env": "^1.6.0", 87 | "babel-preset-stage-0": "^6.24.1", 88 | "babel-register": "^6.24.1", 89 | "babili-webpack-plugin": "^0.1.2", 90 | "cfonts": "^1.1.3", 91 | "chalk": "^2.1.0", 92 | "copy-webpack-plugin": "^4.0.1", 93 | "cross-env": "^5.0.5", 94 | "css-loader": "^0.28.4", 95 | "del": "^3.0.0", 96 | "devtron": "^1.4.0", 97 | "electron": "^1.7.5", 98 | "electron-debug": "^1.4.0", 99 | "electron-devtools-installer": "^2.2.0", 100 | {{#if_eq builder 'packager'}} 101 | "electron-packager": "^8.5.0", 102 | "electron-rebuild": "^1.1.3", 103 | {{else}} 104 | "electron-builder": "^19.19.1", 105 | {{/if_eq}} 106 | {{#eslint}} 107 | "babel-eslint": "^7.2.3", 108 | "eslint": "^4.4.1", 109 | "eslint-friendly-formatter": "^3.0.0", 110 | "eslint-loader": "^1.9.0", 111 | "eslint-plugin-html": "^3.1.1", 112 | {{#if_eq eslintConfig 'standard'}} 113 | "eslint-config-standard": "^10.2.1", 114 | "eslint-plugin-import": "^2.7.0", 115 | "eslint-plugin-node": "^5.1.1", 116 | "eslint-plugin-promise": "^3.5.0", 117 | "eslint-plugin-standard": "^3.0.1", 118 | {{/if_eq}} 119 | {{#if_eq eslintConfig 'airbnb'}} 120 | "eslint-config-airbnb-base": "^11.2.0", 121 | "eslint-import-resolver-webpack": "^0.8.1", 122 | "eslint-plugin-import": "^2.2.0", 123 | {{/if_eq}} 124 | {{/eslint}} 125 | "extract-text-webpack-plugin": "^3.0.0", 126 | "file-loader": "^0.11.2", 127 | "html-webpack-plugin": "^2.30.1", 128 | {{#if unit}} 129 | "inject-loader": "^3.0.0", 130 | "karma": "^1.3.0", 131 | "karma-chai": "^0.1.0", 132 | "karma-coverage": "^1.1.1", 133 | "karma-electron": "^5.1.1", 134 | "karma-mocha": "^1.2.0", 135 | "karma-sourcemap-loader": "^0.3.7", 136 | "karma-spec-reporter": "^0.0.31", 137 | "karma-webpack": "^2.0.1", 138 | "webpack-merge": "^4.1.0", 139 | {{/if}} 140 | {{#if e2e}} 141 | "require-dir": "^0.3.0", 142 | "spectron": "^3.7.1", 143 | {{/if}} 144 | {{#testing unit e2e}} 145 | "babel-plugin-istanbul": "^4.1.1", 146 | "chai": "^4.0.0", 147 | "mocha": "^3.0.2", 148 | {{/testing}} 149 | "multispinner": "^0.2.1", 150 | "node-loader": "^0.6.0", 151 | "style-loader": "^0.18.2", 152 | "url-loader": "^0.5.9", 153 | "vue-html-loader": "^1.2.4", 154 | "vue-loader": "^13.0.5", 155 | "vue-style-loader": "^3.0.1", 156 | "vue-template-compiler": "^2.4.2", 157 | "webpack": "^3.5.2", 158 | "webpack-dev-server": "^2.7.1", 159 | "webpack-hot-middleware": "^2.18.2" 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /meta.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { join } = require('path') 4 | const { readFileSync, writeFileSync } = require('fs') 5 | const { get } = require('https') 6 | 7 | function getCurrentSHA (author) { 8 | return new Promise((resolve, reject) => { 9 | let isBranch = process.argv[2].indexOf('#') > -1 10 | 11 | get({ 12 | host: 'api.github.com', 13 | path: `/repos/simulatedgreg/electron-vue/commits${isBranch ? '?sha=' + process.argv[2].split('#')[1] : ''}`, 14 | headers: { 15 | 'User-Agent': author 16 | } 17 | }, res => { 18 | res.setEncoding('utf8') 19 | let rawData = '' 20 | 21 | res.on('data', chunk => { 22 | rawData += chunk 23 | }) 24 | res.on('end', () => { 25 | try { 26 | let parsed = JSON.parse(rawData) 27 | resolve(parsed[0].sha) 28 | } catch (e) { 29 | reject(e) 30 | } 31 | }) 32 | }).on('error', e => { 33 | reject(e) 34 | }) 35 | }) 36 | } 37 | 38 | function appendSHALink (sha, destDirName) { 39 | let readmePath = join(destDirName, '/README.md') 40 | let md = readFileSync(readmePath, 'utf8') 41 | md = md.replace( 42 | ' using', 43 | `@[${sha.substring(0, 7)}](https://github.com/SimulatedGREG/electron-vue/tree/${sha}) using` 44 | ) 45 | writeFileSync(readmePath, md, 'utf8') 46 | } 47 | 48 | module.exports = { 49 | prompts: { 50 | name: { 51 | type: 'string', 52 | required: true, 53 | message: 'Application Name' 54 | }, 55 | description: { 56 | type: 'string', 57 | required: false, 58 | message: 'Project description', 59 | default: 'An electron-vue project' 60 | }, 61 | plugins: { 62 | type: 'checkbox', 63 | message: 'Select which Vue plugins to install', 64 | choices: ['axios', 'vue-electron', 'vue-router', 'vuex'], 65 | default: ['axios', 'vue-electron', 'vue-router', 'vuex'] 66 | }, 67 | eslint: { 68 | type: 'confirm', 69 | require: true, 70 | message: 'Use linting with ESLint?', 71 | default: true 72 | }, 73 | eslintConfig: { 74 | when: 'eslint', 75 | type: 'list', 76 | message: 'Which ESLint config would you like to use?', 77 | choices: [ 78 | { 79 | name: 'Standard (https://github.com/feross/standard)', 80 | value: 'standard', 81 | short: 'Standard' 82 | }, 83 | { 84 | name: 'Airbnb (https://github.com/airbnb/javascript)', 85 | value: 'airbnb', 86 | short: 'Airbnb' 87 | }, 88 | { 89 | name: 'none (configure it yourself)', 90 | value: 'none', 91 | short: 'none' 92 | } 93 | ] 94 | }, 95 | unit: { 96 | type: 'confirm', 97 | message: 'Set up unit testing with Karma + Mocha?', 98 | required: true 99 | }, 100 | e2e: { 101 | type: 'confirm', 102 | message: 'Set up end-to-end testing with Spectron + Mocha?', 103 | require: true 104 | }, 105 | builder: { 106 | type: 'list', 107 | message: 'What build tool would you like to use?', 108 | choices: [ 109 | { 110 | name: 'electron-builder (https://github.com/electron-userland/electron-builder)', 111 | value: 'builder', 112 | short: 'builder' 113 | }, 114 | { 115 | name: 'electron-packager (https://github.com/electron-userland/electron-packager)', 116 | value: 'packager', 117 | short: 'packager' 118 | } 119 | ] 120 | } 121 | }, 122 | helpers: { 123 | isEnabled (list, check, opts) { 124 | if (list[check]) return opts.fn(this) 125 | else return opts.inverse(this) 126 | }, 127 | deps (plugins) { 128 | let output = '' 129 | let dependencies = { 130 | 'axios': '^0.16.1', 131 | 'vue-electron': '^1.0.6', 132 | 'vue-router': '^2.5.3', 133 | 'vuex': '^2.3.1' 134 | } 135 | 136 | if (Object.keys(plugins).length > 0) output += ',\n' 137 | 138 | Object.keys(plugins).forEach((p, i) => { 139 | output += ` "${p}": "${dependencies[p]}"` 140 | if (i !== Object.keys(plugins).length - 1) output += ',\n' 141 | }) 142 | 143 | return output 144 | }, 145 | testing (unit, e2e, opts) { 146 | if (unit || e2e) { 147 | return opts.fn(this) 148 | } 149 | } 150 | }, 151 | filters: { 152 | 'src/renderer/routes.js': 'plugins[\'vue-router\']', 153 | 'src/renderer/components/LandingPageView/CurrentPage.vue': 'plugins[\'vue-router\']', 154 | 'src/renderer/router/**/*': 'plugins[\'vue-router\']', 155 | 'src/renderer/store/**/*': 'plugins[\'vuex\']', 156 | 'test/e2e/**/*': 'e2e', 157 | 'test/unit/**/*': 'unit', 158 | '.electron-vue/build.config.js': 'builder === \'packager\'', 159 | 'test/.eslintrc': 'e2e || unit', 160 | '.eslintignore': 'eslint', 161 | '.eslintrc.js': 'eslint', 162 | 'appveyor.yml': 'builder === \'builder\'', 163 | '.travis.yml': 'builder === \'builder\'' 164 | }, 165 | complete (data) { 166 | getCurrentSHA(data.author).then(sha => { 167 | let path = !data.inPlace ? data.destDirName : null 168 | if (path !== null) appendSHALink(sha, path) 169 | console.log([ 170 | '\n---', 171 | '', 172 | 'All set. Welcome to your new electron-vue project!', 173 | '', 174 | 'Make sure to check out the documentation for this boilerplate at', 175 | '\x1b[33mhttps://simulatedgreg.gitbooks.io/electron-vue/content/\x1b[0m.', 176 | '', 177 | `Next Steps:\n${!data.inPlace ? '\n \x1b[33m$\x1b[0m cd ' + data.destDirName : ''}`, 178 | ' \x1b[33m$\x1b[0m yarn (or `npm install`)', 179 | ' \x1b[33m$\x1b[0m yarn run dev (or `npm run dev`)' 180 | ].join('\n')) 181 | }, () => { 182 | console.log('\x1b[33mwarning\x1b[0m Failed to append commit SHA on README.md') 183 | }) 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /docs/en/README.md: -------------------------------------------------------------------------------- 1 | ![](../images/logo.png) 2 | 3 | > The boilerplate for making electron applications built with vue \(pretty much what it sounds like\). 4 | 5 | [![Build Status](https://semaphoreci.com/api/v1/simulatedgreg/electron-vue/branches/master/badge.svg)](https://semaphoreci.com/simulatedgreg/electron-vue) 6 | 7 | [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) 8 | 9 | [![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](http://forthebadge.com) [![forthebadge](http://forthebadge.com/images/badges/uses-js.svg)](http://forthebadge.com) [![forthebadge](http://forthebadge.com/images/badges/makes-people-smile.svg)](http://forthebadge.com) 10 | 11 | ## Overview 12 | 13 | The aim of this project is to remove the need of manually setting up electron apps using vue. electron-vue takes advantage of `vue-cli` for scaffolding, `webpack` with `vue-loader`, `electron-packager` or `electron-builder`, some of the most used plugins like `vue-router`, `vuex`, and so much more. 14 | 15 | #### Check out the documentation [here](https://simulatedgreg.gitbooks.io/electron-vue/content/index.html). 16 | 17 | Things you'll find in this boilerplate... 18 | 19 | * Basic project structure with a **single** `package.json` setup 20 | * Detailed [documentation](https://simulatedgreg.gitbooks.io/electron-vue/content/) 21 | * Project scaffolding using [vue-cli](https://github.com/vuejs/vue-cli) 22 | * Ready to use Vue plugins \([axios](https://github.com/mzabriskie/axios), [vue-electron](https://github.com/SimulatedGREG/vue-electron), [vue-router](https://github.com/vuejs/vue-router), [vuex](https://github.com/vuejs/vuex)\)\* 23 | * Installed [vue-devtools](https://github.com/vuejs/vue-devtools) and [devtron](https://github.com/electron/devtron) tools for development 24 | * Ability to easily package your application using [electron-packager](https://github.com/electron-userland/electron-packager) or [electron-builder](https://github.com/electron-userland/electron-builder)\* 25 | * `appveyor.yml` and `.travis.yml` configurations for automated deployments with [electron-builder](https://github.com/electron-userland/electron-builder)\* 26 | * Ability to produce web output for browsers 27 | * Handy [NPM scripts](/npm_scripts.md) 28 | * Use of [webpack](https://github.com/webpack/webpack) and [vue-loader](https://github.com/vuejs/vue-loader) with Hot Module Replacement 29 | * Process restarting when working in electron's `main` process 30 | * HTML/CSS/JS pre-processor support with [vue-loader](https://github.com/vuejs/vue-loader/) 31 | * ES6 with [`stage-0`](https://babeljs.io/docs/plugins/preset-stage-0/) by default 32 | * Use of [`babili`](https://github.com/babel/babili) to remove the need of transpiling completely down to ES5 33 | * ESLint \(with support for [`standard`](https://github.com/feross/standard) and [`airbnb-base`](https://github.com/airbnb/javascript)\)\* 34 | * Unit Testing \(with Karma + Mocha\)\* 35 | * End-to-end Testing \(with Spectron + Mocha\)\* 36 | 37 | \*Customizable during `vue-cli` scaffolding 38 | 39 | ### Getting Started 40 | 41 | This boilerplate was built as a template for [`vue-cli`](https://github.com/vuejs/vue-cli) and includes options to customize your final scaffolded app. The use of `node@^7` or higher is required. electron-vue also officially recommends the [`yarn`](https://yarnpkg.org) package manager as it handles dependencies much better and can help reduce final build size with `yarn clean`. 42 | 43 | ```bash 44 | # Install vue-cli and scaffold boilerplate 45 | npm install -g vue-cli 46 | vue init simulatedgreg/electron-vue my-project 47 | 48 | # Install dependencies and run your app 49 | cd my-project 50 | yarn # or npm install 51 | yarn run dev # or npm run dev 52 | ``` 53 | 54 | ##### Are you a Windows User? 55 | 56 | Make sure to check out [**A Note for Windows Users**](https://simulatedgreg.gitbooks.io/electron-vue/content/en/getting_started.html#a-note-for-windows-users) to make sure you have all the necessary build tools needed for electron and other dependencies. 57 | 58 | ##### Wanting to use Vue 1? 59 | 60 | Just point to the `1.0` branch. Please note that electron-vue has officially deprecated the usage of `vue@^1`, so project structure, features, and documentation will reflect those changes \([**legacy documentation**](https://github.com/SimulatedGREG/electron-vue/tree/1.0/docs)\). 61 | 62 | ```bash 63 | vue init simulatedgreg/electron-vue#1.0 my-project 64 | ``` 65 | 66 | ### Next Steps 67 | 68 | Make sure to take a look at the [documentation](https://simulatedgreg.gitbooks.io/electron-vue/content/). Here you will find useful information about configuration, project structure, and building your app. There's also a handy [FAQs](https://simulatedgreg.gitbooks.io/electron-vue/content/en/faqs.html) section. 69 | 70 | ## Made with electron-vue 71 | 72 | Take a look at some of the amazing projects built with electron-vue. Want to have your own project listed? Feel free to submit a pull request. 73 | 74 | * [**Surfbird**](https://github.com/surfbirdapp/surfbird): A Twitter client built on Electron and Vue 75 | * [**Lulumi-browser**](https://github.com/qazbnm456/lulumi-browser): Lulumi-browser is a light weight browser coded with Vue.js 2 and Electron 76 | * [**Space-Snake**](https://github.com/ilyagru/Space-Snake): A Desktop game built with Electron and Vue.js. 77 | * [**Forrest**](https://github.com/stefanjudis/forrest): An npm scripts desktop client 78 | * [**miikun**](https://github.com/hiro0218/miikun): A Simple Markdown Editor 79 | * [**Dakika**](https://github.com/Madawar/Dakika): A minute taking application that makes writing minutes a breeze 80 | * [**Dynamoc**](https://github.com/ieiayaobb/dynamoc): Dynamoc is a GUI client for dynamodb-local, dynalite and AWS dynamodb 81 | * [**Dockeron**](https://github.com/dockeron/dockeron): A dockeron project, built on Electron + Vue.js for Docker 82 | * [**Easysubs**](https://github.com/matiastucci/easysubs): Download subtitles in a very fast and simple way 83 | * [**adminScheduler**](https://github.com/danieltoorani/adminScheduler): An application leveraging electron for cross platform compatibility, Vue.js for lightning fast UI and full-calendar.io to deliver a premium calendar interface. 84 | * [**Data-curator**](https://github.com/ODIQueensland/data-curator): Share usable open data. 85 | --------------------------------------------------------------------------------