Vuex dispatch cannot modify status

< H1 > problem description: < / H1 >

in electron-vue, use vuex, to call this.$store.dispatch ("changeLogin"); cannot modify the login status.

method definition:

clipboard.png

:

clipboard.png

:

isLoginfalsethis.$store.dispatch("changeLogin");false
clipboard.png


clipboard.png

Dec.29,2021

Ran into this problem myself, I had to import the store inside of my electron index.js

The issue is with the createSharedMutations () from the vuex-electron package

src-> main-> index.js

import { app, BrowserWindow } from 'electron'

// Store must be imported for the shitty vuex-electron sharedMutations
/* eslint no-unused-vars: 0 */
import store from '../renderer/store'

/**
 * Set `__static` path to static files in production
 * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
 */
if (process.env.NODE_ENV !== 'development') {
  global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
}

let mainWindow
const winURL = process.env.NODE_ENV === 'development'
  ? `http://localhost:9080`
  : `file://${__dirname}/index.html`

function createWindow () {
  /**
   * Initial window options
   */
  mainWindow = new BrowserWindow({
    height: 563,
    useContentSize: true,
    width: 1000,
    titleBarStyle: 'hidden'
  })

  mainWindow.loadURL(winURL)

  mainWindow.on('closed', () => {
    mainWindow = null
  })
}

app.on('ready', createWindow)

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', () => {
  if (mainWindow === null) {
    createWindow()
  }
})

actions corresponding to dispatch can be used to handle asynchronous situations
commit corresponding mutations modification must be modified through mutations

Menu