private void OnLaunchedOrActivated(IActivatedEventArgs e) { try { Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { SYEngine.Core.Initialize(); // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; // Place the frame in the current Window Window.Current.Content = rootFrame; } BackgroundTaskHelper.Register("ToastBackgroundTask", new ToastNotificationActionTrigger()); if (e is LaunchActivatedEventArgs && (e as LaunchActivatedEventArgs).PrelaunchActivated == false) { if (rootFrame.Content == null) { string display = AppTool.GetLocalSetting(Settings.DisplayMode, ""); if (string.IsNullOrEmpty(display)) { rootFrame.Navigate(typeof(WelcomePage), (e as LaunchActivatedEventArgs).Arguments); } else { if (_isTabletMode) { rootFrame.Navigate(typeof(TabletMainPage), (e as LaunchActivatedEventArgs).Arguments); } else { rootFrame.Navigate(typeof(DesktopMainPage), (e as LaunchActivatedEventArgs).Arguments); } } } // Ensure the current window is active } else if (e.Kind == ActivationKind.StartupTask) { if (rootFrame.Content == null) { if (_isTabletMode) { rootFrame.Navigate(typeof(TabletMainPage), null); } else { rootFrame.Navigate(typeof(DesktopMainPage), null); } } } else if (e is ToastNotificationActivatedEventArgs toastActivationArgs) { if (rootFrame.Content == null) { if (_isTabletMode) { rootFrame.Navigate(typeof(TabletMainPage), toastActivationArgs.Argument); } else { rootFrame.Navigate(typeof(DesktopMainPage), toastActivationArgs.Argument); } } else { AppViewModel.AppInitByActivated(toastActivationArgs.Argument); } } else if (e is ProtocolActivatedEventArgs protocalArgs) { string arg = protocalArgs.Uri.Query.Replace("?", ""); if (rootFrame.Content == null) { if (_isTabletMode) { rootFrame.Navigate(typeof(TabletMainPage), arg); } else { rootFrame.Navigate(typeof(DesktopMainPage), arg); } } else { AppViewModel.AppInitByActivated(arg); } } Window.Current.Activate(); UIHelper.SetTitleBarColor(); } catch (Exception ex) { _logger.Error("启动出错", ex); } }