File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -117,6 +117,37 @@ public MainViewModel()
117117
118118 UpdateResultsSource ( ) ;
119119
120+ // 启动时自动检查更新
121+ _ = CheckUpdateOnStartupAsync ( ) ;
122+ }
123+
124+ private async Task CheckUpdateOnStartupAsync ( )
125+ {
126+ try
127+ {
128+ // 延迟 2 秒,让主界面先完成加载
129+ await Task . Delay ( 2000 ) ;
130+
131+ if ( UpdateViewModel . IsUpdateDialogOpen ) return ;
132+
133+ var updateInfo = await _updateService . CheckForUpdatesAsync ( ) ;
134+ if ( updateInfo != null )
135+ {
136+ var vm = new UpdateViewModel ( _updateService , updateInfo ) ;
137+ await OverlayDialog . ShowModal < UpdateDialog , UpdateViewModel > (
138+ vm ,
139+ options : new OverlayDialogOptions
140+ {
141+ Buttons = DialogButton . None ,
142+ Title = "软件更新" ,
143+ CanLightDismiss = false
144+ } ) ;
145+ }
146+ }
147+ catch
148+ {
149+ // 静默失败,不打扰用户
150+ }
120151 }
121152
122153 partial void OnConcurrencyChanged ( int value )
You can’t perform that action at this time.
0 commit comments