From 4f7f56278684f184c3a5a39ca269599569ad8104 Mon Sep 17 00:00:00 2001 From: Jeirc-X Date: Sun, 21 Jul 2024 23:29:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=9A=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=87=8D=E8=AF=95=E6=AC=A1=E6=95=B0=EF=BC=8C?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E8=B6=85=E8=BF=87=E9=87=8D=E8=AF=95=E6=AC=A1?= =?UTF-8?q?=E6=95=B0=E4=B8=8B=E8=BD=BD/=E4=B8=8A=E4=BC=A0=E4=BC=9A?= =?UTF-8?q?=E6=9A=82=E5=81=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Changes.md | 4 ++++ build/macos/Info.plist | 4 ++-- src/SyncClipboard.Core/I18n/Strings.Designer.cs | 9 +++++++++ src/SyncClipboard.Core/I18n/Strings.resx | 3 +++ src/SyncClipboard.Core/I18n/Strings.zh-CN.resx | 3 +++ .../Models/UserConfigs/SyncConfig.cs | 2 +- .../UserServices/SyncService/DownloadService.cs | 15 ++++++++------- .../ViewModels/SyncSettingViewModel.cs | 6 ++++++ src/SyncClipboard.Desktop/AppConfig.cs | 2 +- src/SyncClipboard.Desktop/Changes.md | 4 ++++ .../Views/SyncSettingPage.axaml | 5 +++++ src/SyncClipboard.WinUI3/AppConfig.cs | 2 +- .../Views/SyncSettingPage.xaml | 3 +++ 13 files changed, 50 insertions(+), 12 deletions(-) diff --git a/Changes.md b/Changes.md index 0a03ad91..1cf5a191 100644 --- a/Changes.md +++ b/Changes.md @@ -1,3 +1,7 @@ +v2.8.3.1 +- 功能:可以设置重试次数,失败超过重试次数下载/上传会暂停(#100) +- 功能:可以设置剪切文件时不上传(#107) + v2.8.3 - 修复:不设置hash上传图片/文件到服务器后,桌面客户端会无限重复设置剪贴板 - 修复:远程文件不存在时,只报错一次,不再无限弹窗、图标错乱(#87) diff --git a/build/macos/Info.plist b/build/macos/Info.plist index c9a885c0..e3a2711e 100644 --- a/build/macos/Info.plist +++ b/build/macos/Info.plist @@ -19,8 +19,8 @@ NSHighResolutionCapable CFBundleVersion - 0.7.4 + 0.7.4.1 CFBundleShortVersionString - 0.7.4 + 0.7.4.1 diff --git a/src/SyncClipboard.Core/I18n/Strings.Designer.cs b/src/SyncClipboard.Core/I18n/Strings.Designer.cs index 6961c466..4b272b84 100644 --- a/src/SyncClipboard.Core/I18n/Strings.Designer.cs +++ b/src/SyncClipboard.Core/I18n/Strings.Designer.cs @@ -879,6 +879,15 @@ public static string ResetToDefault { } } + /// + /// 查找类似 Retry Times 的本地化字符串。 + /// + public static string RetryTimes { + get { + return ResourceManager.GetString("RetryTimes", resourceCulture); + } + } + /// /// 查找类似 Run 的本地化字符串。 /// diff --git a/src/SyncClipboard.Core/I18n/Strings.resx b/src/SyncClipboard.Core/I18n/Strings.resx index 901c93f4..973ed464 100644 --- a/src/SyncClipboard.Core/I18n/Strings.resx +++ b/src/SyncClipboard.Core/I18n/Strings.resx @@ -522,4 +522,7 @@ Don't Upload When Cutting Files + + Retry Times + \ No newline at end of file diff --git a/src/SyncClipboard.Core/I18n/Strings.zh-CN.resx b/src/SyncClipboard.Core/I18n/Strings.zh-CN.resx index c16d629a..7f170635 100644 --- a/src/SyncClipboard.Core/I18n/Strings.zh-CN.resx +++ b/src/SyncClipboard.Core/I18n/Strings.zh-CN.resx @@ -522,4 +522,7 @@ 剪切文件时不上传 + + 重试次数 + \ No newline at end of file diff --git a/src/SyncClipboard.Core/Models/UserConfigs/SyncConfig.cs b/src/SyncClipboard.Core/Models/UserConfigs/SyncConfig.cs index de7679af..3d013d62 100644 --- a/src/SyncClipboard.Core/Models/UserConfigs/SyncConfig.cs +++ b/src/SyncClipboard.Core/Models/UserConfigs/SyncConfig.cs @@ -16,6 +16,6 @@ public record class SyncConfig public bool TrustInsecureCertificate { get; set; } = false; public uint MaxFileByte { get; set; } = 1024 * 1024 * 20; // 20MB public uint IntervalTime { get; set; } = 3; - public int RetryTimes { get; set; } = 3; + public uint RetryTimes { get; set; } = 3; public uint TimeOut { get; set; } = 100; } diff --git a/src/SyncClipboard.Core/UserServices/SyncService/DownloadService.cs b/src/SyncClipboard.Core/UserServices/SyncService/DownloadService.cs index 6ddcb0fb..d6384462 100644 --- a/src/SyncClipboard.Core/UserServices/SyncService/DownloadService.cs +++ b/src/SyncClipboard.Core/UserServices/SyncService/DownloadService.cs @@ -231,6 +231,10 @@ private async void StartPullLoop() _toastReporter = null; _logger.Write(LOG_TAG, "Canceled"); } + catch (Exception ex) + { + _logger.Write(LOG_TAG, ex.Message); + } } private void StopPullLoop() @@ -272,18 +276,15 @@ public void PushStoppedHandler() private void SetStatusOnError(ref int errorTimes, Exception ex) { errorTimes++; - if (errorTimes == 2) - { - _trayIcon.SetStatusString(SERVICE_NAME, $"Error. Failed times: {errorTimes}.\n{ex.Message}", true); - } + _trayIcon.SetStatusString(SERVICE_NAME, $"Error. Failed times: {errorTimes}.\n{ex.Message}", true); _logger.Write(ex.ToString()); - if (errorTimes == _syncConfig.RetryTimes) + if (errorTimes > _syncConfig.RetryTimes) { _notificationManager.SendText(I18n.Strings.FailedToDownloadClipboard, ex.Message); + throw new Exception("Download retry times reach limit"); } } - private async Task PullLoop(CancellationToken cancelToken) { int errorTimes = 0; @@ -304,9 +305,9 @@ private async Task PullLoop(CancellationToken cancelToken) ex = new Exception("Request timeout"); } - SetStatusOnError(ref errorTimes, ex); _toastReporter?.Cancel(); _toastReporter = null; + SetStatusOnError(ref errorTimes, ex); } finally { diff --git a/src/SyncClipboard.Core/ViewModels/SyncSettingViewModel.cs b/src/SyncClipboard.Core/ViewModels/SyncSettingViewModel.cs index cd725199..93374efe 100644 --- a/src/SyncClipboard.Core/ViewModels/SyncSettingViewModel.cs +++ b/src/SyncClipboard.Core/ViewModels/SyncSettingViewModel.cs @@ -44,6 +44,10 @@ partial void OnServerConfigChanged(ServerConfig value) private uint intervalTime; partial void OnIntervalTimeChanged(uint value) => ClientConfig = ClientConfig with { IntervalTime = value }; + [ObservableProperty] + private uint retryTimes; + partial void OnRetryTimesChanged(uint value) => ClientConfig = ClientConfig with { RetryTimes = value }; + [ObservableProperty] private uint timeOut; partial void OnTimeOutChanged(uint value) => ClientConfig = ClientConfig with { TimeOut = value }; @@ -78,6 +82,7 @@ partial void OnServerConfigChanged(ServerConfig value) partial void OnClientConfigChanged(SyncConfig value) { IntervalTime = value.IntervalTime; + RetryTimes = value.RetryTimes; SyncEnable = value.SyncSwitchOn; UseLocalServer = value.UseLocalServer; TimeOut = value.TimeOut; @@ -144,6 +149,7 @@ public SyncSettingViewModel(ConfigManager configManager, MainViewModel mainViewM _configManager.ListenConfig(config => ClientConfig = config); clientConfig = _configManager.GetConfig(); intervalTime = clientConfig.IntervalTime; + retryTimes = clientConfig.RetryTimes; syncEnable = clientConfig.SyncSwitchOn; useLocalServer = clientConfig.UseLocalServer; timeOut = clientConfig.TimeOut; diff --git a/src/SyncClipboard.Desktop/AppConfig.cs b/src/SyncClipboard.Desktop/AppConfig.cs index 35060fd1..b3953bce 100644 --- a/src/SyncClipboard.Desktop/AppConfig.cs +++ b/src/SyncClipboard.Desktop/AppConfig.cs @@ -6,7 +6,7 @@ internal class AppConfig : IAppConfig { public string AppId => Env.AppId; public string AppStringId => "SyncClipboard.Desktop"; - public string AppVersion => "0.7.4"; + public string AppVersion => "0.7.4.1"; public string UpdateApiUrl => "https://api.github.com/repos/Jeric-X/SyncClipboard.Desktop/releases"; public string UpdateUrl => "https://github.com/Jeric-X/SyncClipboard.Desktop/releases/latest"; } diff --git a/src/SyncClipboard.Desktop/Changes.md b/src/SyncClipboard.Desktop/Changes.md index 5861866f..d0211501 100644 --- a/src/SyncClipboard.Desktop/Changes.md +++ b/src/SyncClipboard.Desktop/Changes.md @@ -1,3 +1,7 @@ +0.7.4.1 +- 功能:可以设置重试次数,失败超过重试次数下载/上传会暂停(https://github.com/Jeric-X/SyncClipboard/issues/100) +- 功能:可以设置剪切文件时不上传(https://github.com/Jeric-X/SyncClipboard/issues/107) + 0.7.4 - 修复:不设置hash上传图片/文件到服务器后,桌面客户端会无限重复设置剪贴板 - 修复:在一些场景复制图片时,无法触发上传(https://github.com/Jeric-X/SyncClipboard/issues/88) diff --git a/src/SyncClipboard.Desktop/Views/SyncSettingPage.axaml b/src/SyncClipboard.Desktop/Views/SyncSettingPage.axaml index 6e919c45..3456d98e 100644 --- a/src/SyncClipboard.Desktop/Views/SyncSettingPage.axaml +++ b/src/SyncClipboard.Desktop/Views/SyncSettingPage.axaml @@ -118,6 +118,11 @@ + + + + + diff --git a/src/SyncClipboard.WinUI3/AppConfig.cs b/src/SyncClipboard.WinUI3/AppConfig.cs index 8673518c..d6935e79 100644 --- a/src/SyncClipboard.WinUI3/AppConfig.cs +++ b/src/SyncClipboard.WinUI3/AppConfig.cs @@ -6,7 +6,7 @@ internal class AppConfig : IAppConfig { public string AppId => Env.AppId; public string AppStringId => "SyncClipboard.WinUI"; - public string AppVersion => "2.8.3"; + public string AppVersion => "2.8.3.1"; public string UpdateApiUrl => "https://api.github.com/repos/Jeric-X/SyncClipboard/releases"; public string UpdateUrl => "https://github.com/Jeric-X/SyncClipboard/releases/latest"; } diff --git a/src/SyncClipboard.WinUI3/Views/SyncSettingPage.xaml b/src/SyncClipboard.WinUI3/Views/SyncSettingPage.xaml index 77c93efa..050e476a 100644 --- a/src/SyncClipboard.WinUI3/Views/SyncSettingPage.xaml +++ b/src/SyncClipboard.WinUI3/Views/SyncSettingPage.xaml @@ -111,6 +111,9 @@ + + +