diff --git a/PCL.Core/App/JumpListService.cs b/PCL.Core/App/JumpListService.cs new file mode 100644 index 000000000..b4697caa8 --- /dev/null +++ b/PCL.Core/App/JumpListService.cs @@ -0,0 +1,35 @@ +using System.Windows; +using System.Windows.Shell; +using System.Windows.Threading; + +namespace PCL.Core.App; + +[LifecycleService(LifecycleState.Running)] +[LifecycleScope("jump-list", "跳转列表", false)] +public partial class JumpListService +{ + [LifecycleStart] + private static void _Start() + { + var app = Application.Current; + if (app is null) return; + var jumpList = new JumpList(); + jumpList.JumpItems.Add(new JumpTask + { + Title = States.Game.SelectedInstance, + CustomCategory = "最近实例", + Arguments = $"--launch {States.Game.SelectedInstance}" + }); + + // TODO: 添加收藏夹管理 + + if (app.Dispatcher.CheckAccess()) + { + JumpList.SetJumpList(app, jumpList); + } + else + { + app.Dispatcher.Invoke(() => JumpList.SetJumpList(app, jumpList), DispatcherPriority.Normal); + } + } +} \ No newline at end of file diff --git a/Plain Craft Launcher 2/Pages/PageLaunch/PageLaunchLeft.xaml.vb b/Plain Craft Launcher 2/Pages/PageLaunch/PageLaunchLeft.xaml.vb index 368ad5713..8988bb8ce 100644 --- a/Plain Craft Launcher 2/Pages/PageLaunch/PageLaunchLeft.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageLaunch/PageLaunchLeft.xaml.vb @@ -1,5 +1,6 @@ Imports PCL.Core.Utils Imports System.Windows +Imports PCL.Core.App Public Class PageLaunchLeft @@ -99,6 +100,16 @@ Public Class PageLaunchLeft RefreshButtonsUI() RefreshPage(False) '有可能选择的版本变化了,需要重新刷新 'If IsProfileVaild() = "" Then McLoginLoader.Start() '自动登录 + Dim args = Basics.CommandLineArguments + If args.Length = 2 AndAlso args(0) = "--launch" Then + Log("[Launch] 收到命令行启动参数,启动实例:" & args(1)) + Dim LaunchInstance As New McInstance(args(1)) + If LaunchInstance.Check() Then + McLaunchStart(New McLaunchOptions() With { .Instance = LaunchInstance }) + Else + Log("[Launch] 命令行参数提供的实例无效", LogLevel.Critical) + End If + End If End Sub) End Sub, "Instance Check", ThreadPriority.AboveNormal)