zdg #147

Merged
zhengdegang merged 2 commits from zdg into main 2024-08-16 17:35:45 +08:00
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) => {