🎨 启动进度详情中加入版本信息

This commit is contained in:
Liang Ding 2022-08-01 09:54:10 +08:00
parent 16574e27e8
commit 1275a4bf16
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 13 additions and 8 deletions

View file

@ -24,6 +24,7 @@ import (
"fmt" "fmt"
"math" "math"
"os" "os"
"path/filepath"
"strings" "strings"
"time" "time"
@ -637,7 +638,7 @@ func subscribeEvents() {
indexWalkDataCount := 0 indexWalkDataCount := 0
eventbus.Subscribe(dejavu.EvtIndexWalkData, func(context map[string]interface{}, path string) { eventbus.Subscribe(dejavu.EvtIndexWalkData, func(context map[string]interface{}, path string) {
msg := fmt.Sprintf(Conf.Language(158), path) msg := fmt.Sprintf(Conf.Language(158), filepath.Base(path))
if 0 == indexWalkDataCount%512 { if 0 == indexWalkDataCount%512 {
util.SetBootDetails(msg) util.SetBootDetails(msg)
contextPushMsg(context, msg) contextPushMsg(context, msg)
@ -665,7 +666,7 @@ func subscribeEvents() {
}) })
indexUpsertFileCount := 0 indexUpsertFileCount := 0
eventbus.Subscribe(dejavu.EvtIndexUpsertFile, func(context map[string]interface{}, path string) { eventbus.Subscribe(dejavu.EvtIndexUpsertFile, func(context map[string]interface{}, path string) {
msg := fmt.Sprintf(Conf.Language(160), path) msg := fmt.Sprintf(Conf.Language(160), filepath.Base(path))
if 0 == indexUpsertFileCount%128 { if 0 == indexUpsertFileCount%128 {
util.SetBootDetails(msg) util.SetBootDetails(msg)
contextPushMsg(context, msg) contextPushMsg(context, msg)
@ -680,7 +681,7 @@ func subscribeEvents() {
}) })
coWalkDataCount := 0 coWalkDataCount := 0
eventbus.Subscribe(dejavu.EvtCheckoutWalkData, func(context map[string]interface{}, path string) { eventbus.Subscribe(dejavu.EvtCheckoutWalkData, func(context map[string]interface{}, path string) {
msg := fmt.Sprintf(Conf.Language(161), path) msg := fmt.Sprintf(Conf.Language(161), filepath.Base(path))
if 0 == coWalkDataCount%512 { if 0 == coWalkDataCount%512 {
util.SetBootDetails(msg) util.SetBootDetails(msg)
contextPushMsg(context, msg) contextPushMsg(context, msg)
@ -696,7 +697,7 @@ func subscribeEvents() {
}) })
coUpsertFileCount := 0 coUpsertFileCount := 0
eventbus.Subscribe(dejavu.EvtCheckoutUpsertFile, func(context map[string]interface{}, path string) { eventbus.Subscribe(dejavu.EvtCheckoutUpsertFile, func(context map[string]interface{}, path string) {
msg := fmt.Sprintf(Conf.Language(162), path) msg := fmt.Sprintf(Conf.Language(162), filepath.Base(path))
util.IncBootProgress(bootProgressPart, msg) util.IncBootProgress(bootProgressPart, msg)
if 0 == coUpsertFileCount%128 { if 0 == coUpsertFileCount%128 {
contextPushMsg(context, msg) contextPushMsg(context, msg)
@ -711,7 +712,7 @@ func subscribeEvents() {
}) })
coRemoveFileCount := 0 coRemoveFileCount := 0
eventbus.Subscribe(dejavu.EvtCheckoutRemoveFile, func(context map[string]interface{}, path string) { eventbus.Subscribe(dejavu.EvtCheckoutRemoveFile, func(context map[string]interface{}, path string) {
msg := fmt.Sprintf(Conf.Language(163), path) msg := fmt.Sprintf(Conf.Language(163), filepath.Base(path))
util.IncBootProgress(bootProgressPart, msg) util.IncBootProgress(bootProgressPart, msg)
if 0 == coRemoveFileCount%512 { if 0 == coRemoveFileCount%512 {
contextPushMsg(context, msg) contextPushMsg(context, msg)

View file

@ -110,11 +110,15 @@ func Boot() {
go cleanOld() go cleanOld()
} }
func setBootDetails(details string) {
bootDetails = "v" + Ver + " " + details
}
func SetBootDetails(details string) { func SetBootDetails(details string) {
if 100 <= bootProgress { if 100 <= bootProgress {
return return
} }
bootDetails = details setBootDetails(details)
} }
func IncBootProgress(progress float64, details string) { func IncBootProgress(progress float64, details string) {
@ -122,7 +126,7 @@ func IncBootProgress(progress float64, details string) {
return return
} }
bootProgress += progress bootProgress += progress
bootDetails = details setBootDetails(details)
} }
func IsBooted() bool { func IsBooted() bool {
@ -138,7 +142,7 @@ func GetBootProgress() float64 {
} }
func SetBooted() { func SetBooted() {
bootDetails = "Finishing boot..." setBootDetails("Finishing boot...")
bootProgress = 100 bootProgress = 100
logging.LogInfof("kernel booted") logging.LogInfof("kernel booted")
} }