diff --git a/STranslateDLL/LocalMode.cs b/STranslateDLL/LocalMode.cs index 2982804..02c0623 100644 --- a/STranslateDLL/LocalMode.cs +++ b/STranslateDLL/LocalMode.cs @@ -13,7 +13,6 @@ public static class LocalMode CancellationToken? token = null ) { - Utilities.Initial(); var getToken = token ?? CancellationToken.None; var splitResult = await SplitTextAsync(content, getToken); diff --git a/STranslateDLL/Utilities.cs b/STranslateDLL/Utilities.cs index ed58009..e6b9820 100644 --- a/STranslateDLL/Utilities.cs +++ b/STranslateDLL/Utilities.cs @@ -7,8 +7,6 @@ namespace STranslateDLL; public static class Utilities { public const string Url = "https://www2.deepl.com/jsonrpc"; - private static long _nextId; - private static bool _hasInit; public static readonly Dictionary TextTypeDic = new() { @@ -21,7 +19,7 @@ public static class Utilities { Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault, - WriteIndented = true + // WriteIndented = true }; public static string Serialize(object data) @@ -29,17 +27,6 @@ public static class Utilities return JsonSerializer.Serialize(data, GetOptions); } - public static void Initial() - { - if (_hasInit) return; - - var rand = new Random(); - var number = rand.NextInt64(99999) + 8300000; - _nextId = number * 1000; - - _hasInit = true; - } - public static bool IsRichText(string text) { return text.Contains('<') && text.Contains('>'); @@ -54,7 +41,9 @@ public static class Utilities public static long CreateId() { - return Interlocked.Increment(ref _nextId); + var rand = new Random(); + var number = rand.NextInt64(99999) + 8300000; + return number * 1000; } public static string AdjustJsonContent(string json, long id)