Merge pull request 'zdg' (#147) from zdg into main

Reviewed-on: #147
This commit is contained in:
zhengdegang 2024-08-16 17:35:43 +08:00
commit 4fd47d2f2f
1 changed files with 6 additions and 4 deletions

View File

@ -13,12 +13,14 @@ export function shareStorePlugin({store}) {
// 在存储变化的时候执行
// const storeName = store.$id
// 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']
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) => {