Skip to content

Commit 27cacd5

Browse files
committed
优化:移除 MainViewModel 冗余更新代码,优化错误弹窗样式
1 parent ab883c1 commit 27cacd5

2 files changed

Lines changed: 2 additions & 52 deletions

File tree

Dialogs/ViewModels/UpdateViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private async Task CheckUpdatesAsync()
7070
catch (Exception ex)
7171
{
7272
Status = DownloadStatus.Failed;
73-
await MessageBox.ShowOverlayAsync($"检查更新失败: {ex.Message}", "错误");
73+
await MessageBox.ShowOverlayAsync($"检查更新失败: {ex.Message}", "错误", icon: MessageBoxIcon.Error);
7474
}
7575
}
7676

@@ -100,7 +100,7 @@ await _updateService.DownloadUpdatesAsync(progress =>
100100
catch (Exception ex)
101101
{
102102
Status = DownloadStatus.Failed;
103-
await MessageBox.ShowOverlayAsync($"下载更新失败: {ex.Message}", "错误");
103+
await MessageBox.ShowOverlayAsync($"下载更新失败: {ex.Message}", "错误", icon: MessageBoxIcon.Error);
104104
}
105105
}
106106

ViewModels/MainViewModel.cs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ public MainViewModel()
117117

118118
UpdateResultsSource();
119119

120-
// Auto-check on startup
121-
_ = CheckUpdateAsync(true);
122120
}
123121

124122
partial void OnConcurrencyChanged(int value)
@@ -228,54 +226,6 @@ private IEnumerable<CheckResult> FilterResults()
228226
partial void OnFilterIspChanged(string value) => UpdateResultsSource();
229227
partial void OnResultsChanged(ObservableCollection<CheckResult> value) => UpdateResultsSource();
230228

231-
/// <summary>
232-
/// 检查更新
233-
/// </summary>
234-
/// <param name="silent">是否静默检查</param>
235-
[RelayCommand]
236-
private async Task CheckUpdateAsync(bool silent = false)
237-
{
238-
try
239-
{
240-
if (!silent)
241-
{
242-
var vm = new UpdateViewModel(_updateService);
243-
await OverlayDialog.ShowModal<UpdateDialog, UpdateViewModel>(
244-
vm,
245-
options: new OverlayDialogOptions
246-
{
247-
Buttons = DialogButton.None,
248-
Title = "软件更新",
249-
CanLightDismiss = false
250-
});
251-
}
252-
else
253-
{
254-
var info = await _updateService.CheckForUpdatesAsync();
255-
if (info != null)
256-
{
257-
var vm = new UpdateViewModel(_updateService);
258-
await OverlayDialog.ShowModal<UpdateDialog, UpdateViewModel>(
259-
vm,
260-
options: new OverlayDialogOptions
261-
{
262-
Buttons = DialogButton.None,
263-
IsCloseButtonVisible = false,
264-
Title = "发现新版本",
265-
CanLightDismiss = false
266-
});
267-
}
268-
}
269-
}
270-
catch (Exception ex)
271-
{
272-
await MessageBox.ShowOverlayAsync($"检查更新失败: {ex.Message}", "错误");
273-
}
274-
}
275-
276-
[RelayCommand]
277-
private Task CheckUpdateManualAsync() => CheckUpdateAsync(false);
278-
279229
[RelayCommand]
280230
private void ShowAbout()
281231
{

0 commit comments

Comments
 (0)