Skip to content
This repository was archived by the owner on Oct 4, 2023. It is now read-only.

Commit b1f069a

Browse files
Andrew EmelianenkoXanderLuciano
Andrew Emelianenko
authored andcommitted
Add optional vuex-electron plugin (#692)
* Sync Vuex store between all processes * Add information about `vuex-electron` to docs
1 parent cf53551 commit b1f069a

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

Diff for: docs/en/vue_accessories.md

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ electron-vue comes packed with the following `vue` plugins that can be installed
66
* [vue-electron](https://github.com/SimulatedGREG/vue-electron) \(attach electron APIs to Vue object\)
77
* [vue-router](https://github.com/vuejs/vue-router) \(single page application routes\)
88
* [vuex](https://github.com/vuejs/vuex) \(flux-inspired application architecture\)
9+
* [vuex-electron](https://github.com/vue-electron/vuex-electron) \(sync vuex store between all processes and instances\)
910

1011
---
1112

@@ -33,3 +34,8 @@ The provided project structure should feel familiar to the setup provided in the
3334
3435
The provided project structure is rather bare but does encourage the use of `vuex`'s module pattern to help organize your data stores. The extra `@/store/modules/index.js` let's your `vuex` store import all modules in a one-shot manner.
3536

37+
### [`vuex-electron`](https://github.com/vue-electron/vuex-electron)
38+
39+
> The easiest way to use your Vuex store between all processes (including main) and instances.
40+
41+
In case if your application has multiple windows, probably you would need to share the state of the application between them. Moreover, probably you would need to share the state of the app between launches or different instances. You could easily solve these two tasks by using `vuex-store`.

Diff for: meta.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ module.exports = {
7979
plugins: {
8080
type: 'checkbox',
8181
message: 'Select which Vue plugins to install',
82-
choices: ['axios', 'vue-electron', 'vue-router', 'vuex'],
83-
default: ['axios', 'vue-electron', 'vue-router', 'vuex']
82+
choices: ['axios', 'vue-electron', 'vue-router', 'vuex', 'vuex-electron'],
83+
default: ['axios', 'vue-electron', 'vue-router', 'vuex', 'vuex-electron']
8484
},
8585
eslint: {
8686
type: 'confirm',
@@ -148,7 +148,8 @@ module.exports = {
148148
'axios': '^0.18.0',
149149
'vue-electron': '^1.0.6',
150150
'vue-router': '^3.0.1',
151-
'vuex': '^3.0.1'
151+
'vuex': '^3.0.1',
152+
'vuex-electron': '^1.0.0'
152153
}
153154

154155
if (Object.keys(plugins).length > 0) output += ',\n'

Diff for: template/src/renderer/store/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
import Vue from 'vue'
22
import Vuex from 'vuex'
33

4+
{{#isEnabled plugins 'vuex-electron'}}
5+
import { createPersistedState, createSharedMutations } from 'vuex-electron'
6+
7+
{{/isEnabled}}
48
import modules from './modules'
59

610
Vue.use(Vuex)
711

812
export default new Vuex.Store({
913
modules,
14+
{{#isEnabled plugins 'vuex-electron'}}
15+
plugins: [
16+
createPersistedState(),
17+
createSharedMutations()
18+
],
19+
{{/isEnabled}}
1020
strict: process.env.NODE_ENV !== 'production'
1121
})

0 commit comments

Comments
 (0)