Repository: SimulatedGREG/electron-vue
Branch: master
Commit: 8d4ed607d653
Files: 208
Total size: 296.7 KB
Directory structure:
gitextract_mf9vvmtx/
├── .github/
│ └── ISSUE_TEMPLATE.md
├── .gitignore
├── LICENSE.md
├── README.md
├── book.json
├── docs/
│ ├── LANGS.md
│ ├── cn/
│ │ ├── README.md
│ │ ├── SUMMARY.md
│ │ ├── book.json
│ │ ├── building_your_app.md
│ │ ├── contributing.md
│ │ ├── development.md
│ │ ├── end-to-end_testing.md
│ │ ├── entry_indexhtml.md
│ │ ├── faqs.md
│ │ ├── file-tree.md
│ │ ├── getting_started.md
│ │ ├── global_configuration.md
│ │ ├── main-process.md
│ │ ├── meta.md
│ │ ├── migration-guide.md
│ │ ├── miscellaneous.md
│ │ ├── new-releases.md
│ │ ├── npm_scripts.md
│ │ ├── project_structure.md
│ │ ├── renderer-process.md
│ │ ├── savingreading-local-files.md
│ │ ├── testing.md
│ │ ├── unittesting.md
│ │ ├── using-electron-builder.md
│ │ ├── using-electron-packager.md
│ │ ├── using-static-assets.md
│ │ ├── using_css_frameworks.md
│ │ ├── using_pre-processors.md
│ │ ├── using_the_file_structure.md
│ │ ├── vue_accessories.md
│ │ └── webpack-configurations.md
│ ├── en/
│ │ ├── README.md
│ │ ├── SUMMARY.md
│ │ ├── book.json
│ │ ├── building_your_app.md
│ │ ├── contributing.md
│ │ ├── debugging-production.md
│ │ ├── development.md
│ │ ├── end-to-end_testing.md
│ │ ├── entry_indexhtml.md
│ │ ├── faqs.md
│ │ ├── file-tree.md
│ │ ├── getting_started.md
│ │ ├── global_configuration.md
│ │ ├── main-process.md
│ │ ├── meta.md
│ │ ├── migration-guide.md
│ │ ├── miscellaneous.md
│ │ ├── new-releases.md
│ │ ├── npm_scripts.md
│ │ ├── project_structure.md
│ │ ├── renderer-process.md
│ │ ├── savingreading-local-files.md
│ │ ├── testing.md
│ │ ├── unittesting.md
│ │ ├── using-electron-builder.md
│ │ ├── using-electron-packager.md
│ │ ├── using-static-assets.md
│ │ ├── using_css_frameworks.md
│ │ ├── using_pre-processors.md
│ │ ├── using_the_file_structure.md
│ │ ├── vue_accessories.md
│ │ └── webpack-configurations.md
│ ├── ja/
│ │ ├── README.md
│ │ ├── SUMMARY.md
│ │ ├── book.json
│ │ ├── building_your_app.md
│ │ ├── contributing.md
│ │ ├── development.md
│ │ ├── end-to-end_testing.md
│ │ ├── entry_indexhtml.md
│ │ ├── faqs.md
│ │ ├── file-tree.md
│ │ ├── getting_started.md
│ │ ├── global_configuration.md
│ │ ├── main-process.md
│ │ ├── meta.md
│ │ ├── migration-guide.md
│ │ ├── miscellaneous.md
│ │ ├── new-releases.md
│ │ ├── npm_scripts.md
│ │ ├── project_structure.md
│ │ ├── renderer-process.md
│ │ ├── savingreading-local-files.md
│ │ ├── testing.md
│ │ ├── unittesting.md
│ │ ├── using-electron-builder.md
│ │ ├── using-electron-packager.md
│ │ ├── using-static-assets.md
│ │ ├── using_css_frameworks.md
│ │ ├── using_pre-processors.md
│ │ ├── using_the_file_structure.md
│ │ ├── vue_accessories.md
│ │ └── webpack-configurations.md
│ ├── ko/
│ │ ├── README.md
│ │ ├── SUMMARY.md
│ │ ├── book.json
│ │ ├── building_your_app.md
│ │ ├── contributing.md
│ │ ├── debugging-production.md
│ │ ├── development.md
│ │ ├── end-to-end_testing.md
│ │ ├── entry_indexhtml.md
│ │ ├── faqs.md
│ │ ├── file-tree.md
│ │ ├── getting_started.md
│ │ ├── global_configuration.md
│ │ ├── main-process.md
│ │ ├── meta.md
│ │ ├── migration-guide.md
│ │ ├── miscellaneous.md
│ │ ├── new-releases.md
│ │ ├── npm_scripts.md
│ │ ├── project_structure.md
│ │ ├── renderer-process.md
│ │ ├── savingreading-local-files.md
│ │ ├── testing.md
│ │ ├── unittesting.md
│ │ ├── using-electron-builder.md
│ │ ├── using-electron-packager.md
│ │ ├── using-static-assets.md
│ │ ├── using_css_frameworks.md
│ │ ├── using_pre-processors.md
│ │ ├── using_the_file_structure.md
│ │ ├── vue_accessories.md
│ │ └── webpack-configurations.md
│ └── pt_BR/
│ ├── README.md
│ ├── SUMMARY.md
│ ├── book.json
│ ├── building_your_app.md
│ ├── contributing.md
│ ├── development.md
│ ├── end-to-end_testing.md
│ ├── entry_indexhtml.md
│ ├── faqs.md
│ ├── file-tree.md
│ ├── getting_started.md
│ ├── global_configuration.md
│ ├── main-process.md
│ ├── meta.md
│ ├── migration-guide.md
│ ├── miscellaneous.md
│ ├── new-releases.md
│ ├── npm_scripts.md
│ ├── project_structure.md
│ ├── renderer-process.md
│ ├── savingreading-local-files.md
│ ├── testing.md
│ ├── unittesting.md
│ ├── using-electron-builder.md
│ ├── using-electron-packager.md
│ ├── using-static-assets.md
│ ├── using_css_frameworks.md
│ ├── using_pre-processors.md
│ ├── using_the_file_structure.md
│ ├── vue_accessories.md
│ └── webpack-configurations.md
├── meta.js
├── package.json
├── template/
│ ├── .babelrc
│ ├── .electron-vue/
│ │ ├── build.config.js
│ │ ├── build.js
│ │ ├── dev-client.js
│ │ ├── dev-runner.js
│ │ ├── webpack.main.config.js
│ │ ├── webpack.renderer.config.js
│ │ └── webpack.web.config.js
│ ├── .eslintignore
│ ├── .eslintrc.js
│ ├── .gitignore
│ ├── .travis.yml
│ ├── README.md
│ ├── appveyor.yml
│ ├── build/
│ │ └── icons/
│ │ └── icon.icns
│ ├── dist/
│ │ ├── electron/
│ │ │ └── .gitkeep
│ │ └── web/
│ │ └── .gitkeep
│ ├── package.json
│ ├── src/
│ │ ├── index.ejs
│ │ ├── main/
│ │ │ ├── index.dev.js
│ │ │ └── index.js
│ │ └── renderer/
│ │ ├── App.vue
│ │ ├── assets/
│ │ │ └── .gitkeep
│ │ ├── components/
│ │ │ ├── LandingPage/
│ │ │ │ └── SystemInformation.vue
│ │ │ └── LandingPage.vue
│ │ ├── main.js
│ │ ├── router/
│ │ │ └── index.js
│ │ └── store/
│ │ ├── index.js
│ │ └── modules/
│ │ ├── Counter.js
│ │ └── index.js
│ ├── static/
│ │ └── .gitkeep
│ └── test/
│ ├── .eslintrc
│ ├── e2e/
│ │ ├── index.js
│ │ ├── specs/
│ │ │ └── Launch.spec.js
│ │ └── utils.js
│ └── unit/
│ ├── index.js
│ ├── karma.conf.js
│ └── specs/
│ └── LandingPage.spec.js
└── tests/
├── builds/
│ └── .gitkeep
├── builds.json
├── scaffold.js
├── scaffold.sh
└── wine.sh
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/ISSUE_TEMPLATE.md
================================================
#### Found an issue or bug with electron-vue? Tell me all about it!
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.
##### Describe the issue / bug.
\#
##### How can I reproduce this problem?
\#
##### If visual, provide a screenshot.
\#
##### Tell me about your development environment.
* Node version:
* NPM version:
* vue-cli version: (if necessary)
* Operating System:
#### *If you are looking to suggest an enhancement or feature, then feel free to remove everything above.*
================================================
FILE: .gitignore
================================================
.idea
_book
thumbs.db
.DS_Store
node_modules
tests/builds/*
npm-debug.log
npm-debug.*.log
!.gitkeep
================================================
FILE: LICENSE.md
================================================
The MIT License (MIT)
Copyright (c) 2016 Greg Holguin
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.
================================================
FILE: README.md
================================================
The boilerplate for making electron applications built with vue (pretty much what it sounds like).
[](http://forthebadge.com) [](http://forthebadge.com) [](http://forthebadge.com)
[](https://github.com/feross/standard)
[](https://semaphoreci.com/simulatedgreg/electron-vue)
## Overview
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`, and some of the most used plugins like `vue-router`, `vuex`, and so much more.
#### Check out the detailed documentation [here](https://simulatedgreg.gitbooks.io/electron-vue/content/index.html).
Things you'll find in this boilerplate...
* Basic project structure with a **single** `package.json` setup
* Detailed [documentation](https://simulatedgreg.gitbooks.io/electron-vue/content/)
* Project scaffolding using [vue-cli](https://github.com/vuejs/vue-cli)
* 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)\)\*
* Installed [vue-devtools](https://github.com/vuejs/vue-devtools) and [devtron](https://github.com/electron/devtron) tools for development
* Ability to easily package your electron app using [electron-packager](https://github.com/electron-userland/electron-packager) or [electron-builder](https://github.com/electron-userland/electron-builder)\*
* `appveyor.yml` and `.travis.yml` configurations for automated deployments with [electron-builder](https://github.com/electron-userland/electron-builder)\*
* Ability to produce web output for browsers
* Handy [NPM scripts](https://simulatedgreg.gitbooks.io/electron-vue/content/en/npm_scripts.html)
* Use of [webpack](https://github.com/webpack/webpack) and [vue-loader](https://github.com/vuejs/vue-loader) with Hot Module Replacement
* Process restarting when working in main process
* HTML/CSS/JS pre-processor support with [vue-loader](https://github.com/vuejs/vue-loader/)
* ES6 with [`stage-0`](https://babeljs.io/docs/plugins/preset-stage-0/) by default
* Use of [`babili`](https://github.com/babel/babili) to remove the need of transpiling completely down to ES5
* ESLint \(with support for [`standard`](https://github.com/feross/standard) and [`airbnb-base`](https://github.com/airbnb/javascript)\)\*
* Unit Testing \(with Karma + Mocha\)\*
* End-to-end Testing \(with Spectron + Mocha\)\*
\*Customizable during vue-cli scaffolding
### Getting Started
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 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`.
```bash
# Install vue-cli and scaffold boilerplate
npm install -g vue-cli
vue init simulatedgreg/electron-vue my-project
# Install dependencies and run your app
cd my-project
yarn # or npm install
yarn run dev # or npm run dev
```
##### Are you a Windows User?
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.
##### Wanting to use Vue 1?
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)).
```bash
vue init simulatedgreg/electron-vue#1.0 my-project
```
### Next Steps
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.
## Made with electron-vue
Take a look at some of the amazing projects built with electron-vue. Want to have your own project listed? Feel free add your project to the bottom of the list below then submit a pull request.
* [**Surfbird**](https://github.com/surfbirdapp/surfbird): A Twitter client built on Electron and Vue
* [**Lulumi-browser**](https://github.com/qazbnm456/lulumi-browser): Lulumi-browser is a light weight browser coded with Vue.js 2 and Electron
* [**Space-Snake**](https://github.com/ilyagru/Space-Snake): A Desktop game built with Electron and Vue.js.
* [**Forrest**](https://github.com/stefanjudis/forrest): An npm scripts desktop client
* [**miikun**](https://github.com/hiro0218/miikun): A Simple Markdown Editor
* [**Dakika**](https://github.com/raj347/Dakika): A minute taking application that makes writing minutes a breeze
* [**Dynamoc**](https://github.com/ieiayaobb/dynamoc): Dynamoc is a GUI client for dynamodb-local, dynalite and AWS dynamodb
* [**Dockeron**](https://github.com/dockeron/dockeron): A dockeron project, built on Electron + Vue.js for Docker
* [**Easysubs**](https://github.com/matiastucci/easysubs): Download subtitles in a very fast and simple way
* [**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.
* [**Backlog**](https://github.com/czytelny/backlog): Simple app for storing TODOs, ideas or backlog items. You can organize them with boards. Sleek flow. Built with Electron + Vue.js + iView
* [**Opshell**](https://github.com/ricktbaker/opshell): Ops tool to make life easier working with AWS instances.
* [**GitHoard**](https://github.com/jojobyte/githoard): Hoard git repositories with ease.
* [**Data-curator**](https://github.com/ODIQueensland/data-curator): Share usable open data.
* [**Bookmark**](https://github.com/mrgodhani/bookmark): Desktop app to manage bookmarked links using Atom Electron and Vue.js
* [**Uber Run**](https://github.com/break-enter/uberrun): Simple automation desktop app to download and organize your tax invoices from Uber.
* [**Apollo**](https://github.com/helados/Apollo): Convert YouTube videos (and more) to .mp3 files
* [**Netsix**](https://github.com/pulsardev/netsix): Share videos with your friends in a real peer-to-peer manner using WebRTC.
* [**code-notes**](https://github.com/lauthieb/code-notes): A simple code snippet manager for developers built with Electron & Vue.js.
* [**Pomotroid**](https://github.com/Splode/pomotroid): A simple and visually-pleasing Pomodoro timer
* [**MarkText**](https://github.com/marktext/marktext): Mark Text is a realtime Markdown Editor.
* [**vue-design**](https://github.com/L-Chris/vue-design): the best website visualization builder with Vue and Electron
* [**ImapSync Client**](https://github.com/ridaamirini/ImapSyncClient): It's only an Internet Message Access Protocol Synchronization Client
* [**Hve**](https://github.com/hellohve/hve): A static blog client tool you may like.
* [**MarkdownFox**](https://github.com/lx4r/markdownfox): A simple Markdown viewer with auto update and PDF export.
* [**Smart DOCSE**](https://github.com/shirshak55/smart-docse): A generic app which ability to display news, contact etc.
* [**Cleaver**](https://getcleaver.com/): Cleaver helps you provision servers ready for deploying your web apps with zero downtime - for free!
* [**XPanel**](https://github.com/krustnic/xpanel): XAMPP control panel alternative built with Electron & Vue.js
* [**Hexo-Client**](https://github.com/gaoyoubo/hexo-client): A hexo client powered by electron-vue.
* [**YT.Downloader**](https://github.com/myazarc/ytdownloader): Youtube Video Downloader&Converter and Play Music, built with Electron & Vue.js.
* [**BMFont-JS**](https://github.com/elisaday/bmfont-js): BMFont-js is a bitmap font generator, built with Electron & Vue.js.
* [**YouGet**](https://github.com/ahmetzeybek/YouGet): YouGet - YouTube Video/Playlist Downloader/Cutter - MP3 Converter
* [**Asar UI**](https://github.com/myazarc/AsarUI): UI for Asar Pack, built with Electron & Vue.js.
* [**Leeze**](https://github.com/dayinji/Leeze): A Receipt Record App, built with Electron & Vue.js.
* [**IntelTracker**](https://github.com/hectate/inteltracker): An intel item tracker for players/speedrunners of NOLF.
* [**Metube**](https://github.com/kimyearho/MeTube): A program to manage your simple YouTube music player and enjoy your music
* [**it-tools**](https://github.com/TsaiKoga/it-tools): A programing helper for developers built with Electron & Vue.js.
* [**GifsWorld**](https://github.com/dj0nny/GifsWorld): Gifs finder built with Vue and Electron
================================================
FILE: book.json
================================================
{
"root": "./docs",
"plugins": [
"edit-link",
"theme-vuejs@git+https://github.com/pearofducks/gitbook-plugin-theme-vuejs.git",
"github",
"ga"
],
"pluginsConfig": {
"edit-link": {
"base": "https://github.com/SimulatedGREG/electron-vue/tree/master/docs",
"label": "Edit This Page"
},
"github": {
"url": "https://github.com/SimulatedGREG/electron-vue"
},
"ga": {
"token": "UA-64200901-3"
}
},
"links": {
"sharing": {
"facebook": false,
"twitter": true
}
}
}
================================================
FILE: docs/LANGS.md
================================================
* [English](en/)
* [日本語](ja/)
* [中文](cn/)
* [대한민국](ko/)
* [Português](pt_BR/)
================================================
FILE: docs/cn/README.md
================================================

> 基于 vue (基本上是它听起来的样子) 来构造 electron 应用程序的样板代码。
[](https://semaphoreci.com/simulatedgreg/electron-vue)
[](https://github.com/feross/standard)
[](http://forthebadge.com) [](http://forthebadge.com) [](http://forthebadge.com)
## 概要
该项目的目的,是为了要避免使用 vue 手动建立起 electron 应用程序。electron-vue 充分利用 `vue-cli` 作为脚手架工具,加上拥有 `vue-loader` 的 `webpack`、`electron-packager` 或是 `electron-builder`,以及一些最常用的插件,如`vue-router`、`vuex` 等等。
#### 在 [这里](https://simulatedgreg.gitbooks.io/electron-vue/content/index.html) 查看其文档。
你会在本样板代码中找到的东西...
* 基本的项目结构与 **单一的** `package.json` 设置
* 详细的 [文档](https://simulatedgreg.gitbooks.io/electron-vue/content/)
* 使用 [vue-cli](https://github.com/vuejs/vue-cli) 作为项目脚手架
* 立即可用的 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)\)\*
* 预装开发工具 [vue-devtools](https://github.com/vuejs/vue-devtools) 和 [devtron](https://github.com/electron/devtron)
* 使用 [electron-packager](https://github.com/electron-userland/electron-packager) 或 [electron-builder](https://github.com/electron-userland/electron-builder) 轻松打包你的应用程序\*
* `appveyor.yml` 与 `.travis.yml` 配置用于 [electron-builder](https://github.com/electron-userland/electron-builder) 的自动部署\*
* 能够生成用于浏览器的网页输出
* 便利的 [NPM 脚本](/npm_scripts.md)
* 使用携带模块热更新 (Hot Module Replacement) 的 [webpack](https://github.com/webpack/webpack) 和 [vue-loader](https://github.com/vuejs/vue-loader)
* 在工作在 electron 的 `main` 主进程时重启进程
* 支持使用 [vue-loader](https://github.com/vuejs/vue-loader/) 的 HTML/CSS/JS 预处理器
* 默认支持 [`stage-0`](https://babeljs.io/docs/plugins/preset-stage-0/) 的 ES6
* 使用 [`babili`](https://github.com/babel/babili) 避免完全反编译到 ES5
* ESLint \(支持 [`standard`](https://github.com/feross/standard) 和 [`airbnb-base`](https://github.com/airbnb/javascript)\)\*
* 单元测试 \(使用 Karma + Mocha\)\*
* 端到端测试 \(使用 Spectron + Mocha\)\*
\* 在`vue-cli`脚手架中可定制
### 起步
该样板代码被构建为 [`vue-cli`](https://github.com/vuejs/vue-cli) 的一个模板,并且包含多个选项,可以自定义你最终的脚手架程序。本项目需要使用 `node@^7` 或更高版本。electron-vue 官方推荐 [`yarn`](https://yarnpkg.org) 作为软件包管理器,因为它可以更好地处理依赖关系,并可以使用 `yarn clean` 帮助减少最后构建文件的大小。
```bash
# 安装 vue-cli 和 脚手架样板代码
npm install -g vue-cli
vue init simulatedgreg/electron-vue my-project
# 安装依赖并运行你的程序
cd my-project
yarn # 或者 npm install
yarn run dev # 或者 npm run dev
```
##### 你是一个 Windows 用户?
请务必查看 [**Windows 用户注意事项**](https://simulatedgreg.gitbooks.io/electron-vue/content/en/getting_started.html#a-note-for-windows-users) 来确保你拥有 electron 和其他依赖关系所需的所有必要构建工具。
##### 希望使用 Vue 1?
只需指向 `1.0` 分支即可。请注意,electron-vue 已经正式废除了 `vue@^1` 的使用,因此,这些更改也同样会反映到项目结构、功能和文档上 \([**遗留文档**](https://github.com/SimulatedGREG/electron-vue/tree/1.0/docs)\)。
```bash
vue init simulatedgreg/electron-vue#1.0 my-project
```
### 下一步
请务必查看 [这个文档](https://simulatedgreg.gitbooks.io/electron-vue/content/)。在这里,你将找到有关项目配置、项目结构和构建应用程序的有用信息。这里还有一个方便的 [常见问题](https://simulatedgreg.gitbooks.io/electron-vue/content/en/faqs.html) 的部分。
## 基于 electron-vue 的作品
看看一些基于 electron-vue 建造的了不起的的项目。想要在此列出你自己的项目吗?请随时提交 pull 请求。
* [**Surfbird**](https://github.com/surfbirdapp/surfbird): 一个基于 Electron 和 Vue 的 Twitter 客户端
* [**Lulumi-browser**](https://github.com/qazbnm456/lulumi-browser): Lulumi-browser 是一个轻量级的浏览器,基于 Vue.js 2 和 Electron
* [**Space-Snake**](https://github.com/ilyagru/Space-Snake): 使用 Electron 和 Vue.js 构建的桌面游戏。
* [**Forrest**](https://github.com/stefanjudis/forrest): 一个 npm 脚本的桌面客户端
* [**miikun**](https://github.com/hiro0218/miikun): 一个简单的 Markdown 编辑器
* [**Dakika**](https://github.com/Madawar/Dakika): 超省时的应用程序,使写作变得轻而易举
* [**Dynamoc**](https://github.com/ieiayaobb/dynamoc): Dynamoc 是一个 dynamodb-local、 dynalite 和 AWS dynamodb 的图形化界面客户端
* [**Dockeron**](https://github.com/dockeron/dockeron): Dockeron 项目, 基于 Electron + Vue.js 的 Docker 桌面客户端
* [**Easysubs**](https://github.com/matiastucci/easysubs): 快速简单地下载字幕
* [**Data-curator**](https://github.com/ODIQueensland/data-curator):分享可用的開放數據。
================================================
FILE: docs/cn/SUMMARY.md
================================================
# 概要
* [简介](./README.md)
* [起步](getting_started.md)
* [项目结构](project_structure.md)
* [文件树](file-tree.md)
* [渲染器进程](renderer-process.md)
* [主进程](main-process.md)
* [Webpack 配置](webpack-configurations.md)
* [开发](development.md)
* [入口 index.html](entry_indexhtml.md)
* [Vue 插件](vue_accessories.md)
* [NPM 脚本](npm_scripts.md)
* [CSS 框架的使用](using_css_frameworks.md)
* [预处理器的使用](using_pre-processors.md)
* [静态资源的使用](using-static-assets.md)
* [读写本地文件](savingreading-local-files.md)
* [建立你的应用](building_your_app.md)
* [electron-packager 的使用](using-electron-packager.md)
* [electron-builder 的使用](using-electron-builder.md)
* [测试](testing.md)
* [单元测试](unittesting.md)
* [端到端测试](end-to-end_testing.md)
* [更多](meta.md)
* [常见问题](faqs.md)
* [新版本](new-releases.md)
* [迁移指南](migration-guide.md)
* [贡献](contributing.md)
================================================
FILE: docs/cn/book.json
================================================
{
"root": ""
}
================================================
FILE: docs/cn/building_your_app.md
================================================
# 构建你的应用程序
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` 脚手架过程中,你会被问到你想要使用哪个构建器。
## [`electron-packager`](using-electron-packager.md)
如果你刚开始制作 electron 应用程序或只需要创建简单的可执行文件,那么 `electron-packager` 就可以满足你的需求。
## [`electron-builder`](using-electron-builder.md)
如果你正在寻找完整的安装程序、自动更新的支持、使用 Travis CI 和 AppVeyor 的 CI 构建、或本机 node 模块的自动重建,那么你会需要 `electron-builder`。
================================================
FILE: docs/cn/contributing.md
================================================
# 贡献
想要贡献你的力量?随时提交 pull 请求。在准备提交任何内容之前,请务必查看以下内容...
### JavaScript 标准规范
为确保所有 JS 代码遵循基本的 ***风格标准***,请务必遵循这些 [规则](http://standardjs.com/#rules)。
[](https://github.com/feross/standard)
================================================
FILE: docs/cn/development.md
================================================
# 开发
### 开始开发环境设置
在你使用 `yarn` 或 `npm install` 安装了依赖之后, 运行...
```bash
yarn run dev # 或者 npm run dev
```
...然后 轰! 现在,你就在运行一个 electron-vue 应用程序.

此样板代码附带了几个易于移除的登录页面组件。
================================================
FILE: docs/cn/end-to-end_testing.md
================================================
# 端对端测试
对于端到端测试,electron-vue 使用 [Spectron](http://electron.atom.io/spectron/) 和 测试框架 [Mocha](https://mochajs.org/) \(以及 [Chai](http://chaijs.com/)\)。Mocha 和 Chai 的 API (包括 `expect`、`should` 以及 `assert` 在内) 均在全局范围内可用。
### 运行测试
```bash
# 开始 Mocha
npm run e2e
```
##### 注意
在运行端到端测试之前,为了使 Spectron 在测试的时候可用,请调用 `npm run pack` 来创建一个产品构建。
### 文件结构
```
my-project
├─ test
| ├─ e2e
│ │ ├─ specs/
│ │ ├─ index.js
└─ └─ └─ utils.js
```
**在大多数情况下,你可以忽略** `index.js` **,只专注于编写** `specs/` **。**
#### `specs/`
这个目录里面是编写实际测试代码的地方。由于 `babel-register` 的强大功能,你可以完全依照 ES2015 进行编写。
#### `index.js`
这是 Mocha 入口文件,并收集加载在 `specs/` 内的所有测试代码用于测试。
#### `utils.js`
在这里,你会发现一些通用的函数,你可以在 `specs/` 中使用。其基本功能包括处理 electron 创建/销毁过程的 `beforeEach` 和 `afterEach`。
### 关于 Spectron
Spectron 是使用 [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/) 和 [WebDriverIO](http://webdriver.io/) 来操作 DOM 元素的 [electron](http://electron.atom.io) 官方测试框架。
#### WebDriverIO 的使用
如 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)\)。
================================================
FILE: docs/cn/entry_indexhtml.md
================================================
# 入口 `index.html`
在产品阶段,electron-vue 使用 [**`html-webpack-plugin`**](https://github.com/ampedandwired/html-webpack-plugin) 创建 `index.html`。在开发过程中,你将在 `src/` 目录中找到一个 `index.ejs`。在这里,你可以更改 HTML 入口文件。
如果你不熟悉这个插件的工作原理,那么我鼓励你看看它的 [文档](https://www.npmjs.com/package/html-webpack-plugin)。简而言之,这个插件会自动将产品阶段的资源(包括 `renderer.js` 和 `styles.css`)注入到最终压缩版的 `index.html` 中。
### 开发阶段的 `index.ejs`
```html
<%= htmlWebpackPlugin.options.title %>
<%= ... %>
```
### 产品阶段的 `index.html` \(非压缩版\)
```html
app
```
### 关于 CDNs 的使用
虽然使用 CDN 提供的资源有益于你的应用程序的最终版本的大小,但我建议不要使用它们。主要原因是,通过这样做,你其实是在假设你的应用程序始终可以访问互联网,而 Electron 应用程序并不总是如此。这成为使用 CSS 框架(如 bootstrap)的一个相当重要的问题,因为没有互联网,你的应用程序将迅速变得没有任何样式并且乱七八糟。
> “我不在乎,我还是想用CDN。”
如果你坚持使用 CDN,那么你仍可以通过将标签添加到 `src/index.ejs` 文件中达到目的。只是当你的应用程序处于离线模式时,请确保设置适当的 UI/UX 流程。
================================================
FILE: docs/cn/faqs.md
================================================
# 常见问题
* [为什么运行 `npm run dev` 之后我的 electron 应用程序是空白的?](#why-is-my-electron-app-blank-after-running-npm-run-dev)
* [为什么我的 electron 程序显示了文件浏览器?](#why-does-my-electron-app-show-a-file-explorer)
* [为什么没有 `vue-devtools` 或 `devtron`?](#why-is-vue-devtoolsdevtron-missing)
* [在哪里放置我的静态资源?](#where-do-i-put-static-assets)
* [为什么 `npm run lint` 会出现错误?](#why-did-npm-run-lint-end-with-an-error)
* [为什么我无法在网页浏览器中加载应用程序?](#why-cant-i-load-my-app-in-a-web-browser)
* [如何导入 `jquery`?](#how-do-import-jquery)
* [如何调试 `main` 进程?](#how-can-i-debug-the-main-process)
---
## 为什么运行 `npm run dev` 之后我的 electron 程序是空白的?
#### 简要
请确认你没有设置可能篡改 `webpack-dev-server` 的个人 **代理**。
## 为什么我的 electron 程序显示了文件浏览器?
#### 简要
你的 `src/renderer` 包含错误。请检查 控制台 (console),修复错误,然后用 `CommandOrControl+R` 刷新 electron。
##### 详述
如果你的 `src/renderer` 中出现错误,则会在首次运行时与 ESLint 产生冲突。接着,一个无效的 webpack 的 `renderer.js` 会被生成出来,它会打断 `HtmlWebpackPlugin` 创建 `index.html`。由于 `webpack-dev-server` 没有 `index.html` 可以提供服务,所以服务器失败,程序返回到文件浏览器。
## 为什么没有 `vue-devtools` 或 `devtron`?
如果缺少 `vue-devtools` 或 `devtron`,请确保首次启动时,关闭并重新打开开发者工具面板。另外,请检查你的终端,检查是否在安装过程中有任何可能的错误消息。
## 在哪里放置我的静态资源?
[**静态资源的使用**](using-static-assets.md)
## 为什么 `npm run lint` 会出现错误?
eslint 的默认属性是将控制台的错误打印出来,如果发现脚本以非零值退出结束时 \(它会产生 npm 错误\)。这是正常的行为。
## 为什么我无法在网页浏览器中加载应用程序?
[\#195](https://github.com/SimulatedGREG/electron-vue/issues/195)
## 如何导入 `jquery`?
如果你想使用 `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)。
## 如何调试 `main` 进程?
当使用 `electron@^1.7.2` 时,你可以打开 Google Chrome,然后转到 `chrome://inspect`,在应用程序以开发模式运行时,弹出远程的 electron 进程。
[Electron 文档](https://github.com/electron/electron/blob/master/docs/tutorial/debugging-main-process.md)
================================================
FILE: docs/cn/file-tree.md
================================================
# 文件树
### 在开发过程中
**注意**: 某些文件或文件夹可能会根据在 `vue-cli` 脚手架中所选设置的不同而有所不同。
```
my-project
├─ .electron-vue
│ └─ .js files
├─ build
│ └─ icons/
├─ dist
│ ├─ electron/
│ └─ web/
├─ node_modules/
├─ src
│ ├─ main
│ │ ├─ index.dev.js
│ │ └─ index.js
│ ├─ renderer
│ │ ├─ components/
│ │ ├─ router/
│ │ ├─ store/
│ │ ├─ App.vue
│ │ └─ main.js
│ └─ index.ejs
├─ static/
├─ test
│ ├─ e2e
│ │ ├─ specs/
│ │ ├─ index.js
│ │ └─ utils.js
│ ├─ unit
│ │ ├─ specs/
│ │ ├─ index.js
│ │ └─ karma.config.js
│ └─ .eslintrc
├─ .babelrc
├─ .eslintignore
├─ .eslintrc.js
├─ .gitignore
├─ package.json
└─ README.md
```
#### 产品构建
```
app.asar
├─ dist
│ └─ electron
│ ├─ static/
│ ├─ index.html
│ ├─ main.js
│ └─ renderer.js
├─ node_modules/
└─ package.json
```
可以说,几乎所有的东西都在最终的产品构建中被删除。在分发 electron 应用程序时,这几乎是强制性的,因为你不希望用户下载拥有庞大文件的臃肿的软件。
================================================
FILE: docs/cn/getting_started.md
================================================
# 起步
## 脚手架
该样板代码被构建为 [`vue-cli`](https://github.com/vuejs/vue-cli) 的一个模板,并且包含多个选项,可以自定义你最终的脚手架程序。本项目需要使用 `node@^7` 或更高版本。electron-vue 官方推荐 [`yarn`](https://yarnpkg.org) 作为软件包管理器,因为它可以更好地处理依赖关系,并可以使用 `yarn clean` 帮助减少最后构建文件的大小。
```bash
# 安装 vue-cli 和 脚手架样板代码
npm install -g vue-cli
vue init simulatedgreg/electron-vue my-project
# 安装依赖并运行你的程序
cd my-project
yarn # 或者 npm install
yarn run dev # 或者 npm run dev
```
#### 关于 electron
虽然是可选的,仍旧我们建议在创建项目之后锁定你 electron 的版本。这样可以防止在同一项目上工作的其他开发者使用不同的版本进行开发。electron 经常发布新版本,所以一些功能特性总是会发生相应的变化。[更多信息](http://electron.atom.io/docs/tutorial/electron-versioning/)。
#### Windows 用户注意事项
如果在 `npm install` 期间遇到关于 `node-gyp` 的错误,那么你很有可能没有在你的系统上安装正确的构建工具。构建工具包括 Python 和 Visual Studio 等等。感谢 [@felixrieseberg](https://github.com/felixrieseberg),有几个软件包可以帮助简化此过程。
我们需要检查的第一项是 npm 的版本,并确保它是最新的。这个可以使用 [`npm-windows-upgrade`](https://github.com/felixrieseberg/npm-windows-upgrade) 来完成。如果你使用 `yarn`,则可以跳过此项检查。
若上一项检查完成,我们可以继续设置所需的构建工具。使用 [`windows-build-tools`](https://github.com/felixrieseberg/windows-build-tools) 来为我们完成大部分烦人的工作。全局安装此工具将依次设置 Visual C++ 软件包、Python 等等。
到现在为止,所有工具都应该成功安装了,如果没有,那么你就会需要安装一个干净的 Visual Studio。请注意,这些并不是 electron-vue 自身的问题 \(Windows 有时候可能会很难用 ¯\\\_\(ツ\)\_/¯\)。
================================================
FILE: docs/cn/global_configuration.md
================================================
# Global Configuration
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`.
#### `config.js`
**Note**: Some options may differ based on the settings choosen during `vue-cli` scaffolding.
```js
{
// Name of electron app
// Will be used in production builds
name: 'app',
// Use ESLint
// Further changes can be made in `.eslintrc.js`
eslint: true,
// webpack-dev-server port
port: 9080,
// electron-packager options
// See `Building you app` for more info
building: {
arch: 'x64',
asar: true,
dir: path.join(__dirname, 'app'),
icon: path.join(__dirname, 'app/icons/icon'),
ignore: /\b(src|index\.ejs|icons)\b/,
name: pkg.name,
out: path.join(__dirname, 'builds'),
overwrite: true,
platform: process.env.PLATFORM_TARGET || 'all'
}
}
```
================================================
FILE: docs/cn/main-process.md
================================================
# 主进程
> 在 Electron 中,运行 package.json 主脚本的过程称为主进程 (main process)。在主进程中运行的脚本可以通过创建网页来显示其图形化界面。
**摘自** [**Electron 文档**](http://electron.atom.io/docs/tutorial/quick-start/#main-process)
---
由于 `main` 进程本质上是一个完整的 node 环境,所以除了以下两个文件之外,并没有什么初始的项目结构。
#### `src/main/index.js`
这个文件是你应用程序的主文件,`electron` 也从这里启动。它也被用作 `webpack` 产品构建的入口文件。所有的 `main` 进程工作都应该从这里开始。
#### `app/src/main/index.dev.js`
这个文件专门用于开发阶段,因为它会安装 `electron-debug` 和 `vue-devtools`。一般不需要修改此文件,但它可以用于扩展你开发的需求。
## 关于 `__dirname` 与 `__filename` 的使用
由于 `main` 进程是使用 `webpack` 来绑定的,所以使用 `__dirname` 和 `__filename` **将不会** 在产品阶段给你提供一个预期的值。若参考 [**文件树**](/file-tree.md) 你会注意到,在产品阶段,`main.js` 被放在了 `dist/electron` 文件夹里面。应根据此点相应地使用 `__dirname` 和 `__filename`。
**如果你需要 `static/` 资源目录的路径,请务必阅读** [**使用静态资源**](/using-static-assets.md) **学习了解非常方便的 `__static` 变量。**
```
app.asar
├─ dist
│ └─ electron
│ ├─ static/
│ ├─ index.html
│ ├─ main.js
│ └─ renderer.js
├─ node_modules/
└─ package.json
```
================================================
FILE: docs/cn/meta.md
================================================
# 更多
### 感谢
哇,非常感谢你们的帮助,使得 electron-vue 在 GitHub 上成为(我可以找到的)前 3 名 `vue-cli` 模板之一。我从来没有想过这个项目会像今天一样脱颖而出。回想过去,我起初(在 **2016年5月**)做了这个样板只是为个人的闭源项目。当我知道我已经完成了大部分的代码之后,我决定开源(样板本身)。转到今天,项目里已经有了这么多新的功能,并且得到了社区的大力支持。我也想给社区的人们一些特别的话,你们帮助我解决了一些我无法解决的问题。你们绝对没有任何义务去做任何事情,但是你们还是这么做的,我很感激。
如果你正在阅读这篇文章,那我几乎可以假设你真的很喜欢 electron-vue。我花了很多时间在创建这个样板上。如果你愿意的话,请自愿留下一些小费。electron-vue 未来的发展肯定不会依赖于这些捐赠,但如果你决定捐赠,它总是一个可以的选择。
#### [**使用 PayPal.me 进行转账**](https://www.paypal.me/simulatedgreg/5)
================================================
FILE: docs/cn/migration-guide.md
================================================
# 迁移指南
本文档尝试解释 _应该_ 如何实现你的项目迁移,但是由于整体项目结构始终可能变化,因此,这可能不是一个完整验证过的方法。
1. 使用 `vue init simulatedgreg/electron-vue my-project` 生成一个崭新的 electron-vue 项目
2. 将当前项目 `src` 内的文件复制到新项目的 `src` 目录中
3. 将 `package.json` 里的依赖关系从当前项目复制到新项目的 `package.json` 里
4. 使用 `yarn` 或 `npm install` 安装依赖
5. 在开发模式下运行项目 \(`yarn run dev` 或 `npm run dev`\)
6. 监视控制台以修复可能出现的错误
正如前面提到的,并没有一个完整验证过的方法来迁移到一个新的项目,但上述这些步骤,通常是可以让你成功完成迁移。任何对项目结构或资源处理的私自修改,将依靠你或你的团队来完成迁移。请确保查看文档的其余部分,因为它将始终反映 electron-vue 当前版本的 `master` 分支。
================================================
FILE: docs/cn/miscellaneous.md
================================================
================================================
FILE: docs/cn/new-releases.md
================================================
# 新版本
electron-vue 自 2016年5月初 创建以来有了很大的发展,并引入了许多新奇的功能。你能相信有一段时间该项目还不支持 `vue-cli` 脚手架吗?新功能的开发计划不会停止。唯一的缺点是,每天都有华而不实的东西存在,进而把你的项目卡在一个老的脚手架上。尽管 electron-vue 利用了 `vue-cli` 的优势,遗憾的是,并没有一个结构化的方式来 _版本化_ (_version_) 样板 或 使其变得 _可更新_ (_updatable_)。
electron-vue 的主要更新将通过 GitHub 的 里程碑 (Milestones) 进行,并将包含许多新的功能和错误的修复,这使得这些版本成为了最佳的 [迁移](/migration-guide.md) 契机,用来从任何现有项目转换为较新的架构。这些里程碑通常不是预先计划的,而是随着问题提交里的功能请求,在追踪问题的时候加上去的。
### 之前的里程碑
#### [复用](https://github.com/SimulatedGREG/electron-vue/milestone/1?closed=1)
* 迁移到 `webpack` 2
* 支持 `electron-builder`
* 支持 `main` 进程的捆绑
* 一般的错误修复
#### [简化](https://github.com/SimulatedGREG/electron-vue/issues/171)
* 迁移到单一的 `package.json` 结构
* 针对 `electron-builder` 用户的 Travis CI / AppVeyor 配置
* `renderer` 进程的最小化网页输出
* 迁移到 `axios`
* 完全支持 `main` 进程捆绑
* 重写开发和构建的脚本
* 迁移到 `babili` 以避免完全反编译到 ES5
* 在使用需要完整路径 \([`__static`](/using-static-assets.md)\) 的模块时支持 `static/` 资源
================================================
FILE: docs/cn/npm_scripts.md
================================================
# NPM 脚本
为了帮助你消除开发过程中的冗余任务,请注意一些可用的 NPM 脚本。以下命令应该运行在项目的根目录下。当然,你可以使用 `yarn run ` 的方式运行下列任何命令。
### `npm run build`
为了产品和打包来构建你的应用程序。更多信息可以在 [**构建你的应用程序**](building_your_app.md) 部分找到。
### `npm run dev`
在开发环境中运行程序
### `npm run lint`
静态分析所有在 `src/` 和 `test/` 下面的 JS 以及 Vue 组件文件。
### `npm run lint:fix`
静态分析所有在 `src/` 和 `test/` 下面的 JS 以及 Vue 组件文件并且尝试修复问题。
### `npm run pack`
同时运行 `npm run pack:main` 和 `npm run pack:renderer`。 虽然这些命令是可用的,但很少情况下,你需要手动执行此操作,因为 `npm run build` 将处理此步骤。
### `npm run pack:main`
运行 webpack 来打包 `main` 进程的源代码。
### `npm run pack:renderer`
运行 webpack 来打包 `renderer` 进程的源代码。
### `npm run unit`
运行使用了 Karma + Jasmine 的单元测试。更多信息请见 [**单元测试**](unittesting.md)。
### `npm run e2e`
运行使用了 Spectron + Mocha 的端对端测试。更多信息请见 [**端对端测试**](unittesting.md)。
### `npm test`
运行 `npm run unit` 和 `npm run e2e`. 更多信息请见 [**测试**](unittesting.md)。
================================================
FILE: docs/cn/project_structure.md
================================================
# 项目结构
当涉及制作 electron 应用程序的问题时,项目结构会有些不同。如果你以前使用过官方的 [`vuejs-templates/webpack`](https://github.com/vuejs-templates/webpack) 设置,那么你对这个结构应该很熟悉。本文档在此章节将尝试解释样板代码的工作原理以及应用程序在构建中的一些区别。
### 单一的 `package.json` 设置
就在不久之前,两个 `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` 设置。
#### `dependencies`
这些依赖项 **将会被** 包含在你最终产品的应用程序中。所以,如果你的应用程序需要某个模块才能运行,那么请在此安装!
#### `devDependencies`
这些依赖项 **不会被** 包含在你最终产品的应用程序中。在这里,你可以安装专门用于开发的模块,如构建脚本、`webpack` 加载器等等。
#### 安装原生 NPM 模块
我们需要确保我们本地的 npm 模块是针对 electron 来构建的。为了做到这一点,我们可以使用 [`electron-rebuild`](https://github.com/electron/electron-rebuild),但是为了使事情变得更简单,我们强烈建议使用 [`electron-builder`](https://github.com/electron-userland/electron-builder) 作为你的构建工具,因为它会为你处理很多任务。
### 关于 `main` 进程
在开发过程中,你可能会注意到 `src/main/index.dev.js`。该文件专门用于开发以及安装开发工具。原则上,该文件不应该被修改,但是可以被用来扩展你的开发需求。在构建的过程中,`webpack` 将介入其中并创建一个的捆绑,以 `src/main/index.js` 作为该捆绑的入口文件。
================================================
FILE: docs/cn/renderer-process.md
================================================
# 渲染器进程
> 由于 Electron 使用 Chromium 显示网页,那么,Chromium 的多进程架构也被使用。Electron 中的每个网页都在自己的进程中运行,称为渲染器进程 (renderer process)。
>
> 在正常的浏览器中,网页通常运行在沙盒封装化的环境中,并且不允许访问本机资源。然而,Electron 用户有权在网页中使用 Node.js 的 API,从而允许较低级别的操作系统交互。
**选自** [**Electron 文档**](http://electron.atom.io/docs/tutorial/quick-start/#renderer-process)
---
## 关于 `vue` 和 `vuex`
### vue 组件
如果你不熟悉 Vue 组件,请阅读 [此处](http://vuejs.org/v2/guide/single-file-components.html)。组件的使用使我们大型、复杂的应用程序更加有组织化。每个组件都有能力封装自己的 CSS、模板 和 JavaScript 的功能。
组件存放在 `src/renderer/components` 里。创建子组件时,一个常用的组织化实践是将它们放置在一个使用其父组件名称的新文件夹中。在协调不同的路由时,这一点特别有用。
```
src/renderer/components
├─ ParentComponentA
│ ├─ ChildComponentA.vue
│ └─ ChildComponentB.vue
└─ ParentComponentA.vue
```
### vue 路由
有关 `vue-router` 的更多信息请点击 [这里](https://github.com/vuejs/vue-router)。 简而言之,我们鼓励使用 `vue-router`,因为创建 单页应用程序 (Single Page Application) 在制作 electron 程序的时候更加实用。你真的想管理一堆 BrowserWindows,然后在其之间传达信息吗?恐怕不会。
路由被保存在 `src/renderer/router/index.js` 里并定义如下...
```js
{
path: '',
name: '',
component: require('@/components/View')
}
```
... 其中 `` 和 `` 都是变量。然后,这些路由使用 `src/renderer/App.vue` 的 `` 指令附加到组件树上。
##### 注意
在使用 `vue-router` 时,不要使用 [**HTML5 历史模式**](http://router.vuejs.org/en/essentials/history-mode.html)。 此模式严格用于通过 `http` 协议提供文件,并且不能正常使用 `file` 协议,但是 electron 在产品构建中使用此协议提供文件。默认的 `hash` 模式正是我们所需要的。
### vuex 模块
描述 `vuex` 并不是简单的事情,所以请阅读 [这里](https://vuex.vuejs.org/zh/),以便更好地了解它试图解决的问题及其工作原理。
electron-vue 利用 `vuex` 的模块结构创建多个数据存储,并保存在 `src/renderer/store/modules` 中。
拥有多个数据存储对于组织化来说可能很好,但你必须导入每一个数据,这也可能令人厌烦。但是不要担心,因为 `src/renderer/store/modules/index.js` 帮我们处理了这些麻烦事!这个简单的脚本让 `src/renderer/store/index.js` 一次性导入我们所有的模块。如果所有这些都没有,只要知道你可以轻松地复制给定的 `Counter.js` 模块,它将以 "神奇" 的方式被加载进来。
================================================
FILE: docs/cn/savingreading-local-files.md
================================================
# 读写本地文件
使用 `electron` 的一大好处是可以访问用户的文件系统。这使你可以读取和写入本地系统上的文件。为了避免 Chromium 的限制以及对应用程序内部文件的改写,请确保使用 `electron` 的 API,特别是 [`app.getPath(name)`](https://electron.atom.io/docs/api/app/#appgetpathname) 函数。这个帮助函数可以使你获得指向系统目录的文件路径,如用户的桌面、系统临时文件 等等。
### 使用案例
假设我们想为我们的应用程序提供本地的数据库存储。在这个例子中,我们将用 [`nedb`](https://github.com/louischatriot/nedb) 作为演示。
```bash
yarn add nedb # 或 npm install nedb --save
```
**src/renderer/datastore.js**
这里,我们设置 NeDB 并将其指向我们的 `userData` 目录。这个空间专门为我们的应用程序所保留,所以,我们可以确信,其他程序 或 与其他用户的交互不应该篡改这个文件空间。至此,我们可以在 `renderer` 进程中导入 `datastore.js` 并使用它。
```js
import Datastore from 'nedb'
import path from 'path'
import { remote } from 'electron'
export default new Datastore({
autoload: true,
filename: path.join(remote.app.getPath('userData'), '/data.db')
})
```
**src/renderer/main.js**
为了更进一步,我们可以将数据存储导入到 `src/renderer/main.js` 里,并将其附加到 Vue 的 原型 (prototype) 上。通过在所有组件文件中使用 `this.$db`,我们现在可以访问数据存储的 API。
```js
import db from './datastore'
/* 其它代码 */
Vue.prototype.$db = db
```
================================================
FILE: docs/cn/testing.md
================================================
# 测试
因受到了官方样板代码 `vuejs-templates/webpack` 提供的测试功能的极大启发,electron-vue 同时支持单元测试和 `renderer` 进程的端到端测试。在 `vue-cli` 脚手架中,你可以选择是否包含测试。
## [单元测试](unittesting.md)
使用 Karma + Mocha 运行单元测试
```bash
npm run unit
```
## [端对端测试](end-to-end_testing.md)
使用 Spectron + Mocha 运行端对端测试
```bash
npm run e2e
```
## 运行所有测试
```bash
npm test
```
### 关于 CI 测试
如果在脚手架时你决定使用 `electron-builder` 作为构建工具,那么你可以在针对 `darwin`、`linux` 和 `win32` 的 Travis CI 以及 AppVeyor 上轻松测试你的程序。在 `.travis.yml` 和 `appveyor.yml` 两者之间,你会发现一些被注释掉的部分,你可以快速取消注释以启用测试。确保阅读 [**使用 CI 的自动化部署**](using-electron-builder.md#automated-deployments-using-ci) 上的更多信息。
================================================
FILE: docs/cn/unittesting.md
================================================
# 单元测试
对于进行单元测试,electron-vue 使用 [Karma](https://karma-runner.github.io/1.0/index.html) 作为测试的运行器,使用 [Mocha](https://mochajs.org/) \(与 [Chai](http://chaijs.com/)\ 作为测试框架。
Mocha 和 Chai 分别使用 `karma-mocha` 和 `karma-chai` 进行集成,所以所有的 API(例如 `expect`)都可以在测试文件中全局使用。
### 运行测试
```bash
# 开始 Karma
npm run unit
```
### 文件结构
```
my-project
├─ test
| ├─ unit
│ │ ├─ specs/
│ │ ├─ index.js
└─ └─ └─ karma.conf.js
```
**在大多数情况下,你可以忽略** `index.js` **和** `karma.conf.js` **,只专注于编写** `specs/` **。**
#### `specs/`
这个目录里面是编写实际测试代码的地方。由于 Webpack 的强大功能,你可以完全依照 ES2015 和 其支持的加载程序编写。
#### `index.js`
这是 `karma-webpack` 使用的入口文件。该文件的目的是一次性收集加载所有的测试和源代码。
#### `karma.conf.js`
在这里,你可以找到实际的 `karma` 配置,并使用 spec/coverage 记录器进行设置。你可以根据 [karma 官方文档](http://karma-runner.github.io/1.0/config/configuration-file.html) 进一步定制。
### Mocking Dependencies
electron-vue 默认安装 [`inject-loader`](https://github.com/plasticine/inject-loader)。有关使用 Vue 组件文件的信息,请参阅 [`vue-loader' 的测试与仿真文档](http://vue-loader.vuejs.org/en/workflow/testing-with-mocks.html)。
================================================
FILE: docs/cn/using-electron-builder.md
================================================
# [`electron-builder`](https://github.com/electron-userland/electron-builder) 的使用
所有 `electron-builder` 生成的文件都可以在 `build` 文件夹中找到。
#### 构建
```bash
npm run build
```
#### 构建未打包的目录
生成简单的可执行文件,没有完整的安装程序。用于快速测试。
```bash
npm run build:dir
```
### 默认的构建配置
可以在 `package.json` 中使用基于 `electron-builder` 的 [各种选项](https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options) 进行进一步定制。
```js
"build": {
"productName": "ElectronVue",
"appId": "org.simulatedgreg.electron-vue",
"dmg": {
"contents": [
{
"x": 410,
"y": 150,
"type": "link",
"path": "/Applications"
},
{
"x": 130,
"y": 150,
"type": "file"
}
]
},
"directories": {
"output": "build"
},
"files": [
"dist/electron",
"node_modules/",
"package.json"
],
"mac": {
"icon": "build/icons/icon.icns"
},
"win": {
"icon": "build/icons/icon.ico"
},
"linux": {
"icon": "build/icons"
}
}
```
## 使用 CI 的自动化部署
当使用 electron-vue 的 `electron-builder` 配置时,本项目还提供了用于自动部署的 `appveyor.yml` 和 `.travis.yml`。两个配置文件都被设置好了用于构建你的 electron 应用,并将生成的程序推送到 GitHub 的发布页面、Bintray 等。Travis CI 用于构建 `linux` 和 `darwin` \(macOS\),而 AppVeyor 用于构建 `win32`。这两项服务都是免费的 OSS 项目。
#### 设置 Travis CI 和 AppVeyor
1. 在 [Travis CI](https://travis-ci.org/getting_started) 或 [AppVeyor](https://www.appveyor.com/) 上创建一个帐户
2. 链接到你 electron-vue 项目的 GitHub 仓库
3. 访问 [https://github.com/settings/tokens](https://github.com/settings/tokens) 并点击 **生成新令牌 (Generate new token)** \(同样的令牌可用于 Travis CI 和 AppVeyor 二者\)
1. 设置一个 **令牌描述 (Token description)**
2. 检查 **public\_repo** 的范围
3. 点击 **生成令牌 (Generate token)**
4. 复制你的新令牌并保存以备以后使用
5. 打开 Travis CI 或 AppVeyor 上的仓库设置选项,添加一个新的 **环境变量 (Environment Variable)**
1. 将变量的名称设置为 `GH_TOKEN`
2. 将变量的值设置为刚刚创建的 GitHub 的访问令牌
3. **保存 (Save)** 新变量并确保加密措施已启用
现在,所有的事情应该都配置完毕了。Travis CI / AppVeyor 在默认情况下会监测到任何到你的 `master` 分支的推送。推送完毕后,Travis CI / AppVeyor 将克隆你的仓库到其服务器并开始构建过程。在最后阶段,`electron-builder` 可以看到环境变量 `GH_TOKEN`,并创建一个发布草稿,并将生成的程序上传到你公共的 GitHub 仓库上。现在,你可以编辑发布草稿,然后发布出去。发布了发行版后,通过更新你的 `package.json`,你可以确保将来的版本标上新版本号。
#### 自动更新
启用你应用程序自动更新的接收选项是一个超级好用的功能,但要知道你必须要有 [**代码签名 (Code Signing)**](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` 底部的代码以启用自动更新。
如果你像大多数人一样,并且没有花哨的代码签名证书,那么你可以随时使用 GitHub API 来检查新的软件发布。当检测到新版本时,你的应用程序会提供一条通知,导向用户可以下载并安装新版本的下载页面。由于 `electron-builder` 提供的了不起的安装程序,用户无需卸载当前版本,新的安装将替代旧的版本,同时仍然保留任何 Web 存储或 `userData` 文件。
================================================
FILE: docs/cn/using-electron-packager.md
================================================
# [`electron-packager`](https://github.com/electron-userland/electron-packager) 的使用
所有 `electron-packager` 生成的文件都可以在 `build` 文件夹中找到。
#### 针对所有平台的构建
请注意,并非所有操作系统都可以为所有其他平台进行构建。
```bash
npm run build
```
#### 针对特定平台的构建
平台包括 `darwin`、 `mas`、 `linux` 和 `win32`。
```bash
# build for darwin (macOS)
npm run build:darwin
```
#### 清除
从 `build` 删除所有的构建文件。
```bash
npm run build:clean
```
### 非 Windows 用户注意事项
如果你想在非 Windows 平台上为 Windows 构建时 **使用自定义图标**,你必须安装 [wine](https://www.winehq.org/)。[更多信息](https://github.com/electron-userland/electron-packager#building-windows-apps-from-non-windows-platforms)。
### 默认的构建配置
可以在 `.electron-vue/build.config.js` 中使用基于 `electron-packager` 的 [各种选项](https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options) 进行进一步定制。你可以设置 `package.json` 里的 `productName` 来设置构建后的程序名称。
```js
{
// 针对 'x64' 架构
arch: 'x64',
// 使用 'electron/asar' 压缩应用
asar: true,
// 应用程序的目录
dir: path.join(__dirname, '../'),
// 设置 electron 程序的图标
// 基于平台添加文件的扩展
//
// 如果针对 Linux 进行构建, 请阅读
// https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#icon
icon: path.join(__dirname, '../build/icons/icon'),
// 忽略可能造成最后程序很大的文件
ignore: /(^\/(src|test|\.[a-z]+|README|yarn|static|dist\/web))|\.gitkeep/,
// 把构建结果存储到 `builds`
out: path.join(__dirname, '../build'),
// 重写现有构建
overwrite: true,
// 指定平台的环境变量
platform: process.env.BUILD_TARGET || 'all'
}
```
================================================
FILE: docs/cn/using-static-assets.md
================================================
# 静态资源的使用
如果你以前使用过官方的 `vuejs-templates/webpack` 样板,那么你应该对 `static/` 目录很熟悉。这里面,你可以放置可供 `main` 和 `renderer` 进程使用的静态资源。在 Vue 应用程序中使用这些资源很简单,但是使用 `fs` 和其他需要完整路径的模块可能会有点棘手。 幸运的是,electron-vue 提供了一个 `__static` 变量,它可以在开发和产品阶段生成 `static/` 目录的路径。
### Vue 组件里 `src` 标签的使用案例
假设我有一个组件需要下载一个图像,但是直到一些其他任务完成后这个图像的地址才能知道。简单起见,让我们用一个 `data` 变量来绑定图像的来源。
**SomeComponent.vue**
```html
```
此处,`webpack` 并不会捆绑图像 `unsplash.png`,并且应用程序可以看到 `static/imgs/unsplash.png` 目录里的资源。感谢 `vue-loader` 为我们完成了所有繁琐的工作。
### JS 搭配 `fs`、`path` 和 `__static` 的使用案例
假设我们有一个静态资源,我们需要使用 `fs` 将它读入到我们的应用程序中,但是我们如何在开发和产品阶段为 `static/` 目录获得可靠的路径呢?electron-vue 提供了一个名为 `__static` 的全局变量,它将产生一个指向 `static/` 目录的正确路径。以下是我们在开发和产品阶段如何使用它读取一个简单的文本文件。
**static/someFile.txt**
```txt
foobar
```
**SomeFile.js \(** `main` **或** `renderer` **进程\)**
```js
import fs from 'fs'
import path from 'path'
let fileContents = fs.readFileSync(path.join(__static, '/someFile.txt'), 'utf8')
console.log(fileContents)
// => "foobar"
```
请注意,在产品阶段,默认情况下,所有文件都包含 [`asar`](https://github.com/electron/asar),因为它是被极力推荐的。因此,`static/` 文件夹中的资源只能在 `electron` 内部访问,因为只有 `electron` 了解此行为。由此,如果你打算将文件分发给用户,例如在外部程序中打开文件,那么,首先你需要将这些资源从应用程序复制到用户的文档空间或桌面中。从那里,你可以使用 electron 的 API [`shell.openItem()`](https://electron.atom.io/docs/api/shell/#shellopenitemfullpath) 来打开这些资源。
这种情况的一种替代方法,是配置 `electron-packager` 或 `electron-builder`,设置特定文件,用来 “解压缩” 在产品阶段的 `asar` 存档。electron-vue 并没有计划支持这种方法; 任何与此或与如何设定此事项相关的问题将被关闭。
================================================
FILE: docs/cn/using_css_frameworks.md
================================================
# CSS 框架的使用
虽然这可能看起来并不明智,但我建议你使用 [`style-loader`](https://github.com/webpack/style-loader) 将第三方 CSS 库导入 webpack,其实这一点我们已经为你做了。
## 使用案例
假设你要为你的程序使用 [bootstrap](http://getbootstrap.com/)、[bulma](http://bulma.io/) 或者 [materialize](http://materializecss.com/)。你可以仍旧像通常情况下一样,从 `npm` 安装你的库,而不是将资源附加到 `index.ejs` 上,我们将在我们的 JavaScript 中导入 CSS,具体在 `src/renderer/main.js` 中。
#### 例子
让我们安装 `bulma` 如下
```bash
npm install bulma --save
```
然后,在 `src/renderer/main.js` 里面加入这一行:
```bash
import 'bulma/css/bulma.css'
```
替代方案是, 你也可以在你的组件文件中引用 `bulma`。
**App.vue**
```html
```
现在,`webpack` 会为我们的应用程序加载 `bulma`,并使其在产品构建中可用.
================================================
FILE: docs/cn/using_pre-processors.md
================================================
# 预处理器的使用
将 [`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) 相关的详细信息。
## 使用案例
假设我们需要使用 Sass/SCSS 来预处理我们的 CSS。首先,我们需要安装正确的 `webpack` 加载器来处理这种语法。
#### 安装 `sass-loader`
```bash
npm install --save-dev sass-loader node-sass
```
一旦安装了我们需要的加载器,一切就都差不多完成了。`vue-loader` 将神奇地做好其余的工作。现在我们可以轻松地将 `lang="sass"` 或 `lang="scss"` 添加到我们的 Vue 组件文件中。注意,我们还安装了 `node-sass`,因为它是 `sass-loader` 的依赖包。
#### 应用 `lang` 属性
所以...
```html
```
... 现在变成了 ...
```html
```
相同的原理适用于任何其他预处理器。那么,也许你的 JS 需要 coffeescript?只需安装 [coffeescript-loader](https://github.com/webpack/coffee-loader),并将属性 `lang=“coffeescript”` 应用到你的 `