diff --git a/src/Common.CoreLib/Net/WebSocket/WebSocketServer.cs b/src/Common.CoreLib/Net/WebSocket/WebSocketServer.cs index a626839b0..0e9b9e87a 100644 --- a/src/Common.CoreLib/Net/WebSocket/WebSocketServer.cs +++ b/src/Common.CoreLib/Net/WebSocket/WebSocketServer.cs @@ -52,11 +52,19 @@ namespace System.Net.WebSocket readonly CancellationTokenSource tokenSource = new(); - private bool isStarted; - public async Task StartAsync() + bool isStarted; + public void Start() { if (isStarted) return; isStarted = true; + Task.Factory.StartNew(StartCore, + tokenSource.Token, + TaskCreationOptions.LongRunning, + TaskScheduler.Default); + } + + async void StartCore() + { listener.Start(); RunState = true; try diff --git a/src/Common.CoreLib/Properties/ThisAssembly.DynamicVersion.cs b/src/Common.CoreLib/Properties/ThisAssembly.DynamicVersion.cs index aedffa520..fe937c879 100644 --- a/src/Common.CoreLib/Properties/ThisAssembly.DynamicVersion.cs +++ b/src/Common.CoreLib/Properties/ThisAssembly.DynamicVersion.cs @@ -11,6 +11,8 @@ namespace System.Properties { switch (DI.Platform) { + case Platform.Windows: + return DI.IsDesktopBridge ? Version + alpha : Version; case Platform.Linux: return Version + alpha; case Platform.Android: diff --git a/src/ST.Client.Desktop.Avalonia.App.Bridge.Package/Package.appxmanifest b/src/ST.Client.Desktop.Avalonia.App.Bridge.Package/Package.appxmanifest index 50ef20b55..fb115f865 100644 --- a/src/ST.Client.Desktop.Avalonia.App.Bridge.Package/Package.appxmanifest +++ b/src/ST.Client.Desktop.Avalonia.App.Bridge.Package/Package.appxmanifest @@ -4,6 +4,7 @@ xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" + xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10" IgnorableNamespaces="uap rescap"> - + + + + diff --git a/src/ST.Client.Desktop.Avalonia.App/App.axaml.cs b/src/ST.Client.Desktop.Avalonia.App/App.axaml.cs index f38ae2a9d..21eee23fd 100644 --- a/src/ST.Client.Desktop.Avalonia.App/App.axaml.cs +++ b/src/ST.Client.Desktop.Avalonia.App/App.axaml.cs @@ -295,11 +295,17 @@ namespace System.Application.UI void Desktop_Startup(object? sender, ControlledApplicationLifetimeStartupEventArgs e) { + + var isOfficialChannelPackage = IsNotOfficialChannelPackageDetectionHelper.Check(Program.IsMainProcess); + #if StartupTrace StartupTrace.Restart("Desktop_Startup.Start"); #endif #if WINDOWS - VisualStudioAppCenterSDK.Init(); + if (isOfficialChannelPackage) + { + VisualStudioAppCenterSDK.Init(); + } #endif #if StartupTrace StartupTrace.Restart("AppCenterSDK.Init"); diff --git a/src/ST.Client.Desktop.Avalonia/Application/Services/IDesktopAvaloniaAppService.cs b/src/ST.Client.Desktop.Avalonia/Application/Services/IDesktopAvaloniaAppService.cs index 3b2330f03..97b05bbeb 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/Services/IDesktopAvaloniaAppService.cs +++ b/src/ST.Client.Desktop.Avalonia/Application/Services/IDesktopAvaloniaAppService.cs @@ -25,13 +25,36 @@ namespace System.Application.Services async Task ShowDialogWindow(Window window) { var owner = GetActiveWindow(); - await window.ShowDialog(owner); + if (owner != null) + { + try + { + await window.ShowDialog(owner); + return; + } + catch (InvalidOperationException) + { + } + } + window.Show(); } void ShowWindow(Window window) { var owner = GetActiveWindow(); - window.Show(owner); + if (owner != null) + { + try + { + window.Show(owner); + return; + } + catch (InvalidOperationException) + { + } + + } + window.Show(); } void ShowWindowNoParent(Window window) diff --git a/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/ShowWindowServiceImpl.cs b/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/ShowWindowServiceImpl.cs index 0204d915d..958814ea8 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/ShowWindowServiceImpl.cs +++ b/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/ShowWindowServiceImpl.cs @@ -57,10 +57,11 @@ namespace System.Application.Services.Implementation { return; } - var window = (Window)Activator.CreateInstance(windowType); + var window = (Window?)Activator.CreateInstance(windowType); + if (window == null) return; if (viewModel == null && typeWindowViewModel != typeof(object)) { - viewModel = (WindowViewModel)Activator.CreateInstance(typeWindowViewModel); + viewModel = (WindowViewModel?)Activator.CreateInstance(typeWindowViewModel); } if (!string.IsNullOrEmpty(title) && viewModel != null) { @@ -92,14 +93,14 @@ namespace System.Application.Services.Implementation } if (viewModel == null) { - void Window_DataContextChanged(object _, EventArgs __) + void Window_DataContextChanged(object? _, EventArgs __) { if (window.DataContext is DialogWindowViewModel dialogWindowViewModel) { BindingDialogWindowViewModel(window, dialogWindowViewModel, actionDialogWindowViewModel); } } - void Window_Closed(object _, EventArgs __) + void Window_Closed(object? _, EventArgs __) { window.DataContextChanged -= Window_DataContextChanged; window.Closed -= Window_Closed; @@ -113,16 +114,24 @@ namespace System.Application.Services.Implementation } } if (viewModel != null) window.DataContext = viewModel; - if (isDialog) + try { - await IDesktopAvaloniaAppService.Instance.ShowDialogWindow(window); - } - else - { - if (isParent) - IDesktopAvaloniaAppService.Instance.ShowWindow(window); + if (isDialog) + { + await IDesktopAvaloniaAppService.Instance.ShowDialogWindow(window); + } else - IDesktopAvaloniaAppService.Instance.ShowWindowNoParent(window); + { + if (isParent) + IDesktopAvaloniaAppService.Instance.ShowWindow(window); + else + IDesktopAvaloniaAppService.Instance.ShowWindowNoParent(window); + } + } + catch (Exception e) + { + Log.Error(nameof(ShowWindowServiceImpl), e, + "Show fail, windowType: {0}", window?.GetType().Name); } }); @@ -173,17 +182,41 @@ namespace System.Application.Services.Implementation public void CloseWindow(WindowViewModel vm) { - IDesktopAvaloniaAppService.Instance.CloseWindow(vm); + try + { + IDesktopAvaloniaAppService.Instance.CloseWindow(vm); + } + catch (Exception e) + { + Log.Error(nameof(ShowWindowServiceImpl), e, + "CloseWindow fail, vmType: {0}", vm.GetType().Name); + } } public void HideWindow(WindowViewModel vm) { - IDesktopAvaloniaAppService.Instance.HideWindow(vm); + try + { + IDesktopAvaloniaAppService.Instance.HideWindow(vm); + } + catch (Exception e) + { + Log.Error(nameof(ShowWindowServiceImpl), e, + "HideWindow fail, vmType: {0}", vm.GetType().Name); + } } public void ShowWindow(WindowViewModel vm) { - IDesktopAvaloniaAppService.Instance.ShowWindowNoParent(vm); + try + { + IDesktopAvaloniaAppService.Instance.ShowWindowNoParent(vm); + } + catch (Exception e) + { + Log.Error(nameof(ShowWindowServiceImpl), e, + "ShowWindowNoParent fail, vmType: {0}", vm.GetType().Name); + } } } } \ No newline at end of file diff --git a/src/ST.Client.Desktop.Windows/Services/Implementation/WindowsDesktopPlatformServiceImpl.cs b/src/ST.Client.Desktop.Windows/Services/Implementation/WindowsDesktopPlatformServiceImpl.cs index 75736c1a8..f349a3f66 100644 --- a/src/ST.Client.Desktop.Windows/Services/Implementation/WindowsDesktopPlatformServiceImpl.cs +++ b/src/ST.Client.Desktop.Windows/Services/Implementation/WindowsDesktopPlatformServiceImpl.cs @@ -124,6 +124,9 @@ namespace System.Application.Services.Implementation public void SetBootAutoStart(bool isAutoStart, string name) { + global::Windows.ApplicationModel.AppInstance.GetActivatedEventArgs() + global::Windows.UI.ap + //global::Windows.ApplicationModel.app // 开机启动使用 taskschd.msc 实现 try { diff --git a/src/ST.Client.Desktop/Security/IsNotOfficialChannelPackageDetectionHelper.cs b/src/ST.Client.Desktop/Security/IsNotOfficialChannelPackageDetectionHelper.cs index 337e869cd..f7e5068e9 100644 --- a/src/ST.Client.Desktop/Security/IsNotOfficialChannelPackageDetectionHelper.cs +++ b/src/ST.Client.Desktop/Security/IsNotOfficialChannelPackageDetectionHelper.cs @@ -7,7 +7,12 @@ namespace System.Application.Security { public static class IsNotOfficialChannelPackageDetectionHelper { - public static bool Check() + /// + /// + /// + /// + /// + public static bool Check(bool showMessageBox = true) { var value = AppSettings.IsOfficialChannelPackage; if (!value) @@ -18,7 +23,7 @@ namespace System.Application.Security var title = AppResources.Warning; MessageBoxCompat.Show(text, title, MessageBoxButtonCompat.OK, MessageBoxImageCompat.Warning); } - IsNotOfficialChannelPackageWarning(); + if (showMessageBox) IsNotOfficialChannelPackageWarning(); } return value; } diff --git a/src/ST.Client.Desktop/UI/ViewModels/FastLRBHelper.cs b/src/ST.Client.Desktop/UI/ViewModels/FastLRBHelper.cs index 7b64500dc..93f5addbf 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/FastLRBHelper.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/FastLRBHelper.cs @@ -178,7 +178,7 @@ namespace System.Application.UI.ViewModels vm.ServerWebSocketListenerPort = port; vm.ServerWebSocket.OnClientReceived += e => vm.OnClientReceived(e); } - await vm.ServerWebSocket.StartAsync(); + vm.ServerWebSocket.Start(); var conn_helper = DI.Get(); var apiBaseUrl = "https://127.0.0.1:28110"; //ICloudServiceClient.Instance.ApiBaseUrl; vm.TempAes.RemoveTo(vm); diff --git a/src/ST.Client.Mobile.Droid.Design/ui/src/main/res/layout/activity_settings.xml b/src/ST.Client.Mobile.Droid.Design/ui/src/main/res/layout/activity_settings.xml index e2eba2f68..a8f7d800b 100644 --- a/src/ST.Client.Mobile.Droid.Design/ui/src/main/res/layout/activity_settings.xml +++ b/src/ST.Client.Mobile.Droid.Design/ui/src/main/res/layout/activity_settings.xml @@ -373,7 +373,7 @@ xamarin:managedType="AndroidX.AppCompat.Widget.AppCompatImageView" /> @@ -394,6 +394,22 @@ android:textColor="@color/text_secondary" xamarin:managedType="AndroidX.AppCompat.Widget.AppCompatTextView" /> + + + + diff --git a/src/ST.Client.Mobile.Droid/UI/Activities/SettingsActivity.cs b/src/ST.Client.Mobile.Droid/UI/Activities/SettingsActivity.cs index b82d4225a..253fe327b 100644 --- a/src/ST.Client.Mobile.Droid/UI/Activities/SettingsActivity.cs +++ b/src/ST.Client.Mobile.Droid/UI/Activities/SettingsActivity.cs @@ -7,6 +7,7 @@ using Binding; using ReactiveUI; using System.Application.Models; using System.Application.Models.Settings; +using System.Application.Services; using System.Application.UI.Resx; using System.Application.UI.ViewModels; using System.Collections.Generic; @@ -104,6 +105,12 @@ namespace System.Application.UI.Activities }); } + protected override void OnResume() + { + base.OnResume(); + binding!.swOSAppNotificationSettings.Enabled = INotificationService.Instance.AreNotificationsEnabled(); + } + protected override void OnClick(View view) { foreach (var item in comboBoxs)