🎨 Partially refresh the interface after data synchronization https://github.com/siyuan-note/siyuan/issues/8098

This commit is contained in:
Liang Ding 2023-04-25 15:34:46 +08:00
parent e0e40dbad2
commit bd2e2c78bc
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
4 changed files with 33 additions and 11 deletions

View file

@ -182,7 +182,6 @@ func exportLog(c *gin.Context) {
}
}
var start = true // 是否是启动
func getConf(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
@ -200,21 +199,21 @@ func getConf(c *gin.Context) {
ret.Data = map[string]interface{}{
"conf": maskedConf,
"start": start,
"start": !util.IsUILoaded,
}
if start {
start = false
if !util.IsUILoaded {
go func() {
util.WaitForUILoaded()
if model.Conf.Editor.ReadOnly {
// 编辑器启用只读模式时启动后提示用户 https://github.com/siyuan-note/siyuan/issues/7700
go func() {
time.Sleep(time.Second * 7)
if model.Conf.Editor.ReadOnly {
// 编辑器启用只读模式时启动后提示用户 https://github.com/siyuan-note/siyuan/issues/7700
time.Sleep(time.Second * 3)
if model.Conf.Editor.ReadOnly {
util.PushMsg(model.Conf.Language(197), 7000)
}
}()
}
}
}()
}
}

View file

@ -1053,7 +1053,8 @@ func bootSyncRepo() (err error) {
if 0 < len(fetchedFiles) {
go func() {
time.Sleep(7 * time.Second) // 等待一段时间后前端完成界面初始化后再同步
util.WaitForUILoaded() // 等待一段时间后前端完成界面初始化后再同步,因为需要推送消息
syncErr := syncRepo(false, false)
if nil != err {
logging.LogErrorf("boot background sync repo failed: %s", syncErr)

View file

@ -129,6 +129,8 @@ func Serve(fastMode bool) {
}
}()
go util.HookUILoaded()
if err = http.Serve(ln, ginServer); nil != err {
if !fastMode {
logging.LogErrorf("boot kernel failed: %s", err)

View file

@ -40,6 +40,26 @@ import (
const DatabaseVer = "20220501" // 修改表结构的话需要修改这里
// IsUILoaded 是否已经加载了 UI。
var IsUILoaded = false
func WaitForUILoaded() {
for !IsUILoaded {
logging.LogInfof("waiting for UI loading...")
time.Sleep(time.Second)
}
}
func HookUILoaded() {
for !IsUILoaded {
if 0 < len(SessionsByType("main")) {
IsUILoaded = true
return
}
time.Sleep(time.Second)
}
}
// IsExiting 是否正在退出程序。
var IsExiting = false