mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 10:30:13 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
0384261c95
6 changed files with 63 additions and 36 deletions
|
|
@ -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)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -478,10 +478,6 @@ func genTreeID(tree *parse.Tree) {
|
|||
return
|
||||
}
|
||||
|
||||
func ReloadUI() {
|
||||
task.AppendTask(task.ReloadUI, util.ReloadUI)
|
||||
}
|
||||
|
||||
func FullReindex() {
|
||||
task.AppendTask(task.DatabaseIndexFull, fullReindex)
|
||||
task.AppendTask(task.DatabaseIndexRef, IndexRefs)
|
||||
|
|
|
|||
|
|
@ -1053,7 +1053,6 @@ func bootSyncRepo() (err error) {
|
|||
|
||||
if 0 < len(fetchedFiles) {
|
||||
go func() {
|
||||
time.Sleep(7 * time.Second) // 等待一段时间后前端完成界面初始化后再同步
|
||||
syncErr := syncRepo(false, false)
|
||||
if nil != err {
|
||||
logging.LogErrorf("boot background sync repo failed: %s", syncErr)
|
||||
|
|
@ -1238,33 +1237,42 @@ func processSyncMergeResult(exit, byHand bool, start time.Time, mergeResult *dej
|
|||
return
|
||||
}
|
||||
|
||||
incReindex(upserts, removes)
|
||||
if !exit {
|
||||
ReloadUI()
|
||||
if exit { // 退出时同步不用推送事件
|
||||
return
|
||||
}
|
||||
|
||||
upsertRootIDs, removeRootIDs := incReindex(upserts, removes)
|
||||
elapsed := time.Since(start)
|
||||
if !exit {
|
||||
go func() {
|
||||
time.Sleep(2 * time.Second)
|
||||
util.PushStatusBar(fmt.Sprintf(Conf.Language(149), elapsed.Seconds()))
|
||||
go func() {
|
||||
util.WaitForUILoaded()
|
||||
|
||||
if 0 < len(mergeResult.Conflicts) {
|
||||
syConflict := false
|
||||
for _, file := range mergeResult.Conflicts {
|
||||
if strings.HasSuffix(file.Path, ".sy") {
|
||||
syConflict = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if util.ContainerAndroid == util.Container || util.ContainerIOS == util.Container {
|
||||
// 移动端不推送差异详情
|
||||
upsertRootIDs = []string{}
|
||||
removeRootIDs = []string{}
|
||||
}
|
||||
|
||||
if syConflict {
|
||||
// 数据同步发生冲突时在界面上进行提醒 https://github.com/siyuan-note/siyuan/issues/7332
|
||||
util.PushMsg(Conf.Language(108), 7000)
|
||||
util.BroadcastByType("main", "syncMergeResult", 0, "",
|
||||
map[string]interface{}{"upsertRootIDs": upsertRootIDs, "removeRootIDs": removeRootIDs})
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
util.PushStatusBar(fmt.Sprintf(Conf.Language(149), elapsed.Seconds()))
|
||||
|
||||
if 0 < len(mergeResult.Conflicts) {
|
||||
syConflict := false
|
||||
for _, file := range mergeResult.Conflicts {
|
||||
if strings.HasSuffix(file.Path, ".sy") {
|
||||
syConflict = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if syConflict {
|
||||
// 数据同步发生冲突时在界面上进行提醒 https://github.com/siyuan-note/siyuan/issues/7332
|
||||
util.PushMsg(Conf.Language(108), 7000)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func logSyncMergeResult(mergeResult *dejavu.MergeResult) {
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ func checkSync(boot, exit, byHand bool) bool {
|
|||
}
|
||||
|
||||
// incReindex 增量重建索引。
|
||||
func incReindex(upserts, removes []string) {
|
||||
func incReindex(upserts, removes []string) (upsertRootIDs, removeRootIDs []string) {
|
||||
util.IncBootProgress(3, "Sync reindexing...")
|
||||
msg := fmt.Sprintf(Conf.Language(35))
|
||||
util.PushStatusBar(msg)
|
||||
|
|
@ -274,6 +274,7 @@ func incReindex(upserts, removes []string) {
|
|||
}
|
||||
|
||||
id := strings.TrimSuffix(filepath.Base(removeFile), ".sy")
|
||||
removeRootIDs = append(removeRootIDs, id)
|
||||
block := treenode.GetBlockTree(id)
|
||||
if nil != block {
|
||||
msg = fmt.Sprintf(Conf.Language(39), block.RootID)
|
||||
|
|
@ -316,7 +317,9 @@ func incReindex(upserts, removes []string) {
|
|||
}
|
||||
treenode.IndexBlockTree(tree)
|
||||
sql.UpsertTreeQueue(tree)
|
||||
upsertRootIDs = append(upsertRootIDs, tree.Root.ID)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func SetCloudSyncDir(name string) {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,25 @@ import (
|
|||
|
||||
const DatabaseVer = "20220501" // 修改表结构的话需要修改这里
|
||||
|
||||
// IsUILoaded 是否已经加载了 UI。
|
||||
var IsUILoaded = false
|
||||
|
||||
func WaitForUILoaded() {
|
||||
for !IsUILoaded {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
||||
func HookUILoaded() {
|
||||
for !IsUILoaded {
|
||||
if 0 < len(SessionsByType("main")) {
|
||||
IsUILoaded = true
|
||||
return
|
||||
}
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
||||
// IsExiting 是否正在退出程序。
|
||||
var IsExiting = false
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue