mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 改进桌面端监控前端界面进程退出钩子
This commit is contained in:
parent
f2004f2b07
commit
a3bba94ad3
1 changed files with 12 additions and 5 deletions
|
|
@ -48,7 +48,7 @@ func HookDesktopUIProcJob() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if firstRunHookDesktopUIProcJob {
|
if firstRunHookDesktopUIProcJob {
|
||||||
// 等待启动结束再
|
// 等待启动结束再监控
|
||||||
time.Sleep(30 * time.Second)
|
time.Sleep(30 * time.Second)
|
||||||
firstRunHookDesktopUIProcJob = false
|
firstRunHookDesktopUIProcJob = false
|
||||||
return
|
return
|
||||||
|
|
@ -59,7 +59,9 @@ func HookDesktopUIProcJob() {
|
||||||
}
|
}
|
||||||
|
|
||||||
uiProcNames := []string{"siyuan", "electron"}
|
uiProcNames := []string{"siyuan", "electron"}
|
||||||
|
uiProcessCount := 0
|
||||||
util.UIProcessIDs.Range(func(uiProcIDArg, _ interface{}) bool {
|
util.UIProcessIDs.Range(func(uiProcIDArg, _ interface{}) bool {
|
||||||
|
uiProcessCount++
|
||||||
uiProcID, err := strconv.Atoi(uiProcIDArg.(string))
|
uiProcID, err := strconv.Atoi(uiProcIDArg.(string))
|
||||||
if nil != err {
|
if nil != err {
|
||||||
logging.LogErrorf("invalid UI proc ID [%s]: %s", uiProcIDArg, err)
|
logging.LogErrorf("invalid UI proc ID [%s]: %s", uiProcIDArg, err)
|
||||||
|
|
@ -73,18 +75,23 @@ func HookDesktopUIProcJob() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if nil == proc {
|
if nil == proc {
|
||||||
|
noUIProcCount++
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
procName := strings.ToLower(proc.Executable())
|
procName := strings.ToLower(proc.Executable())
|
||||||
|
uiProcOk := false
|
||||||
for _, name := range uiProcNames {
|
for _, name := range uiProcNames {
|
||||||
if strings.Contains(procName, name) {
|
uiProcOk = strings.Contains(procName, name)
|
||||||
noUIProcCount++
|
}
|
||||||
return false
|
if !uiProcOk {
|
||||||
}
|
noUIProcCount++
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
if 1 > uiProcessCount {
|
||||||
|
noUIProcCount++
|
||||||
|
}
|
||||||
|
|
||||||
if 0 < noUIProcCount {
|
if 0 < noUIProcCount {
|
||||||
logging.LogInfof("no active UI proc count [%d]", noUIProcCount)
|
logging.LogInfof("no active UI proc count [%d]", noUIProcCount)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue