@@ -157,9 +157,13 @@ def build(self, page: ft.Page):
157157 self .llbot_card .build ()
158158
159159 # 检查更新/立即更新按钮
160+ self ._button_text = ft .Text ("检查更新" )
160161 self .check_update_button = ft .ElevatedButton (
161- "检查更新" ,
162- icon = ft .Icons .CLOUD_DOWNLOAD ,
162+ content = ft .Row (
163+ [ft .Icon (ft .Icons .CLOUD_DOWNLOAD ), self ._button_text ],
164+ tight = True ,
165+ spacing = 8 ,
166+ ),
163167 on_click = self ._on_check_or_update_click ,
164168 style = ft .ButtonStyle (
165169 color = ft .Colors .ON_PRIMARY ,
@@ -168,6 +172,7 @@ def build(self, page: ft.Page):
168172 padding = ft .padding .symmetric (horizontal = 24 , vertical = 12 ),
169173 )
170174 )
175+ self ._button_icon = self .check_update_button .content .controls [0 ]
171176
172177 # 加载中指示器
173178 self .loading_indicator = ft .ProgressRing (
@@ -305,6 +310,7 @@ def load_versions_async():
305310 async def update_ui ():
306311 self .pmhq_card .update_version (pmhq_version if pmhq_version else "未知" )
307312 self .llbot_card .update_version (llbot_version if llbot_version else "未知" )
313+ self ._sync_update_status ()
308314 if self .page :
309315 self .page .update ()
310316
@@ -356,11 +362,11 @@ async def update_ui():
356362
357363 has_any_update = any (info .has_update for _ , info in all_check_results )
358364 if has_any_update :
359- self .check_update_button . text = "立即更新"
360- self .check_update_button . icon = ft .Icons .DOWNLOAD
365+ self ._button_text . value = "立即更新"
366+ self ._button_icon . name = ft .Icons .DOWNLOAD
361367 else :
362- self .check_update_button . text = "检查更新"
363- self .check_update_button . icon = ft .Icons .CLOUD_DOWNLOAD
368+ self ._button_text . value = "检查更新"
369+ self ._button_icon . name = ft .Icons .CLOUD_DOWNLOAD
364370
365371 if self .page :
366372 self .page .update ()
@@ -380,11 +386,11 @@ async def update_ui():
380386
381387 def set_updates_found (self , updates_found : list ):
382388 if updates_found :
383- self .check_update_button . text = "立即更新"
384- self .check_update_button . icon = ft .Icons .DOWNLOAD
389+ self ._button_text . value = "立即更新"
390+ self ._button_icon . name = ft .Icons .DOWNLOAD
385391 else :
386- self .check_update_button . text = "检查更新"
387- self .check_update_button . icon = ft .Icons .CLOUD_DOWNLOAD
392+ self ._button_text . value = "检查更新"
393+ self ._button_icon . name = ft .Icons .CLOUD_DOWNLOAD
388394
389395 for component_name , update_info in updates_found :
390396 if component_name == "管理器" :
@@ -394,11 +400,10 @@ def set_updates_found(self, updates_found: list):
394400 elif component_name == "LLBot" :
395401 self .llbot_card .update_check_result (update_info )
396402
397- if self .page :
398- try :
399- self .page .update ()
400- except :
401- pass
403+ try :
404+ self .check_update_button .update ()
405+ except :
406+ pass
402407
403408 def _start_all_updates (self ):
404409 if not self .update_manager or not self .update_manager .has_updates :
@@ -495,8 +500,8 @@ async def on_complete():
495500 if self .page :
496501 self .page .pop_dialog ()
497502
498- self .check_update_button . text = "检查更新"
499- self .check_update_button . icon = ft .Icons .CLOUD_DOWNLOAD
503+ self ._button_text . value = "检查更新"
504+ self ._button_icon . name = ft .Icons .CLOUD_DOWNLOAD
500505
501506 self .app_card .clear_update_status ()
502507 self .pmhq_card .clear_update_status ()
@@ -571,14 +576,14 @@ def _close_dialog(self, dialog: ft.AlertDialog):
571576 self .page .pop_dialog ()
572577
573578 def refresh (self ):
579+ self ._sync_update_status ()
574580 self ._load_versions ()
575-
576- # 同步更新管理器的状态到卡片
581+
582+ def _sync_update_status ( self ):
577583 if self .update_manager and self .update_manager .has_updates :
578- self .check_update_button . text = "立即更新"
579- self .check_update_button . icon = ft .Icons .DOWNLOAD
584+ self ._button_text . value = "立即更新"
585+ self ._button_icon . name = ft .Icons .DOWNLOAD
580586
581- # 同步更新状态到卡片显示
582587 for name , info in self .update_manager .updates_found :
583588 if name == "管理器" :
584589 self .app_card .update_check_result (info )
@@ -587,11 +592,5 @@ def refresh(self):
587592 elif name == "LLBot" :
588593 self .llbot_card .update_check_result (info )
589594 else :
590- self .check_update_button .text = "检查更新"
591- self .check_update_button .icon = ft .Icons .CLOUD_DOWNLOAD
592-
593- if self .page :
594- try :
595- self .page .update ()
596- except :
597- pass
595+ self ._button_text .value = "检查更新"
596+ self ._button_icon .name = ft .Icons .CLOUD_DOWNLOAD
0 commit comments