1717from one_dragon .envs .env_config import ProxyTypeEnum
1818from one_dragon .utils import os_utils
1919from one_dragon .utils .i18_utils import gt
20+ from one_dragon .utils .log_utils import log
2021from one_dragon_qt .services .theme_manager import ThemeManager
2122from one_dragon_qt .widgets .column import Column
2223from one_dragon_qt .widgets .setting_card .combo_box_setting_card import (
@@ -72,20 +73,24 @@ def run(self) -> None:
7273 latest_stable , latest_beta = self .ctx .github_update_service .get_latest_tags ()
7374 self .check_finished .emit (True , latest_stable , latest_beta , '' )
7475 except Exception as e :
76+ log .error ('检查 GitHub 更新失败' , exc_info = True )
7577 self .check_finished .emit (False , '' , '' , str (e ))
7678
7779
7880class GhProxyUpdateRunner (QThread ):
7981
80- update_finished = Signal (str )
82+ update_finished = Signal (bool , str )
8183
8284 def __init__ (self , ctx : ScriptChainerContext ):
8385 QThread .__init__ (self )
8486 self .ctx = ctx
8587
8688 def run (self ) -> None :
87- self .ctx .gh_proxy_service .update_proxy_url ()
88- self .update_finished .emit (self .ctx .env_config .gh_proxy_url )
89+ success = False
90+ try :
91+ success = self .ctx .gh_proxy_service .update_proxy_url ()
92+ finally :
93+ self .update_finished .emit (success , self .ctx .env_config .gh_proxy_url )
8994
9095
9196class GithubUpdateCard (MultiPushSettingCard ):
@@ -259,6 +264,7 @@ class EditorSettingInterface(VerticalScrollInterface):
259264
260265 def __init__ (self , ctx : ScriptChainerContext , parent = None ):
261266 self .ctx : ScriptChainerContext = ctx
267+ self ._gh_proxy_auto_refreshed = False
262268 self .gh_proxy_update_runner = GhProxyUpdateRunner (ctx )
263269 self .gh_proxy_update_runner .update_finished .connect (self ._on_gh_proxy_update_finished )
264270
@@ -396,6 +402,8 @@ def on_fetch_gh_proxy_url_clicked(self) -> None:
396402 self .start_gh_proxy_url_refresh ()
397403
398404 def refresh_gh_proxy_url_by_config (self ) -> None :
405+ if self ._gh_proxy_auto_refreshed :
406+ return
399407 if not self .ctx .env_config .auto_fetch_gh_proxy_url :
400408 return
401409 if self .ctx .env_config .proxy_type != ProxyTypeEnum .GHPROXY .value .value :
@@ -408,8 +416,9 @@ def start_gh_proxy_url_refresh(self) -> None:
408416 self .fetch_gh_proxy_url_btn .setDisabled (True )
409417 self .gh_proxy_update_runner .start ()
410418
411- def _on_gh_proxy_update_finished (self , _proxy_url : str ) -> None :
412- self .gh_proxy_url_opt .setValue (_proxy_url , emit_signal = False )
419+ def _on_gh_proxy_update_finished (self , success : bool , proxy_url : str ) -> None :
420+ self ._gh_proxy_auto_refreshed = success
421+ self .gh_proxy_url_opt .setValue (proxy_url , emit_signal = False )
413422 self .fetch_gh_proxy_url_btn .setEnabled (True )
414423
415424 def update_proxy_ui (self ) -> None :
0 commit comments