mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 The User Guide is no longer opened repeatedly when multiple windows exist https://github.com/siyuan-note/siyuan/issues/11588
This commit is contained in:
parent
564c578369
commit
7b4d297ade
3 changed files with 51 additions and 23 deletions
|
|
@ -32,6 +32,26 @@ var (
|
|||
sessions = sync.Map{} // {appId, {sessionId, session}}
|
||||
)
|
||||
|
||||
func BroadcastByTypeAndApp(typ, app, cmd string, code int, msg string, data interface{}) {
|
||||
appSessions, ok := sessions.Load(app)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
appSessions.(*sync.Map).Range(func(key, value interface{}) bool {
|
||||
session := value.(*melody.Session)
|
||||
if t, ok := session.Get("type"); ok && typ == t {
|
||||
event := NewResult()
|
||||
event.Cmd = cmd
|
||||
event.Code = code
|
||||
event.Msg = msg
|
||||
event.Data = data
|
||||
session.Write(event.Bytes())
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
// BroadcastByType 广播所有实例上 typ 类型的会话。
|
||||
func BroadcastByType(typ, cmd string, code int, msg string, data interface{}) {
|
||||
typeSessions := SessionsByType(typ)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue