@@ -476,6 +476,10 @@ def check_wxauto_status(self):
476476 def check_wxautox_status (self ):
477477 """检查wxautox库的可用状态(能否成功导入)"""
478478 try :
479+ # 初始化日志标志
480+ if not hasattr (self , '_wxautox_status_logged' ):
481+ self ._wxautox_status_logged = {}
482+
479483 # 在打包环境中,避免使用subprocess检查,防止冲突
480484 is_frozen = getattr (sys , 'frozen' , False )
481485 if is_frozen :
@@ -484,21 +488,35 @@ def check_wxautox_status(self):
484488 import importlib .util
485489 spec = importlib .util .find_spec ('wxautox' )
486490 if spec is not None :
487- self .wxautox_status .config (text = "已打包" , style = "Green.TLabel" )
488- self .add_log ("wxautox库在打包环境中可用,准备检测激活状态" )
489- # 在打包环境中,延迟检测激活状态
490- self .root .after (1000 , self ._check_wxautox_activation_once )
491+ # 检查状态是否已经更新,避免重复日志
492+ current_status = self .wxautox_status .cget ("text" )
493+ if current_status != "已打包" :
494+ self .wxautox_status .config (text = "已打包" , style = "Green.TLabel" )
495+ if not self ._wxautox_status_logged .get ('packed_available' , False ):
496+ self .add_log ("wxautox库在打包环境中可用,准备检测激活状态" )
497+ self ._wxautox_status_logged ['packed_available' ] = True
498+ # 在打包环境中,延迟检测激活状态
499+ self .root .after (1000 , self ._check_wxautox_activation_once )
491500 return True
492501 else :
493- self .wxautox_status .config (text = "未打包" , style = "Red.TLabel" )
494- if hasattr (self , 'wxautox_activation_status' ):
495- self .wxautox_activation_status .config (text = "未打包" , style = "Red.TLabel" )
502+ current_status = self .wxautox_status .cget ("text" )
503+ if current_status != "未打包" :
504+ self .wxautox_status .config (text = "未打包" , style = "Red.TLabel" )
505+ if hasattr (self , 'wxautox_activation_status' ):
506+ self .wxautox_activation_status .config (text = "未打包" , style = "Red.TLabel" )
507+ # 重置日志标志
508+ self ._wxautox_status_logged = {}
496509 return False
497510 except Exception :
498- self .wxautox_status .config (text = "已打包" , style = "Green.TLabel" )
499- self .add_log ("wxautox库在打包环境中假设可用,准备检测激活状态" )
500- # 在打包环境中,延迟检测激活状态
501- self .root .after (1000 , self ._check_wxautox_activation_once )
511+ # 检查状态是否已经更新,避免重复日志
512+ current_status = self .wxautox_status .cget ("text" )
513+ if current_status != "已打包" :
514+ self .wxautox_status .config (text = "已打包" , style = "Green.TLabel" )
515+ if not self ._wxautox_status_logged .get ('packed_assumed' , False ):
516+ self .add_log ("wxautox库在打包环境中假设可用,准备检测激活状态" )
517+ self ._wxautox_status_logged ['packed_assumed' ] = True
518+ # 在打包环境中,延迟检测激活状态
519+ self .root .after (1000 , self ._check_wxautox_activation_once )
502520 return True # 假设可用,避免阻止启动
503521 else :
504522 # 在开发环境中,使用subprocess来检查wxautox,避免影响主进程
@@ -513,19 +531,28 @@ def check_wxautox_status(self):
513531 )
514532
515533 if result .returncode == 0 and "wxautox_available" in result .stdout :
516- self .wxautox_status .config (text = "可用" , style = "Green.TLabel" )
517- # 获取并显示版本号
518- version = self .get_package_version ('wxautox' )
519- self .wxautox_version .config (text = version )
520- self .add_log ("wxautox库检测为可用,将在微信初始化成功后检测激活状态" )
534+ # 检查状态是否已经更新,避免重复日志
535+ current_status = self .wxautox_status .cget ("text" )
536+ if current_status != "可用" :
537+ self .wxautox_status .config (text = "可用" , style = "Green.TLabel" )
538+ # 获取并显示版本号
539+ version = self .get_package_version ('wxautox' )
540+ self .wxautox_version .config (text = version )
541+ if not self ._wxautox_status_logged .get ('dev_available' , False ):
542+ self .add_log ("wxautox库检测为可用,将在微信初始化成功后检测激活状态" )
543+ self ._wxautox_status_logged ['dev_available' ] = True
521544 # 不立即检测激活状态,等待微信初始化成功后再检测
522545 return True
523546 else :
524- self .wxautox_status .config (text = "不可用" , style = "Red.TLabel" )
525- self .wxautox_version .config (text = "" )
526- # 更新激活状态显示
527- if hasattr (self , 'wxautox_activation_status' ):
528- self .wxautox_activation_status .config (text = "未激活" , style = "Red.TLabel" )
547+ current_status = self .wxautox_status .cget ("text" )
548+ if current_status != "不可用" :
549+ self .wxautox_status .config (text = "不可用" , style = "Red.TLabel" )
550+ self .wxautox_version .config (text = "" )
551+ # 更新激活状态显示
552+ if hasattr (self , 'wxautox_activation_status' ):
553+ self .wxautox_activation_status .config (text = "未激活" , style = "Red.TLabel" )
554+ # 重置日志标志
555+ self ._wxautox_status_logged = {}
529556 return False
530557 except subprocess .TimeoutExpired :
531558 self .wxautox_status .config (text = "检查超时" , style = "Red.TLabel" )
0 commit comments