Skip to content

Commit 7de0c22

Browse files
committed
chore: 删除一些无用代码
1 parent d125031 commit 7de0c22

4 files changed

Lines changed: 7 additions & 194 deletions

File tree

Plain Craft Launcher 2/Application.xaml.cs

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,6 @@ private void Application_Startup() // (sender As Object, e As StartupEventArgs)
5454
Environment.Exit((int)ModBase.ProcessReturnValues.Fail);
5555
}
5656
}
57-
/* TODO ERROR: Skipped IfDirectiveTrivia
58-
#If DEBUGRESERVED Then
59-
*/ /* TODO ERROR: Skipped DisabledTextTrivia
60-
'制作更新包
61-
ElseIf args(0) = "--edit1" Then
62-
ExeEdit(args(1), True)
63-
Environment.Exit(ProcessReturnValues.TaskDone)
64-
ElseIf args(0) = "--edit2" Then
65-
ExeEdit(args(1), False)
66-
Environment.Exit(ProcessReturnValues.TaskDone)
67-
*/ /* TODO ERROR: Skipped EndIfDirectiveTrivia
68-
#End If
69-
*/
7057
}
7158

7259
// 初始化文件结构
@@ -75,30 +62,7 @@ ElseIf args(0) = "--edit2" Then
7562
Directory.CreateDirectory(ModBase.PathTemp + "Cache");
7663
Directory.CreateDirectory(ModBase.PathTemp + "Download");
7764
Directory.CreateDirectory(ModBase.PathAppdata);
78-
/* TODO ERROR: Skipped IfDirectiveTrivia
79-
#If False Then
80-
*/ /* TODO ERROR: Skipped DisabledTextTrivia
81-
'检测单例
82-
Dim ShouldWaitForExit As Boolean = args.Length > 0 AndAlso args(0) = "--wait" '要求等待已有的 PCL 退出
83-
Dim WaitRetryCount As Integer = 0
84-
WaitRetry:
85-
Dim WindowHwnd As IntPtr = FindWindow(Nothing, "Plain Craft Launcher Community Edition ")
86-
If WindowHwnd = IntPtr.Zero Then FindWindow(Nothing, "Plain Craft Launcher 2 Community Edition ")
87-
If WindowHwnd <> IntPtr.Zero Then
88-
If ShouldWaitForExit AndAlso WaitRetryCount < 20 Then '至多等待 10 秒
89-
WaitRetryCount += 1
90-
Thread.Sleep(500)
91-
GoTo WaitRetry
92-
End If
93-
'将已有的 PCL 窗口拖出来
94-
ShowWindowToTop(WindowHwnd)
95-
'播放提示音并退出
96-
Beep()
97-
Environment.[Exit](ProcessReturnValues.Cancel)
98-
End If
99-
*/ /* TODO ERROR: Skipped EndIfDirectiveTrivia
100-
#End If
101-
*/ // 设置 ToolTipService 默认值
65+
// 设置 ToolTipService 默认值
10266
ToolTipService.InitialShowDelayProperty.OverrideMetadata(typeof(DependencyObject),
10367
new FrameworkPropertyMetadata(300));
10468
ToolTipService.BetweenShowDelayProperty.OverrideMetadata(typeof(DependencyObject),
@@ -159,14 +123,6 @@ End If
159123
// 计时
160124
ModBase.Log("[Start] 第一阶段加载用时:" + (TimeUtils.GetTimeTick() - ModBase.ApplicationStartTick) + " ms");
161125
ModBase.ApplicationStartTick = TimeUtils.GetTimeTick();
162-
// 执行测试
163-
/* TODO ERROR: Skipped IfDirectiveTrivia
164-
#If DEBUGRESERVED Then
165-
*/ /* TODO ERROR: Skipped DisabledTextTrivia
166-
Test()
167-
*/ /* TODO ERROR: Skipped EndIfDirectiveTrivia
168-
#End If
169-
*/
170126
ModAnimation.AniControlEnabled += 1;
171127
}
172128
catch (Exception ex)

Plain Craft Launcher 2/Modules/Base/ModBase.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3649,9 +3649,6 @@ public static void Log(string Text, LogLevel Level = LogLevel.Normal, string Tit
36493649
ModMain.Hint("[调试模式] " + Text, ModMain.HintType.Info, false);
36503650
break;
36513651
}
3652-
/* TODO ERROR: Skipped EndIfDirectiveTrivia
3653-
#End If
3654-
*/
36553652
case LogLevel.Hint:
36563653
{
36573654
ModMain.Hint(Text, ModMain.HintType.Critical, false);
@@ -3756,9 +3753,6 @@ public static void Log(Exception Ex, string Desc, LogLevel Level = LogLevel.Debu
37563753
ModMain.Hint("[调试模式] " + ExLine, ModMain.HintType.Info, false);
37573754
break;
37583755
}
3759-
/* TODO ERROR: Skipped EndIfDirectiveTrivia
3760-
#End If
3761-
*/
37623756
case LogLevel.Hint:
37633757
{
37643758
var ExLine = Desc + ":" + Ex;

Plain Craft Launcher 2/Modules/ModWebServer.cs

Lines changed: 0 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -343,134 +343,4 @@ public static void StartNaidAuthorize(Action? completeCallback = null)
343343
}
344344

345345
#endregion
346-
347-
#region 旧的 HTTP 服务端实现
348-
349-
/* TODO ERROR: Skipped IfDirectiveTrivia
350-
#If False
351-
*/ /* TODO ERROR: Skipped DisabledTextTrivia
352-
Private Server As HttpListener
353-
Public Class HttpServer
354-
Public Sub New()
355-
Server = New HttpListener()
356-
Server.Prefixes.Add("http://127.0.0.1:29992/")
357-
Server.Start()
358-
Task.Run(
359-
Async Function()
360-
While True
361-
Try
362-
Dim Context As HttpListenerContext = Await Server.GetContextAsync()
363-
ApiRoute(Context)
364-
Catch ex As Exception
365-
Log(ex, "[Server] 处理响应时发生错误")
366-
End Try
367-
End While
368-
End Function)
369-
End Sub
370-
371-
Private CurrentStatus As New OAuthCompleteStatus()
372-
373-
Public Sub ApiRoute(Context As HttpListenerContext)
374-
375-
376-
Dim RequestUrl As String = Context.Request.Url.AbsolutePath
377-
Dim OAuthCode As String = Nothing
378-
379-
' 多斜杠处理
380-
While RequestUrl.Contains("//")
381-
RequestUrl = RequestUrl.Replace("//", "/")
382-
End While
383-
384-
Select Case RequestUrl
385-
Case "/api/naid/oauth20/callback"
386-
387-
Dim Query = Context.Request.Url.Query
388-
If Query.StartsWith("?") Then Query = Query.Substring(1)
389-
390-
'在 URL 参数中寻找授权码
391-
For Each Param As String In Query.Split("&"c)
392-
If Param.StartsWithF("code=") Then
393-
OAuthCode = Param.Substring(5)
394-
End If
395-
Next
396-
397-
'设置状态信息
398-
If OAuthCode IsNot Nothing Then
399-
Dim result = NatayarkProfileManager.GetNaidDataSync(OAuthCode)
400-
If result Then
401-
CurrentStatus.success = True
402-
CurrentStatus.username = NatayarkProfileManager.NaidProfile.Username
403-
Else
404-
CurrentStatus.success = False
405-
CurrentStatus.message = $"获取用户信息失败,请尝试重新登录"
406-
CurrentStatus.stacktrace = NatayarkProfileManager.Exception.ToString()
407-
End If
408-
Else
409-
CurrentStatus.success = False
410-
CurrentStatus.message = $"回调参数无效: {Query}"
411-
End If
412-
413-
'重定向至结束页
414-
Context.Response.StatusCode = HttpStatusCode.Redirect
415-
Context.Response.AddHeader("location", "/complete")
416-
Context.Response.Close()
417-
Case "/complete"
418-
Try
419-
Dim Data = GetResourceStream("Resources/oauth-complete.html")
420-
If Data Is Nothing Then GoTo NotFound
421-
Context.Response.StatusCode = HttpStatusCode.OK
422-
Context.Response.AddHeader("Content-Type", "text/html, charset=utf-8")
423-
Data.CopyTo(Context.Response.OutputStream)
424-
Context.Response.OutputStream.Dispose()
425-
Context.Response.Close()
426-
Catch ex As Exception
427-
GoTo NotFound
428-
End Try
429-
Case "/assets/background"
430-
SyncLock ChangeLock
431-
If PicAddress Is Nothing OrElse String.IsNullOrWhiteSpace(PicAddress) Then GoTo NotFound
432-
Using FileReadStream As New FileStream(PicAddress, FileMode.Open, FileAccess.Read, FileShare.None, 16384, True)
433-
Context.Response.StatusCode = HttpStatusCode.OK
434-
Context.Response.AddHeader("Content-Type", "application/octet-stream")
435-
FileReadStream.CopyTo(Context.Response.OutputStream)
436-
Context.Response.OutputStream.Dispose()
437-
Context.Response.Close()
438-
End Using
439-
End SyncLock
440-
Case "/assets/icon.ico"
441-
Try
442-
Dim Data = GetResourceStream("Images/icon.ico")
443-
If Data Is Nothing Then GoTo NotFound
444-
Context.Response.StatusCode = HttpStatusCode.OK
445-
Context.Response.AddHeader("Content-Type", "application/octet-stream")
446-
Data.CopyTo(Context.Response.OutputStream)
447-
Context.Response.OutputStream.Dispose()
448-
Context.Response.Close()
449-
Catch ex As Exception
450-
GoTo NotFound
451-
End Try
452-
Case "/api/naid/oauth20/status"
453-
Try
454-
Dim status = JsonConvert.SerializeObject(CurrentStatus)
455-
Dim buffer = Encoding.UTF8.GetBytes(status)
456-
Context.Response.StatusCode = HttpStatusCode.OK
457-
Context.Response.AddHeader("Content-Type", "application/json, charset=utf-8")
458-
Context.Response.OutputStream.Write(buffer, 0, buffer.Length)
459-
Context.Response.OutputStream.Dispose()
460-
Context.Response.Close()
461-
Catch ex As Exception
462-
GoTo NotFound
463-
End Try
464-
Case Else
465-
NotFound:
466-
Context.Response.StatusCode = HttpStatusCode.NotFound
467-
Context.Response.Close()
468-
End Select
469-
End Sub
470-
End Class
471-
*/ /* TODO ERROR: Skipped EndIfDirectiveTrivia
472-
#End If
473-
*/
474-
475-
#endregion
476346
}

Plain Craft Launcher 2/Pages/PageInstance/PageInstanceExport.xaml.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -735,10 +735,8 @@ private void StartExport(object sender, MouseButtonEventArgs e)
735735
var Loaders = new List<ModLoader.LoaderBase>();
736736

737737
#region 准备 PCL 文件
738-
739-
/* TODO ERROR: Skipped IfDirectiveTrivia
740-
#If Not RELEASE Then
741-
*/
738+
739+
#if !RELEASE
742740
if (IncludePCL)
743741
Loaders.Add(new ModLoader.LoaderTask<int, int>("下载 PCL 正式版", Loader =>
744742
{
@@ -749,9 +747,7 @@ private void StartExport(object sender, MouseButtonEventArgs e)
749747
ProgressWeight = 0.5d,
750748
Block = false
751749
});
752-
/* TODO ERROR: Skipped EndIfDirectiveTrivia
753-
#End If
754-
*/
750+
#endif
755751

756752
#endregion
757753

@@ -840,14 +836,11 @@ private void StartExport(object sender, MouseButtonEventArgs e)
840836
Loader.Progress = 0.97d;
841837
// 复制 PCL 实例设置
842838
ModBase.CopyDirectory(McInstance.PathInstance + @"PCL\", OverridesFolder + @"PCL\");
843-
/* TODO ERROR: Skipped IfDirectiveTrivia
844-
#If RELEASE Then
845-
*/ /* TODO ERROR: Skipped DisabledTextTrivia
839+
#if RELEASE
846840
'复制 PCL 本体
847841
If IncludePCL Then CopyFile(ExePathWithName, CacheFolder & "Plain Craft Launcher.exe")
848-
*/ /* TODO ERROR: Skipped EndIfDirectiveTrivia
849-
#End If
850-
*/ // 复制 PCL 个性化内容
842+
#endif
843+
// 复制 PCL 个性化内容
851844
if (IncludePCLCustom)
852845
{
853846
if (Directory.Exists(ModBase.ExePath + @"PCL\Pictures\"))

0 commit comments

Comments
 (0)