diff --git a/src/ST.Client.Desktop/Models/MyAuthenticator.cs b/src/ST.Client.Desktop/Models/MyAuthenticator.cs index ff6bf795a..bd3f9f653 100644 --- a/src/ST.Client.Desktop/Models/MyAuthenticator.cs +++ b/src/ST.Client.Desktop/Models/MyAuthenticator.cs @@ -431,32 +431,7 @@ namespace System.Application.Models } #endif - public async Task GetQrCodeStream() - { - var qrCode = await Task.Run(() => - { - var bytes = Serializable.SMP(new[] { this.AuthenticatorData.ToLightweightExportDTO() }); -#if DEBUG - var bytes_compress_gzip = bytes.CompressByteArray(); -#endif - var bytes_compress_br = bytes.CompressByteArrayByBrotli(); -#if DEBUG - Toast.Show($"bytesLength, source: {bytes.Length}, gzip: {bytes_compress_gzip.Length}, br: {bytes_compress_br.Length}"); -#endif - (var result, var stream, var e) = QRCodeHelper.Create(bytes); - switch (result) - { - case QRCodeHelper.QRCodeCreateResult.DataTooLong: - Toast.Show(AppResources.AuthLocal_ExportToQRCodeTooLongErrorTip); - break; - case QRCodeHelper.QRCodeCreateResult.Exception: - Toast.Show(e!.ToString()); - break; - } - return stream; - }); - return qrCode; - } + public Task GetQrCodeStream() => AuthService.GetQrCodeStreamAsync(AuthenticatorData); /// /// 编辑令牌自定义名称 diff --git a/src/ST.Client.Desktop/Models/Settings2/GeneralSettings.cs b/src/ST.Client.Desktop/Models/Settings2/GeneralSettings.cs index 8e009194c..74517fac0 100644 --- a/src/ST.Client.Desktop/Models/Settings2/GeneralSettings.cs +++ b/src/ST.Client.Desktop/Models/Settings2/GeneralSettings.cs @@ -74,5 +74,11 @@ namespace System.Application.Models.Settings /// public static SerializableProperty> TextReaderProvider { get; } = GetProperty(defaultValue: (IReadOnlyDictionary?)null, autoSave: true); + + /// + /// 下载更新渠道 + /// + public static SerializableProperty UpdateChannel { get; } + = GetProperty(defaultValue: (UpdateChannelType)default, autoSave: true); } } \ No newline at end of file diff --git a/src/ST.Client.Desktop/Models/Settings2/UISettings.cs b/src/ST.Client.Desktop/Models/Settings2/UISettings.cs index 927c0a046..9b2951edd 100644 --- a/src/ST.Client.Desktop/Models/Settings2/UISettings.cs +++ b/src/ST.Client.Desktop/Models/Settings2/UISettings.cs @@ -13,13 +13,18 @@ namespace System.Application.Models.Settings static UISettings() { //Theme.ValueChanged += Theme_ValueChanged; +#if !__MOBILE__ AppGridSize.ValueChanged += AppGridSize_ValueChanged; +#endif } + +#if !__MOBILE__ private static void AppGridSize_ValueChanged(object? sender, ValueChangedEventArgs e) { SteamConnectService.Current.SteamApps.Refresh(); } +#endif //private static void Theme_ValueChanged(object sender, ValueChangedEventArgs e) //{ diff --git a/src/ST.Client.Desktop/Services/Mvvm/AuthService.cs b/src/ST.Client.Desktop/Services/Mvvm/AuthService.cs index 8c09e41ef..2d2e32199 100644 --- a/src/ST.Client.Desktop/Services/Mvvm/AuthService.cs +++ b/src/ST.Client.Desktop/Services/Mvvm/AuthService.cs @@ -3,6 +3,7 @@ using Newtonsoft.Json.Linq; using ReactiveUI; using System.Application.Entities; using System.Application.Models; +using System.Application.UI; using System.Application.UI.Resx; using System.Application.UI.ViewModels; using System.Collections.Generic; @@ -729,5 +730,39 @@ namespace System.Application.Services Toast.Show(ex.Message); } } + + public static async Task GetQrCodeStreamAsync(IEnumerable datas) + { + var qrCode = await Task.Run(() => + { + var dtos = datas.Select(x => x.ToLightweightExportDTO()).ToArray(); + var bytes = Serializable.SMP(dtos); +#if DEBUG + var bytes_compress_gzip = bytes.CompressByteArray(); +#endif + var bytes_compress_br = bytes.CompressByteArrayByBrotli(); +#if DEBUG + Toast.Show($"bytesLength, source: {bytes.Length}, gzip: {bytes_compress_gzip.Length}, br: {bytes_compress_br.Length}"); +#endif + (var result, var stream, var e) = QRCodeHelper.Create(bytes); + switch (result) + { + case QRCodeHelper.QRCodeCreateResult.DataTooLong: + Toast.Show(AppResources.AuthLocal_ExportToQRCodeTooLongErrorTip); + break; + case QRCodeHelper.QRCodeCreateResult.Exception: + Toast.Show(e!.ToString()); + break; + } + return stream; + }); + return qrCode; + } + + public static Task GetQrCodeStreamAsync(params IGAPAuthenticatorDTO[] datas) + { + IEnumerable datas_ = datas; + return GetQrCodeStreamAsync(datas_); + } } } \ No newline at end of file diff --git a/src/ST.Client.Desktop/UI/ViewModels/Pages/DebugPageViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Pages/DebugPageViewModel.cs index 10e3a0256..3b19131f2 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/Pages/DebugPageViewModel.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/Pages/DebugPageViewModel.cs @@ -42,8 +42,19 @@ namespace System.Application.UI.ViewModels { } + //async void TestHttp() + //{ + // var task1 = IHttpService.Instance.GetAsync("https://developers.google.com/android"); + // var task2 = IHttpService.Instance.GetAsync("https://developer.android.google.cn/"); + // var str = await Task.WhenAny(task1, task2); + // DebugString = str.Result ?? string.Empty; + //} + public void DebugButton_Click() { + //TestHttp(); + //return; + TestTextBoxWindow(0); //DebugButton_Click1(); diff --git a/src/ST.Client.Desktop/UI/ViewModels/Windows/LocalAuthPage/ExportAuthWindowViewModel.shared.cs b/src/ST.Client.Desktop/UI/ViewModels/Windows/LocalAuthPage/ExportAuthWindowViewModel.shared.cs index cf21c0253..1de461faa 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/Windows/LocalAuthPage/ExportAuthWindowViewModel.shared.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/Windows/LocalAuthPage/ExportAuthWindowViewModel.shared.cs @@ -8,7 +8,6 @@ using System.Linq; using System.Properties; using System.Threading.Tasks; using static System.Application.FilePicker2; -using WinAuth; namespace System.Application.UI.ViewModels { @@ -222,20 +221,7 @@ namespace System.Application.UI.ViewModels static async Task GetQRCodeAsync(Func? filter) { var datas = AuthService.Current.GetExportSourceAuthenticators(filter); - var qrCode = await Task.Run(() => - { - var dtos = datas.Select(x => x.ToLightweightExportDTO()).ToArray(); - var bytes = Serializable.SMP(dtos); -#if DEBUG - var bytes_compress_gzip = bytes.CompressByteArray(); -#endif - var bytes_compress_br = bytes.CompressByteArrayByBrotli(); -#if DEBUG - Toast.Show($"bytesLength, source: {bytes.Length}, gzip: {bytes_compress_gzip.Length}, br: {bytes_compress_br.Length}"); -#endif - return CreateQRCode(bytes_compress_br); - }); - return qrCode; + return await AuthService.GetQrCodeStreamAsync(datas); } /// @@ -258,21 +244,6 @@ namespace System.Application.UI.ViewModels async Task ExportAuthToQRCodeAsync() => await ExportAuthCore(async () => QRCode = await GetQRCodeAsync(Filter), ignorePath: true, ignorePassword: true); - static Stream? CreateQRCode(byte[] bytes) - { - (var result, var stream, var e) = QRCodeHelper.Create(bytes); - switch (result) - { - case QRCodeHelper.QRCodeCreateResult.DataTooLong: - Toast.Show(AppResources.AuthLocal_ExportToQRCodeTooLongErrorTip); - break; - case QRCodeHelper.QRCodeCreateResult.Exception: - Toast.Show(e!.ToString()); - break; - } - return stream; - } - /// /// 默认导出文件名 /// diff --git a/src/ST.Client/UpdateChannelType.cs b/src/ST.Client/UpdateChannelType.cs new file mode 100644 index 000000000..ed2c01119 --- /dev/null +++ b/src/ST.Client/UpdateChannelType.cs @@ -0,0 +1,17 @@ +namespace System.Application +{ + /// + /// 下载更新渠道类型 + /// + public enum UpdateChannelType + { + /// + /// 自动识别 + /// + Auto, + + GitHub, + + Gitee, + } +} \ No newline at end of file