@MrEmelianenko
src/main/index.js
By import '../renderer/store' ,only use this.$store.dispatch, can not use this.$store.commit

By del createSharedMutations() ,both this.$store.dispatch and this.$store.commit can run
LandingPage.vue
<template>
<div id="wrapper">
<img id="logo" src="~@/assets/logo.png" alt="electron-vue">
<main>
--------* {{value}} *-----------
<div>
<button @click="onAdd">âž•</button>
<button @click="onDec">âž–</button>
</div>
</main>
</div>
</template>
<script>
import SystemInformation from './LandingPage/SystemInformation'
import {mapState, mapGetters, mapActions} from 'vuex'
export default {
name: 'landing-page',
components: {SystemInformation},
methods: {
open(link) {
this.$electron.shell.openExternal(link)
},
onAdd() {
// this.$store.commit('INCREMENT_MAIN_COUNTER', {}) // del createSharedMutations()
this.$store.dispatch('inc', {}) // use `import '../renderer/store'`
},
onDec() {
// this.$store.commit('DECREMENT_MAIN_COUNTER', {}) // del createSharedMutations()
this.$store.dispatch('dec', {}) // use `import '../renderer/store'`
},
},
computed: {
...mapState({
value: state => state.Counter.main
}),
},
}
</script>
Counter.js
const state = {
main: 0
}
const mutations = {
DECREMENT_MAIN_COUNTER (state) {
console.log('DECREMENT_MAIN_COUNTER')
state.main--
},
INCREMENT_MAIN_COUNTER (state) {
console.log('INCREMENT_MAIN_COUNTER')
state.main++
}
}
const actions = {
someAsyncTask ({ commit }) {
// do something async
commit('INCREMENT_MAIN_COUNTER')
},
dec ({ commit }) {
// do something async
console.log('dec')
commit('DECREMENT_MAIN_COUNTER')
},
inc ({ commit }) {
// do something async
console.log('inc')
commit('INCREMENT_MAIN_COUNTER')
}
}
export default {
namespaces: true,
state,
mutations,
actions
}
Most helpful comment
Same here and I've wasted just 2h debugging this crap until I realized the issue is in fact in electron-vue... 😠I had to remove the createSharedMutations() function call.