mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
🎨 桌面端加入底部状态栏 https://github.com/siyuan-note/siyuan/issues/5286
This commit is contained in:
parent
7a83808d45
commit
12cea42ce3
4 changed files with 140 additions and 30 deletions
|
|
@ -40,7 +40,7 @@ require (
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||||
github.com/qiniu/go-sdk/v7 v7.13.0
|
github.com/qiniu/go-sdk/v7 v7.13.0
|
||||||
github.com/radovskyb/watcher v1.0.7
|
github.com/radovskyb/watcher v1.0.7
|
||||||
github.com/siyuan-note/dejavu v0.0.0-20220625094848-7e1437e9c8c2
|
github.com/siyuan-note/dejavu v0.0.0-20220625122139-d442191b9acc
|
||||||
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676
|
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676
|
||||||
github.com/siyuan-note/eventbus v0.0.0-20220624162334-ca7c06dc771f
|
github.com/siyuan-note/eventbus v0.0.0-20220624162334-ca7c06dc771f
|
||||||
github.com/siyuan-note/filelock v0.0.0-20220616063212-74cfba0754ee
|
github.com/siyuan-note/filelock v0.0.0-20220616063212-74cfba0754ee
|
||||||
|
|
|
||||||
|
|
@ -423,6 +423,8 @@ github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546/go.mod h1:TrYk7fJV
|
||||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||||
github.com/siyuan-note/dejavu v0.0.0-20220625094848-7e1437e9c8c2 h1:G0gSYBcywwHgHQesFo/tGbKc2tEGsWBmncEuGpGH1Xg=
|
github.com/siyuan-note/dejavu v0.0.0-20220625094848-7e1437e9c8c2 h1:G0gSYBcywwHgHQesFo/tGbKc2tEGsWBmncEuGpGH1Xg=
|
||||||
github.com/siyuan-note/dejavu v0.0.0-20220625094848-7e1437e9c8c2/go.mod h1:i7dnOgHM41EA7xIX2CYSxYe0WhksGZidQQsLvWryK7w=
|
github.com/siyuan-note/dejavu v0.0.0-20220625094848-7e1437e9c8c2/go.mod h1:i7dnOgHM41EA7xIX2CYSxYe0WhksGZidQQsLvWryK7w=
|
||||||
|
github.com/siyuan-note/dejavu v0.0.0-20220625122139-d442191b9acc h1:wbgMZUgzWFOyeTJ9vtyW+N8v+bCzcBRR2LbaurN76so=
|
||||||
|
github.com/siyuan-note/dejavu v0.0.0-20220625122139-d442191b9acc/go.mod h1:i7dnOgHM41EA7xIX2CYSxYe0WhksGZidQQsLvWryK7w=
|
||||||
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676 h1:QB9TjJQFhXhZ6dAtPpY02DlzHAQm1C+WqZq6OadG8mI=
|
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676 h1:QB9TjJQFhXhZ6dAtPpY02DlzHAQm1C+WqZq6OadG8mI=
|
||||||
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
||||||
github.com/siyuan-note/eventbus v0.0.0-20220624162334-ca7c06dc771f h1:JMobMNZ7AqaKKyEK+WeWFhix/2TDQXgPZDajU00IybU=
|
github.com/siyuan-note/eventbus v0.0.0-20220624162334-ca7c06dc771f h1:JMobMNZ7AqaKKyEK+WeWFhix/2TDQXgPZDajU00IybU=
|
||||||
|
|
|
||||||
|
|
@ -34,60 +34,150 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
eventbus.Subscribe(dejavu.EvtIndexWalkData, func(path string) {
|
eventbus.Subscribe(dejavu.EvtIndexWalkData, func(context map[string]interface{}, path string) {
|
||||||
msg := "Indexing repo walk data [" + path + "]"
|
msg := "Indexing repo [walk data " + path + "]"
|
||||||
util.SetBootDetails(msg)
|
util.SetBootDetails(msg)
|
||||||
util.PushEndlessProgress(msg)
|
|
||||||
|
switch context[CtxPushMsg].(int) {
|
||||||
|
case CtxPushMsgToProgress:
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
case CtxPushMsgToStatusBar:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
case CtxPushMsgToStatusBarAndProgress:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
eventbus.Subscribe(dejavu.EvtIndexGetLatestFile, func(path string) {
|
eventbus.Subscribe(dejavu.EvtIndexGetLatestFile, func(context map[string]interface{}, path string) {
|
||||||
msg := "Indexing repo get latest file [" + path + "]"
|
msg := "Indexing repo [get latest file " + path + "]"
|
||||||
util.SetBootDetails(msg)
|
util.SetBootDetails(msg)
|
||||||
util.PushEndlessProgress(msg)
|
|
||||||
|
switch context[CtxPushMsg].(int) {
|
||||||
|
case CtxPushMsgToProgress:
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
case CtxPushMsgToStatusBar:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
case CtxPushMsgToStatusBarAndProgress:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
eventbus.Subscribe(dejavu.EvtIndexUpsertFile, func(path string) {
|
eventbus.Subscribe(dejavu.EvtIndexUpsertFile, func(context map[string]interface{}, path string) {
|
||||||
msg := "Indexing repo upsert file [" + path + "]"
|
msg := "Indexing repo [upsert file " + path + "]"
|
||||||
util.SetBootDetails(msg)
|
util.SetBootDetails(msg)
|
||||||
util.PushEndlessProgress(msg)
|
|
||||||
|
switch context[CtxPushMsg].(int) {
|
||||||
|
case CtxPushMsgToProgress:
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
case CtxPushMsgToStatusBar:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
case CtxPushMsgToStatusBarAndProgress:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
eventbus.Subscribe(dejavu.EvtCheckoutWalkData, func(path string) {
|
eventbus.Subscribe(dejavu.EvtCheckoutWalkData, func(context map[string]interface{}, path string) {
|
||||||
msg := "Checkout repo walk data [" + path + "]"
|
msg := "Checkout repo [walk data " + path + "]"
|
||||||
util.SetBootDetails(msg)
|
util.SetBootDetails(msg)
|
||||||
util.PushEndlessProgress(msg)
|
|
||||||
|
switch context[CtxPushMsg].(int) {
|
||||||
|
case CtxPushMsgToProgress:
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
case CtxPushMsgToStatusBar:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
case CtxPushMsgToStatusBarAndProgress:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
eventbus.Subscribe(dejavu.EvtCheckoutUpsertFile, func(path string) {
|
eventbus.Subscribe(dejavu.EvtCheckoutUpsertFile, func(context map[string]interface{}, path string) {
|
||||||
msg := "Checkout repo upsert file [" + path + "]"
|
msg := "Checkout repo [upsert file " + path + "]"
|
||||||
util.SetBootDetails(msg)
|
util.SetBootDetails(msg)
|
||||||
util.PushEndlessProgress(msg)
|
|
||||||
|
switch context[CtxPushMsg].(int) {
|
||||||
|
case CtxPushMsgToProgress:
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
case CtxPushMsgToStatusBar:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
case CtxPushMsgToStatusBarAndProgress:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
eventbus.Subscribe(dejavu.EvtCheckoutRemoveFile, func(path string) {
|
eventbus.Subscribe(dejavu.EvtCheckoutRemoveFile, func(context map[string]interface{}, path string) {
|
||||||
msg := "Checkout repo remove file [" + path + "]"
|
msg := "Checkout repo [remove file " + path + "]"
|
||||||
util.SetBootDetails(msg)
|
util.SetBootDetails(msg)
|
||||||
util.PushEndlessProgress(msg)
|
|
||||||
|
switch context[CtxPushMsg].(int) {
|
||||||
|
case CtxPushMsgToProgress:
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
case CtxPushMsgToStatusBar:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
case CtxPushMsgToStatusBarAndProgress:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
eventbus.Subscribe(dejavu.EvtSyncBeforeDownloadCloudIndexes, func(latestSync string) {
|
eventbus.Subscribe(dejavu.EvtSyncBeforeDownloadCloudIndexes, func(context map[string]interface{}, latestSync string) {
|
||||||
msg := "Downloading repo indexes..."
|
msg := "Downloading repo indexes..."
|
||||||
util.SetBootDetails(msg)
|
util.SetBootDetails(msg)
|
||||||
util.PushEndlessProgress(msg)
|
|
||||||
|
switch context[CtxPushMsg].(int) {
|
||||||
|
case CtxPushMsgToProgress:
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
case CtxPushMsgToStatusBar:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
case CtxPushMsgToStatusBarAndProgress:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
eventbus.Subscribe(dejavu.EvtSyncBeforeDownloadCloudFile, func(id string) {
|
eventbus.Subscribe(dejavu.EvtSyncBeforeDownloadCloudFile, func(context map[string]interface{}, id string) {
|
||||||
msg := "Downloading repo object [" + id + "]"
|
msg := "Downloading repo object [" + id + "]"
|
||||||
util.SetBootDetails(msg)
|
util.SetBootDetails(msg)
|
||||||
util.PushEndlessProgress(msg)
|
|
||||||
|
switch context[CtxPushMsg].(int) {
|
||||||
|
case CtxPushMsgToProgress:
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
case CtxPushMsgToStatusBar:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
case CtxPushMsgToStatusBarAndProgress:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
eventbus.Subscribe(dejavu.EvtSyncBeforeDownloadCloudChunk, func(id string) {
|
eventbus.Subscribe(dejavu.EvtSyncBeforeDownloadCloudChunk, func(context map[string]interface{}, id string) {
|
||||||
msg := "Downloading repo object [" + id + "]"
|
msg := "Downloading repo object [" + id + "]"
|
||||||
util.SetBootDetails(msg)
|
util.SetBootDetails(msg)
|
||||||
util.PushEndlessProgress(msg)
|
|
||||||
|
switch context[CtxPushMsg].(int) {
|
||||||
|
case CtxPushMsgToProgress:
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
case CtxPushMsgToStatusBar:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
case CtxPushMsgToStatusBarAndProgress:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
eventbus.Subscribe(dejavu.EvtSyncBeforeUploadObject, func(id string) {
|
eventbus.Subscribe(dejavu.EvtSyncBeforeUploadObject, func(context map[string]interface{}, id string) {
|
||||||
msg := "Uploading repo object [" + id + "]"
|
msg := "Uploading repo object [" + id + "]"
|
||||||
util.SetBootDetails(msg)
|
util.SetBootDetails(msg)
|
||||||
util.PushEndlessProgress(msg)
|
|
||||||
|
switch context[CtxPushMsg].(int) {
|
||||||
|
case CtxPushMsgToProgress:
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
case CtxPushMsgToStatusBar:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
case CtxPushMsgToStatusBarAndProgress:
|
||||||
|
util.PushStatusBar(msg)
|
||||||
|
util.PushEndlessProgress(msg)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -229,7 +319,9 @@ func CheckoutRepo(id string) (err error) {
|
||||||
Conf.Sync.Enabled = false
|
Conf.Sync.Enabled = false
|
||||||
Conf.Save()
|
Conf.Save()
|
||||||
|
|
||||||
err = repo.Checkout(id)
|
err = repo.Checkout(id, map[string]interface{}{
|
||||||
|
CtxPushMsg: CtxPushMsgToStatusBarAndProgress,
|
||||||
|
})
|
||||||
if nil != err {
|
if nil != err {
|
||||||
util.PushClearProgress()
|
util.PushClearProgress()
|
||||||
return
|
return
|
||||||
|
|
@ -269,11 +361,21 @@ func IndexRepo(memo string) (err error) {
|
||||||
WaitForWritingFiles()
|
WaitForWritingFiles()
|
||||||
sql.WaitForWritingDatabase()
|
sql.WaitForWritingDatabase()
|
||||||
filelock.ReleaseAllFileLocks()
|
filelock.ReleaseAllFileLocks()
|
||||||
_, err = repo.Index(memo)
|
_, err = repo.Index(memo, map[string]interface{}{
|
||||||
|
CtxPushMsg: CtxPushMsgToStatusBarAndProgress,
|
||||||
|
})
|
||||||
util.PushClearProgress()
|
util.PushClearProgress()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
CtxPushMsg = "pushMsg"
|
||||||
|
|
||||||
|
CtxPushMsgToProgress = iota
|
||||||
|
CtxPushMsgToStatusBar
|
||||||
|
CtxPushMsgToStatusBarAndProgress
|
||||||
|
)
|
||||||
|
|
||||||
func indexRepoBeforeCloudSync() {
|
func indexRepoBeforeCloudSync() {
|
||||||
if 1 > len(Conf.Repo.Key) {
|
if 1 > len(Conf.Repo.Key) {
|
||||||
return
|
return
|
||||||
|
|
@ -287,7 +389,9 @@ func indexRepoBeforeCloudSync() {
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
latest, err := repo.Latest()
|
latest, err := repo.Latest()
|
||||||
index, err := repo.Index("[Auto] Cloud sync")
|
index, err := repo.Index("[Auto] Cloud sync", map[string]interface{}{
|
||||||
|
CtxPushMsg: CtxPushMsgToStatusBar,
|
||||||
|
})
|
||||||
if nil != err {
|
if nil != err {
|
||||||
util.LogErrorf("index repo before cloud sync failed: %s", err)
|
util.LogErrorf("index repo before cloud sync failed: %s", err)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,10 @@ func PushErrMsg(msg string, timeout int) (msgId string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func PushStatusBar(msg string) {
|
||||||
|
BroadcastByType("main", "statusbar", 0, msg, nil)
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PushProgressCodeProgressed = 0 // 有进度
|
PushProgressCodeProgressed = 0 // 有进度
|
||||||
PushProgressCodeEndless = 1 // 无进度
|
PushProgressCodeEndless = 1 // 无进度
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue