zdg #147
|
@ -13,12 +13,14 @@ export function shareStorePlugin({store}) {
|
||||||
// 在存储变化的时候执行
|
// 在存储变化的时候执行
|
||||||
// const storeName = store.$id
|
// const storeName = store.$id
|
||||||
// const storeName = mutation.storeId
|
// const storeName = mutation.storeId
|
||||||
const { storeId: storeName, payload, events, type } = mutation // direct
|
|
||||||
// if (!Object.keys(payload).length) return
|
|
||||||
if (type != 'direct') return
|
|
||||||
// 用于多窗口共享(需要共享的状态名称)
|
// 用于多窗口共享(需要共享的状态名称)
|
||||||
const names = ['tool']
|
const names = ['tool']
|
||||||
if (names.includes(storeName)) stateSync(storeName, events.key, events.newValue) // 需要同步
|
if (names.includes(storeName)) {
|
||||||
|
const { storeId: storeName, payload, events, type } = mutation // direct
|
||||||
|
// if (!Object.keys(payload).length) return
|
||||||
|
if (type != 'direct' || !events || Array.isArray(events) || !events.key) return
|
||||||
|
stateSync(storeName, events.key, events.newValue) // 需要同步
|
||||||
|
}
|
||||||
})
|
})
|
||||||
// 暴露方法-手动同步
|
// 暴露方法-手动同步
|
||||||
store.stateSync = (storeName, key, value) => {
|
store.stateSync = (storeName, key, value) => {
|
||||||
|
|
Loading…
Reference in New Issue