主要更新了http相关的内容

This commit is contained in:
2025-11-18 19:54:13 +08:00
parent bf464b04a6
commit 5762b6daf4
13 changed files with 155 additions and 136 deletions

View File

@@ -1,16 +1,9 @@
using Microsoft.VisualBasic;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
@@ -32,13 +25,13 @@ namespace Ramitta.lib
#endregion
#region
public static void DebugBar(Label obj, String? text, SolidColorBrush? color=null)
public static void DebugBar(Label obj, String? text, SolidColorBrush? color = null)
{
if (obj == null) return;
// 通过Dispatcher确保在UI线程执行
obj.Dispatcher.Invoke(() =>
{
if (text!=null)obj.Content = text;
if (text != null) obj.Content = text;
if (color != null) obj.Background = color;
@@ -122,37 +115,6 @@ namespace Ramitta.lib
}
#endregion
#region
public static Dictionary<string, string>? Startupe;
public static Dictionary<string, string> ParseCommandLineArgs(string[] args)
{
var arguments = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
for (int i = 0; i < args.Length; i++)
{
string arg = args[i];
// 检查是否是参数名(以-或/开头)
if (arg.StartsWith("-") || arg.StartsWith("/"))
{
string key = arg.TrimStart('-', '/');
string value = "true"; // 默认值为true表示开关存在
// 检查下一个参数是否是值(不以-或/开头)
if (i + 1 < args.Length && !args[i + 1].StartsWith("-") && !args[i + 1].StartsWith("/"))
{
value = args[i + 1];
i++; // 跳过下一个参数,因为已经被用作值
}
arguments[key] = value;
}
}
return arguments;
}
#endregion
#region
public static bool IsPathExist(string databasePath)
{
@@ -163,7 +125,7 @@ namespace Ramitta.lib
return Directory.Exists(databasePath);
}
public static void FileWrite(string outputPath, string outputText, bool createDirectories = true,bool fileAdd = false)
public static void FileWrite(string outputPath, string outputText, bool createDirectories = true, bool fileAdd = false)
{
string directory = Path.GetDirectoryName(outputPath);
if (createDirectories && !Directory.Exists(directory))
@@ -182,7 +144,7 @@ namespace Ramitta.lib
{
try
{
return File.ReadAllText(outputPath);
return File.ReadAllText(outputPath);
}
catch
{
@@ -262,7 +224,7 @@ namespace Ramitta.lib
#endregion
#region
public static async Task<int> RunExternalCommand(string? applicationPath = "explorer.exe", string arguments="", bool UseShellExecute = false, bool CreateNoWindow = false)
public static async Task<int> RunExternalCommand(string? applicationPath = "explorer.exe", string arguments = "", bool UseShellExecute = false, bool CreateNoWindow = false)
{
ProcessStartInfo startInfo = new ProcessStartInfo
{
@@ -289,7 +251,7 @@ namespace Ramitta.lib
}
catch (Exception ex)
catch (Exception)
{
throw;
}
@@ -335,7 +297,7 @@ namespace Ramitta.lib
return output; // 返回标准输出内容
}
}
catch (Exception ex)
catch (Exception)
{
// 可以记录或处理异常
throw; // 重新抛出异常以便调用者捕获