├── .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
├── images
│ ├── landing-page.jpg
│ └── logo.png
├── 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
│ │ ├── 256x256.png
│ │ ├── icon.icns
│ │ └── icon.ico
├── dist
│ ├── electron
│ │ └── .gitkeep
│ └── web
│ │ └── .gitkeep
├── package.json
├── src
│ ├── index.ejs
│ ├── main
│ │ ├── index.dev.js
│ │ └── index.js
│ └── renderer
│ │ ├── App.vue
│ │ ├── assets
│ │ ├── .gitkeep
│ │ └── logo.png
│ │ ├── components
│ │ ├── LandingPage.vue
│ │ └── LandingPage
│ │ │ └── SystemInformation.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.json
├── builds
└── .gitkeep
├── scaffold.js
├── scaffold.sh
└── wine.sh
/.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 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/LANGS.md:
--------------------------------------------------------------------------------
1 | * [English](en/)
2 | * [日本語](ja/)
3 | * [中文](cn/)
4 | * [대한민국](ko/)
5 | * [Português](pt_BR/)
6 |
--------------------------------------------------------------------------------
/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/book.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": ""
3 | }
4 |
--------------------------------------------------------------------------------
/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/cn/contributing.md:
--------------------------------------------------------------------------------
1 | # 贡献
2 |
3 | 想要贡献你的力量?随时提交 pull 请求。在准备提交任何内容之前,请务必查看以下内容...
4 |
5 | ### JavaScript 标准规范
6 |
7 | 为确保所有 JS 代码遵循基本的 ***风格标准***,请务必遵循这些 [规则](http://standardjs.com/#rules)。
8 |
9 | [](https://github.com/feross/standard)
10 |
--------------------------------------------------------------------------------
/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 | 
13 |
14 | 此样板代码附带了几个易于移除的登录页面组件。
15 |
--------------------------------------------------------------------------------
/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/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/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` 时,你可以打开 Google Chrome,然后转到 `chrome://inspect`,在应用程序以开发模式运行时,弹出远程的 electron 进程。
53 |
54 | [Electron 文档](https://github.com/electron/electron/blob/master/docs/tutorial/debugging-main-process.md)
55 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/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/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/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/docs/cn/miscellaneous.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimulatedGREG/electron-vue/8d4ed607d65300381a8f47d97923eb07832b1a9a/docs/cn/miscellaneous.md
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/docs/cn/project_structure.md:
--------------------------------------------------------------------------------
1 | # 项目结构
2 |
3 | 当涉及制作 electron 应用程序的问题时,项目结构会有些不同。如果你以前使用过官方的 [`vuejs-templates/webpack`](https://github.com/vuejs-templates/webpack) 设置,那么你对这个结构应该很熟悉。本文档在此章节将尝试解释样板代码的工作原理以及应用程序在构建中的一些区别。
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/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` 并不是简单的事情,所以请阅读 [这里](https://vuex.vuejs.org/zh/),以便更好地了解它试图解决的问题及其工作原理。
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/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/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/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/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/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 |
13 |
14 |
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/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 |
--------------------------------------------------------------------------------
/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 |