This commit is contained in:
Daniel 2024-06-27 21:29:31 +08:00
parent c9d3a50fd4
commit ed5c4738f9
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
5 changed files with 38 additions and 22 deletions

View file

@ -81,7 +81,7 @@ type AppConf struct {
ShowChangelog bool `json:"showChangelog"` // 是否显示版本更新日志
CloudRegion int `json:"cloudRegion"` // 云端区域0中国大陆1北美
Snippet *conf.Snpt `json:"snippet"` // 代码片段
State int `json:"state"` // 运行状态0已经正常退出1运行中
DataIndexState int `json:"dataIndexState"` // 数据索引状态0已索引1未索引
m *sync.Mutex
}
@ -464,8 +464,8 @@ func InitConf() {
Conf.LocalIPs = util.GetLocalIPs()
if 1 == Conf.State {
// 上次未正常退出
if 1 == Conf.DataIndexState {
// 上次未正常完成数据索引
go func() {
util.WaitForUILoaded()
time.Sleep(2 * time.Second)
@ -477,7 +477,7 @@ func InitConf() {
}()
}
Conf.State = 1 // 运行中
Conf.DataIndexState = 0
Conf.Save()
logging.SetLogLevel(Conf.LogLevel)
@ -716,7 +716,6 @@ func (conf *AppConf) save0(data []byte) {
}
func (conf *AppConf) Close() {
conf.State = 0 // 已经正常退出
conf.Save()
}

View file

@ -429,4 +429,14 @@ func subscribeSQLEvents() {
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
eventbus.Subscribe(eventbus.EvtSQLIndexChanged, func() {
Conf.DataIndexState = 1
Conf.Save()
})
eventbus.Subscribe(eventbus.EvtSQLIndexFlushed, func() {
Conf.DataIndexState = 0
Conf.Save()
})
}