From 7de0c22052e6f829dc19b67350d51204bcdbb1e8 Mon Sep 17 00:00:00 2001 From: LuLu-ling Date: Mon, 11 May 2026 20:24:52 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=88=A0=E9=99=A4=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=97=A0=E7=94=A8=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/Application.xaml.cs | 46 +------ .../Modules/Base/ModBase.cs | 6 - .../Modules/ModWebServer.cs | 130 ------------------ .../PageInstance/PageInstanceExport.xaml.cs | 19 +-- 4 files changed, 7 insertions(+), 194 deletions(-) diff --git a/Plain Craft Launcher 2/Application.xaml.cs b/Plain Craft Launcher 2/Application.xaml.cs index 77dc88fbe..ba7158034 100644 --- a/Plain Craft Launcher 2/Application.xaml.cs +++ b/Plain Craft Launcher 2/Application.xaml.cs @@ -54,19 +54,6 @@ private void Application_Startup() // (sender As Object, e As StartupEventArgs) Environment.Exit((int)ModBase.ProcessReturnValues.Fail); } } - /* TODO ERROR: Skipped IfDirectiveTrivia - #If DEBUGRESERVED Then - */ /* TODO ERROR: Skipped DisabledTextTrivia - '制作更新包 - ElseIf args(0) = "--edit1" Then - ExeEdit(args(1), True) - Environment.Exit(ProcessReturnValues.TaskDone) - ElseIf args(0) = "--edit2" Then - ExeEdit(args(1), False) - Environment.Exit(ProcessReturnValues.TaskDone) - */ /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ } // 初始化文件结构 @@ -75,30 +62,7 @@ ElseIf args(0) = "--edit2" Then Directory.CreateDirectory(ModBase.PathTemp + "Cache"); Directory.CreateDirectory(ModBase.PathTemp + "Download"); Directory.CreateDirectory(ModBase.PathAppdata); - /* TODO ERROR: Skipped IfDirectiveTrivia - #If False Then - */ /* TODO ERROR: Skipped DisabledTextTrivia - '检测单例 - Dim ShouldWaitForExit As Boolean = args.Length > 0 AndAlso args(0) = "--wait" '要求等待已有的 PCL 退出 - Dim WaitRetryCount As Integer = 0 - WaitRetry: - Dim WindowHwnd As IntPtr = FindWindow(Nothing, "Plain Craft Launcher Community Edition ") - If WindowHwnd = IntPtr.Zero Then FindWindow(Nothing, "Plain Craft Launcher 2 Community Edition ") - If WindowHwnd <> IntPtr.Zero Then - If ShouldWaitForExit AndAlso WaitRetryCount < 20 Then '至多等待 10 秒 - WaitRetryCount += 1 - Thread.Sleep(500) - GoTo WaitRetry - End If - '将已有的 PCL 窗口拖出来 - ShowWindowToTop(WindowHwnd) - '播放提示音并退出 - Beep() - Environment.[Exit](ProcessReturnValues.Cancel) - End If - */ /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ // 设置 ToolTipService 默认值 + // 设置 ToolTipService 默认值 ToolTipService.InitialShowDelayProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(300)); ToolTipService.BetweenShowDelayProperty.OverrideMetadata(typeof(DependencyObject), @@ -159,14 +123,6 @@ End If // 计时 ModBase.Log("[Start] 第一阶段加载用时:" + (TimeUtils.GetTimeTick() - ModBase.ApplicationStartTick) + " ms"); ModBase.ApplicationStartTick = TimeUtils.GetTimeTick(); - // 执行测试 - /* TODO ERROR: Skipped IfDirectiveTrivia - #If DEBUGRESERVED Then - */ /* TODO ERROR: Skipped DisabledTextTrivia - Test() - */ /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ ModAnimation.AniControlEnabled += 1; } catch (Exception ex) diff --git a/Plain Craft Launcher 2/Modules/Base/ModBase.cs b/Plain Craft Launcher 2/Modules/Base/ModBase.cs index 0f8bcd8a4..763e281ef 100644 --- a/Plain Craft Launcher 2/Modules/Base/ModBase.cs +++ b/Plain Craft Launcher 2/Modules/Base/ModBase.cs @@ -3649,9 +3649,6 @@ public static void Log(string Text, LogLevel Level = LogLevel.Normal, string Tit ModMain.Hint("[调试模式] " + Text, ModMain.HintType.Info, false); break; } - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ case LogLevel.Hint: { ModMain.Hint(Text, ModMain.HintType.Critical, false); @@ -3756,9 +3753,6 @@ public static void Log(Exception Ex, string Desc, LogLevel Level = LogLevel.Debu ModMain.Hint("[调试模式] " + ExLine, ModMain.HintType.Info, false); break; } - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ case LogLevel.Hint: { var ExLine = Desc + ":" + Ex; diff --git a/Plain Craft Launcher 2/Modules/ModWebServer.cs b/Plain Craft Launcher 2/Modules/ModWebServer.cs index 7a0a76674..f090f0837 100644 --- a/Plain Craft Launcher 2/Modules/ModWebServer.cs +++ b/Plain Craft Launcher 2/Modules/ModWebServer.cs @@ -343,134 +343,4 @@ public static void StartNaidAuthorize(Action? completeCallback = null) } #endregion - - #region 旧的 HTTP 服务端实现 - - /* TODO ERROR: Skipped IfDirectiveTrivia - #If False - */ /* TODO ERROR: Skipped DisabledTextTrivia - Private Server As HttpListener - Public Class HttpServer - Public Sub New() - Server = New HttpListener() - Server.Prefixes.Add("http://127.0.0.1:29992/") - Server.Start() - Task.Run( - Async Function() - While True - Try - Dim Context As HttpListenerContext = Await Server.GetContextAsync() - ApiRoute(Context) - Catch ex As Exception - Log(ex, "[Server] 处理响应时发生错误") - End Try - End While - End Function) - End Sub - - Private CurrentStatus As New OAuthCompleteStatus() - - Public Sub ApiRoute(Context As HttpListenerContext) - - - Dim RequestUrl As String = Context.Request.Url.AbsolutePath - Dim OAuthCode As String = Nothing - - ' 多斜杠处理 - While RequestUrl.Contains("//") - RequestUrl = RequestUrl.Replace("//", "/") - End While - - Select Case RequestUrl - Case "/api/naid/oauth20/callback" - - Dim Query = Context.Request.Url.Query - If Query.StartsWith("?") Then Query = Query.Substring(1) - - '在 URL 参数中寻找授权码 - For Each Param As String In Query.Split("&"c) - If Param.StartsWithF("code=") Then - OAuthCode = Param.Substring(5) - End If - Next - - '设置状态信息 - If OAuthCode IsNot Nothing Then - Dim result = NatayarkProfileManager.GetNaidDataSync(OAuthCode) - If result Then - CurrentStatus.success = True - CurrentStatus.username = NatayarkProfileManager.NaidProfile.Username - Else - CurrentStatus.success = False - CurrentStatus.message = $"获取用户信息失败,请尝试重新登录" - CurrentStatus.stacktrace = NatayarkProfileManager.Exception.ToString() - End If - Else - CurrentStatus.success = False - CurrentStatus.message = $"回调参数无效: {Query}" - End If - - '重定向至结束页 - Context.Response.StatusCode = HttpStatusCode.Redirect - Context.Response.AddHeader("location", "/complete") - Context.Response.Close() - Case "/complete" - Try - Dim Data = GetResourceStream("Resources/oauth-complete.html") - If Data Is Nothing Then GoTo NotFound - Context.Response.StatusCode = HttpStatusCode.OK - Context.Response.AddHeader("Content-Type", "text/html, charset=utf-8") - Data.CopyTo(Context.Response.OutputStream) - Context.Response.OutputStream.Dispose() - Context.Response.Close() - Catch ex As Exception - GoTo NotFound - End Try - Case "/assets/background" - SyncLock ChangeLock - If PicAddress Is Nothing OrElse String.IsNullOrWhiteSpace(PicAddress) Then GoTo NotFound - Using FileReadStream As New FileStream(PicAddress, FileMode.Open, FileAccess.Read, FileShare.None, 16384, True) - Context.Response.StatusCode = HttpStatusCode.OK - Context.Response.AddHeader("Content-Type", "application/octet-stream") - FileReadStream.CopyTo(Context.Response.OutputStream) - Context.Response.OutputStream.Dispose() - Context.Response.Close() - End Using - End SyncLock - Case "/assets/icon.ico" - Try - Dim Data = GetResourceStream("Images/icon.ico") - If Data Is Nothing Then GoTo NotFound - Context.Response.StatusCode = HttpStatusCode.OK - Context.Response.AddHeader("Content-Type", "application/octet-stream") - Data.CopyTo(Context.Response.OutputStream) - Context.Response.OutputStream.Dispose() - Context.Response.Close() - Catch ex As Exception - GoTo NotFound - End Try - Case "/api/naid/oauth20/status" - Try - Dim status = JsonConvert.SerializeObject(CurrentStatus) - Dim buffer = Encoding.UTF8.GetBytes(status) - Context.Response.StatusCode = HttpStatusCode.OK - Context.Response.AddHeader("Content-Type", "application/json, charset=utf-8") - Context.Response.OutputStream.Write(buffer, 0, buffer.Length) - Context.Response.OutputStream.Dispose() - Context.Response.Close() - Catch ex As Exception - GoTo NotFound - End Try - Case Else - NotFound: - Context.Response.StatusCode = HttpStatusCode.NotFound - Context.Response.Close() - End Select - End Sub - End Class - */ /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ - - #endregion } \ No newline at end of file diff --git a/Plain Craft Launcher 2/Pages/PageInstance/PageInstanceExport.xaml.cs b/Plain Craft Launcher 2/Pages/PageInstance/PageInstanceExport.xaml.cs index bb7b3c460..3f533f188 100644 --- a/Plain Craft Launcher 2/Pages/PageInstance/PageInstanceExport.xaml.cs +++ b/Plain Craft Launcher 2/Pages/PageInstance/PageInstanceExport.xaml.cs @@ -735,10 +735,8 @@ private void StartExport(object sender, MouseButtonEventArgs e) var Loaders = new List(); #region 准备 PCL 文件 - - /* TODO ERROR: Skipped IfDirectiveTrivia - #If Not RELEASE Then - */ + + #if !RELEASE if (IncludePCL) Loaders.Add(new ModLoader.LoaderTask("下载 PCL 正式版", Loader => { @@ -749,9 +747,7 @@ private void StartExport(object sender, MouseButtonEventArgs e) ProgressWeight = 0.5d, Block = false }); - /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ + #endif #endregion @@ -840,14 +836,11 @@ private void StartExport(object sender, MouseButtonEventArgs e) Loader.Progress = 0.97d; // 复制 PCL 实例设置 ModBase.CopyDirectory(McInstance.PathInstance + @"PCL\", OverridesFolder + @"PCL\"); - /* TODO ERROR: Skipped IfDirectiveTrivia - #If RELEASE Then - */ /* TODO ERROR: Skipped DisabledTextTrivia + #if RELEASE '复制 PCL 本体 If IncludePCL Then CopyFile(ExePathWithName, CacheFolder & "Plain Craft Launcher.exe") - */ /* TODO ERROR: Skipped EndIfDirectiveTrivia - #End If - */ // 复制 PCL 个性化内容 + #endif + // 复制 PCL 个性化内容 if (IncludePCLCustom) { if (Directory.Exists(ModBase.ExePath + @"PCL\Pictures\"))