From c004a1c72fd955b4cf7eabf0a1481ddf392c9e32 Mon Sep 17 00:00:00 2001 From: nilaoda Date: Fri, 22 Nov 2024 19:46:34 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8DWindowsVista=E7=BC=96?= =?UTF-8?q?=E8=AF=91=20(#499)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build_latest.yml | 10 +++++---- .../N_m3u8DL-RE.Common.csproj | 2 +- src/N_m3u8DL-RE.Common/Resource/ResString.cs | 7 +++--- .../N_m3u8DL-RE.Parser.csproj | 4 ++-- src/N_m3u8DL-RE/Directory.Build.props | 22 +++++++++---------- src/N_m3u8DL-RE/N_m3u8DL-RE.csproj | 8 +++---- src/N_m3u8DL-RE/Program.cs | 20 +++++++++++------ 7 files changed, 41 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build_latest.yml b/.github/workflows/build_latest.yml index 68a4773..fd0e5a2 100644 --- a/.github/workflows/build_latest.yml +++ b/.github/workflows/build_latest.yml @@ -23,7 +23,7 @@ env: ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true jobs: - build-win7-x86: + build-win-nt6_0-x86: runs-on: windows-latest steps: @@ -34,13 +34,15 @@ jobs: with: dotnet-version: ${{ env.DOTNET_SDK_VERSION }} + - run: powershell -Command "(Get-Content src/N_m3u8DL-RE/N_m3u8DL-RE.csproj) -replace '.*', 'net9.0-windows' | Set-Content src/N_m3u8DL-RE/N_m3u8DL-RE.csproj" + - run: dotnet add src/N_m3u8DL-RE/N_m3u8DL-RE.csproj package YY-Thunks --version 1.1.4 - run: dotnet add src/N_m3u8DL-RE/N_m3u8DL-RE.csproj package VC-LTL --version 5.1.1 - - run: dotnet publish src/N_m3u8DL-RE -r win-x86 -c Release -o artifact-x86 + - run: dotnet publish src/N_m3u8DL-RE -p:TargetPlatformMinVersion=6.0 -r win-x86 -c Release -o artifact-x86 - name: Upload Artifact[win-x86] uses: actions/upload-artifact@v3.1.3 with: - name: N_m3u8DL-RE_Beta_win7-x86 + name: N_m3u8DL-RE_Beta_win_NT6.0-x86 path: artifact-x86\N_m3u8DL-RE.exe build-win-x64-arm64: @@ -135,7 +137,7 @@ jobs: create_draft_release: name: Create Github draft release if: ${{ github.event.inputs.doRelease == 'true' }} - needs: [build-win7-x86,build-win-x64-arm64,build-linux-x64,build-linux-arm64,build-mac-x64-arm64] + needs: [build-win-nt6_0-x86,build-win-x64-arm64,build-linux-x64,build-linux-arm64,build-mac-x64-arm64] runs-on: ubuntu-latest steps: - name: Audit gh version diff --git a/src/N_m3u8DL-RE.Common/N_m3u8DL-RE.Common.csproj b/src/N_m3u8DL-RE.Common/N_m3u8DL-RE.Common.csproj index e631f94..2214b05 100644 --- a/src/N_m3u8DL-RE.Common/N_m3u8DL-RE.Common.csproj +++ b/src/N_m3u8DL-RE.Common/N_m3u8DL-RE.Common.csproj @@ -5,7 +5,7 @@ net9.0 N_m3u8DL_RE.Common enable - preview + preview enable diff --git a/src/N_m3u8DL-RE.Common/Resource/ResString.cs b/src/N_m3u8DL-RE.Common/Resource/ResString.cs index 8c97681..9cae7d1 100644 --- a/src/N_m3u8DL-RE.Common/Resource/ResString.cs +++ b/src/N_m3u8DL-RE.Common/Resource/ResString.cs @@ -2,6 +2,8 @@ public class ResString { + public static string CurrentLoc = "en-US"; + public static readonly string ReLiveTs = ""; public static string singleFileRealtimeDecryptWarn => GetText("singleFileRealtimeDecryptWarn"); public static string singleFileSplitWarn => GetText("singleFileSplitWarn"); @@ -132,10 +134,9 @@ public class ResString if (!StaticText.LANG_DIC.ContainsKey(key)) return "<...LANG TEXT MISSING...>"; - var current = Thread.CurrentThread.CurrentUICulture.Name; - if (current == "zh-CN" || current == "zh-SG" || current == "zh-Hans") + if (CurrentLoc == "zh-CN" || CurrentLoc == "zh-SG" || CurrentLoc == "zh-Hans") return StaticText.LANG_DIC[key].ZH_CN; - if (current.StartsWith("zh-")) + if (CurrentLoc.StartsWith("zh-")) return StaticText.LANG_DIC[key].ZH_TW; return StaticText.LANG_DIC[key].EN_US; } diff --git a/src/N_m3u8DL-RE.Parser/N_m3u8DL-RE.Parser.csproj b/src/N_m3u8DL-RE.Parser/N_m3u8DL-RE.Parser.csproj index 34d56a1..f8dfdaf 100644 --- a/src/N_m3u8DL-RE.Parser/N_m3u8DL-RE.Parser.csproj +++ b/src/N_m3u8DL-RE.Parser/N_m3u8DL-RE.Parser.csproj @@ -1,11 +1,11 @@ - library + library net9.0 N_m3u8DL_RE.Parser enable - preview + preview enable diff --git a/src/N_m3u8DL-RE/Directory.Build.props b/src/N_m3u8DL-RE/Directory.Build.props index 496105d..311188e 100644 --- a/src/N_m3u8DL-RE/Directory.Build.props +++ b/src/N_m3u8DL-RE/Directory.Build.props @@ -5,19 +5,19 @@ true true full - link - true - true - zh-CN;zh-TW;en-US - true - true - aarch64-linux-gnu-objcopy + link + true + true + zh-CN;zh-TW;en-US + true + true + aarch64-linux-gnu-objcopy - - + + diff --git a/src/N_m3u8DL-RE/N_m3u8DL-RE.csproj b/src/N_m3u8DL-RE/N_m3u8DL-RE.csproj index 44da4ec..4f471e8 100644 --- a/src/N_m3u8DL-RE/N_m3u8DL-RE.csproj +++ b/src/N_m3u8DL-RE/N_m3u8DL-RE.csproj @@ -2,13 +2,13 @@ Exe - net9.0 + net9.0 N_m3u8DL_RE enable - preview + preview enable - 0.2.1 - AnyCPU;x64 + 0.2.1 + AnyCPU;x64 diff --git a/src/N_m3u8DL-RE/Program.cs b/src/N_m3u8DL-RE/Program.cs index 0d350fd..c683787 100644 --- a/src/N_m3u8DL-RE/Program.cs +++ b/src/N_m3u8DL-RE/Program.cs @@ -5,7 +5,6 @@ using N_m3u8DL_RE.Parser; using Spectre.Console; using N_m3u8DL_RE.Common.Resource; using N_m3u8DL_RE.Common.Log; -using System.Globalization; using System.Text; using N_m3u8DL_RE.Common.Util; using N_m3u8DL_RE.Processor; @@ -22,11 +21,21 @@ internal class Program { static async Task Main(string[] args) { + // 处理NT6.0及以下System.CommandLine报错CultureNotFound问题 + if (OperatingSystem.IsWindows()) + { + var osVersion = Environment.OSVersion.Version; + if (osVersion.Major < 6 || (osVersion.Major == 6 && osVersion.Minor == 0)) + { + Environment.SetEnvironmentVariable("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "1"); + } + } + Console.CancelKeyPress += Console_CancelKeyPress; ServicePointManager.DefaultConnectionLimit = 1024; try { Console.CursorVisible = true; } catch { } - string loc = "en-US"; + string loc = ResString.CurrentLoc; string currLoc = Thread.CurrentThread.CurrentUICulture.Name; if (currLoc == "zh-CN" || currLoc == "zh-SG") loc = "zh-CN"; else if (currLoc.StartsWith("zh-")) loc = "zh-TW"; @@ -38,11 +47,8 @@ internal class Program { loc = list[index + 1]; } - - CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(loc); - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(loc); - Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(loc); - + + ResString.CurrentLoc = loc; await CommandInvoker.InvokeArgs(args, DoWorkAsync); }