mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 前端用户界面引入后台任务列表 https://github.com/siyuan-note/siyuan/issues/7117
This commit is contained in:
parent
3b9ae96dbd
commit
d95c6bd467
4 changed files with 29 additions and 0 deletions
|
|
@ -44,6 +44,7 @@ func main() {
|
||||||
model.LoadAssetsTexts()
|
model.LoadAssetsTexts()
|
||||||
|
|
||||||
go task.Loop()
|
go task.Loop()
|
||||||
|
go task.StatusLoop()
|
||||||
|
|
||||||
go model.AutoGenerateDocHistory()
|
go model.AutoGenerateDocHistory()
|
||||||
go model.AutoSync()
|
go model.AutoSync()
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ func StartKernel(container, appDir, workspaceBaseDir, timezoneID, localIPs, lang
|
||||||
model.LoadAssetsTexts()
|
model.LoadAssetsTexts()
|
||||||
|
|
||||||
go task.Loop()
|
go task.Loop()
|
||||||
|
go task.StatusLoop()
|
||||||
|
|
||||||
go model.AutoGenerateDocHistory()
|
go model.AutoGenerateDocHistory()
|
||||||
go model.AutoSync()
|
go model.AutoSync()
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,29 @@ const (
|
||||||
DatabaseIndexEmbedBlock = "task.database.index.embedBlock" // 数据库索引嵌入块
|
DatabaseIndexEmbedBlock = "task.database.index.embedBlock" // 数据库索引嵌入块
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func StatusLoop() {
|
||||||
|
for {
|
||||||
|
time.Sleep(1000 * time.Millisecond)
|
||||||
|
tasks := taskQueue
|
||||||
|
data := map[string]interface{}{}
|
||||||
|
var items []map[string]interface{}
|
||||||
|
for _, task := range tasks {
|
||||||
|
if OCRImage == task.Action || DatabaseIndexEmbedBlock == task.Action {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
item := map[string]interface{}{
|
||||||
|
"action": task.Action,
|
||||||
|
}
|
||||||
|
items = append(items, item)
|
||||||
|
}
|
||||||
|
util.PushBackgroundTask(data)
|
||||||
|
if 0 < len(tasks) {
|
||||||
|
time.Sleep(1000 * time.Millisecond)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func Loop() {
|
func Loop() {
|
||||||
for {
|
for {
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(10 * time.Millisecond)
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,10 @@ func PushStatusBar(msg string) {
|
||||||
BroadcastByType("main", "statusbar", 0, msg, nil)
|
BroadcastByType("main", "statusbar", 0, msg, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func PushBackgroundTask(data map[string]interface{}) {
|
||||||
|
BroadcastByType("main", "backgroundtask", 0, "", data)
|
||||||
|
}
|
||||||
|
|
||||||
type BlockStatResult struct {
|
type BlockStatResult struct {
|
||||||
RuneCount int `json:"runeCount"`
|
RuneCount int `json:"runeCount"`
|
||||||
WordCount int `json:"wordCount"`
|
WordCount int `json:"wordCount"`
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue