mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 localStorage 支持在多界面实例间同步 https://github.com/siyuan-note/siyuan/issues/6965
This commit is contained in:
parent
3a1382cb42
commit
853ba5be3a
5 changed files with 38 additions and 10 deletions
|
|
@ -233,6 +233,8 @@ func PushEvent(event *Result) {
|
|||
broadcastOtherApps(msg, event.AppId)
|
||||
case PushModeBroadcastApp:
|
||||
broadcastApp(msg, event.AppId)
|
||||
case PushModeBroadcastMainExcludeSelfApp:
|
||||
broadcastOtherAppMains(msg, event.AppId)
|
||||
case PushModeNone:
|
||||
}
|
||||
}
|
||||
|
|
@ -282,6 +284,26 @@ func broadcastOtherApps(msg []byte, excludeApp string) {
|
|||
})
|
||||
}
|
||||
|
||||
func broadcastOtherAppMains(msg []byte, excludeApp string) {
|
||||
sessions.Range(func(key, value interface{}) bool {
|
||||
appSessions := value.(*sync.Map)
|
||||
appSessions.Range(func(key, value interface{}) bool {
|
||||
session := value.(*melody.Session)
|
||||
if app, _ := session.Get("app"); app == excludeApp {
|
||||
return true
|
||||
}
|
||||
|
||||
if t, ok := session.Get("type"); ok && "main" != t {
|
||||
return true
|
||||
}
|
||||
|
||||
session.Write(msg)
|
||||
return true
|
||||
})
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
func broadcastApp(msg []byte, app string) {
|
||||
sessions.Range(func(key, value interface{}) bool {
|
||||
appSessions := value.(*sync.Map)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue