🎨 localStorage 支持在多界面实例间同步 https://github.com/siyuan-note/siyuan/issues/6965

This commit is contained in:
Liang Ding 2023-01-01 14:09:36 +08:00
parent 3adb7d9ad0
commit 95bb18afe1
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
12 changed files with 49 additions and 55 deletions

View file

@ -288,7 +288,7 @@ func deleteBlock(c *gin.Context) {
}
func broadcastTransactions(transactions []*model.Transaction) {
evt := util.NewCmdResult("transactions", 0, util.PushModeBroadcast, util.PushModeBroadcast)
evt := util.NewCmdResult("transactions", 0, util.PushModeBroadcast)
evt.Data = transactions
util.PushEvent(evt)
}

View file

@ -115,7 +115,7 @@ func heading2Doc(c *gin.Context) {
name := path.Base(targetPath)
box := model.Conf.Box(targetNotebook)
files, _, _ := model.ListDocTree(targetNotebook, path.Dir(targetPath), model.Conf.FileTree.Sort)
evt := util.NewCmdResult("heading2doc", 0, util.PushModeBroadcast, util.PushModeNone)
evt := util.NewCmdResult("heading2doc", 0, util.PushModeBroadcast)
evt.Data = map[string]interface{}{
"box": box,
"path": targetPath,
@ -159,7 +159,7 @@ func li2Doc(c *gin.Context) {
name := path.Base(targetPath)
box := model.Conf.Box(targetNotebook)
files, _, _ := model.ListDocTree(targetNotebook, path.Dir(targetPath), model.Conf.FileTree.Sort)
evt := util.NewCmdResult("li2doc", 0, util.PushModeBroadcast, util.PushModeNone)
evt := util.NewCmdResult("li2doc", 0, util.PushModeBroadcast)
evt.Data = map[string]interface{}{
"box": box,
"path": targetPath,
@ -465,7 +465,7 @@ func createDailyNote(c *gin.Context) {
if existed && "" != app {
pushMode = util.PushModeBroadcastApp
}
evt := util.NewCmdResult("createdailynote", 0, pushMode, util.PushModeNone)
evt := util.NewCmdResult("createdailynote", 0, pushMode)
evt.AppId = app
name := path.Base(p)
@ -750,7 +750,7 @@ func getDoc(c *gin.Context) {
}
func pushCreate(box *model.Box, p, treeID string, arg map[string]interface{}) {
evt := util.NewCmdResult("create", 0, util.PushModeBroadcast, util.PushModeNone)
evt := util.NewCmdResult("create", 0, util.PushModeBroadcast)
name := path.Base(p)
files, _, _ := model.ListDocTree(box.ID, path.Dir(p), model.Conf.FileTree.Sort)
evt.Data = map[string]interface{}{

View file

@ -76,7 +76,7 @@ func renameNotebook(c *gin.Context) {
return
}
evt := util.NewCmdResult("renamenotebook", 0, util.PushModeBroadcast, util.PushModeNone)
evt := util.NewCmdResult("renamenotebook", 0, util.PushModeBroadcast)
evt.Data = map[string]interface{}{
"box": notebook,
"name": name,
@ -101,7 +101,7 @@ func removeNotebook(c *gin.Context) {
return
}
evt := util.NewCmdResult("unmount", 0, util.PushModeBroadcast, 0)
evt := util.NewCmdResult("unmount", 0, util.PushModeBroadcast)
evt.Data = map[string]interface{}{
"box": notebook,
}
@ -137,7 +137,7 @@ func createNotebook(c *gin.Context) {
"notebook": model.Conf.Box(id),
}
evt := util.NewCmdResult("createnotebook", 0, util.PushModeBroadcast, util.PushModeNone)
evt := util.NewCmdResult("createnotebook", 0, util.PushModeBroadcast)
evt.Data = map[string]interface{}{
"box": model.Conf.Box(id),
"existed": existed,
@ -164,7 +164,7 @@ func openNotebook(c *gin.Context) {
return
}
evt := util.NewCmdResult("mount", 0, util.PushModeBroadcast, util.PushModeNone)
evt := util.NewCmdResult("mount", 0, util.PushModeBroadcast)
evt.Data = map[string]interface{}{
"box": model.Conf.Box(notebook),
"existed": existed,

View file

@ -196,7 +196,7 @@ func setLocalStorage(c *gin.Context) {
}
app := arg["app"].(string)
evt := util.NewCmdResult("setLocalStorage", 0, util.PushModeBroadcastMainExcludeSelfApp, util.PushModeBroadcastMainExcludeSelfApp)
evt := util.NewCmdResult("setLocalStorage", 0, util.PushModeBroadcastMainExcludeSelfApp)
evt.AppId = app
evt.Data = val
util.PushEvent(evt)

View file

@ -93,7 +93,7 @@ func performTransactions(c *gin.Context) {
}
func pushTransactions(app, session string, transactions []*model.Transaction) {
evt := util.NewCmdResult("transactions", 0, util.PushModeBroadcastExcludeSelf, util.PushModeBroadcastExcludeSelf)
evt := util.NewCmdResult("transactions", 0, util.PushModeBroadcastExcludeSelf)
evt.AppId = app
evt.SessionId = session
evt.Data = transactions