perf: 新增强制输出日志功能

This commit is contained in:
知一一 2025-05-07 17:55:57 +08:00
parent cbaf97386b
commit e24fc7dfa3
1 changed files with 4 additions and 5 deletions

View File

@ -2346,7 +2346,7 @@ LoadSettings() {
SaveSettings(*) { SaveSettings(*) {
WriteSettings() WriteSettings()
MsgBox "设置已保存!" MsgBox "设置已保存!"
AddLog("设置已保存!") AddLog("设置已保存!", true)
} }
; 全局设置 Map 对象 ; 全局设置 Map 对象
global g_settings := Map( global g_settings := Map(
@ -2534,15 +2534,14 @@ BtnClear.OnEvent("Click", (*) => LogBox.Value := "")
if g_settings["Debug"] { if g_settings["Debug"] {
DebugGui.Show() DebugGui.Show()
} }
AddLog(text) { AddLog(text, forceOutput := false) { ; 默认参数设为false
; global LogBox
if (!IsObject(LogBox) || !LogBox.Hwnd) { if (!IsObject(LogBox) || !LogBox.Hwnd) {
return return
} }
static lastText := "" ; 静态变量保存上一条内容 static lastText := "" ; 静态变量保存上一条内容
global LogBox global LogBox
; 如果内容与上一条相同则跳过 ; 如果内容与上一条相同且不强制输出,则跳过
if (text = lastText) if (text = lastText && !forceOutput)
return return
lastText := text ; 保存当前内容供下次比较 lastText := text ; 保存当前内容供下次比较
timestamp := FormatTime(, "HH:mm:ss") timestamp := FormatTime(, "HH:mm:ss")