Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
electron-store-vuex-sync
Advanced tools
自动同步electron-store
和vuex
const { ipcMain } = require('electron')
const Store = require('electron-store');
const { injectStore } = require('electron-store-vuex-sync')
const store = new Store();
injectStore(ipcMain, store)
import Vuex from 'vuex'
import { getVuexStoreConfig } from 'electron-store-vuex-sync'
import { ipcRenderer } from 'electron'
const store = new Vuex.Store(getVuexStoreConfig(ipcRenderer))
return store
如果需要vuex可以同步回store
import Vuex from 'vuex'
import { getVuexStoreConfig } from 'electron-store-vuex-sync'
import { ipcRenderer } from 'electron'
const schema = {
a: {
type: 'array'
}
}
const store = new Vuex.Store(getVuexStoreConfig(ipcRenderer, schema))
return store
这样,会根据你schema的key,自动添加mutation
,名字类似于set:key名
默认情况下,state根据schema推导,但是可以通过传入第四个参数defaultStore,让state中每个属性就为defaultStore对应的值
默认同步会在加载成功后通过对应事件同步
import Vuex from 'vuex'
import { getVuexStoreConfig } from 'electron-store-vuex-sync'
import { ipcRenderer } from 'electron'
import store from '../store' // 导出的electron store
const schema = {
a: {
type: 'array'
}
}
const store = new Vuex.Store(getVuexStoreConfig(ipcRenderer, schema, null, store))
return store
这样,会根据你schema的key,自动添加mutation
,名字类似于set:key名
electron
的ipcMain
用来注入监听事件electron-store
创建的store
store
的名字需要不同页面同步不同store
的时候需要,可选返回传入的store
electron
的ipcRenderer
用来注入监听事件electron-store
的schema
可以根据这个自动初始化,省去手动的问题store
的名字需要不同页面同步不同store
的时候需要,可选如果使用schema
来初始化的话,vuex
的mutation
为set:schema的key
只会生成对应的vuex
配置,像是state
,action
这些你可以通过解构等方法把自己的方法注入进去
因为electron-store
默认名字为config
,所以vuex
用来初始化和同步的事件前缀也默认为config:
background
的注入请放在最顶上
FAQs
auto sync electron-store and vuex
The npm package electron-store-vuex-sync receives a total of 0 weekly downloads. As such, electron-store-vuex-sync popularity was classified as not popular.
We found that electron-store-vuex-sync demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.