适配WindowsVista

This commit is contained in:
nilaoda 2024-11-21 21:55:21 +08:00
parent bb20d50122
commit 2b4787008d
7 changed files with 41 additions and 32 deletions

View File

@ -23,7 +23,7 @@ env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
jobs: jobs:
build-win7-x86: build-win-nt6_0-x86:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
@ -34,13 +34,15 @@ jobs:
with: with:
dotnet-version: ${{ env.DOTNET_SDK_VERSION }} dotnet-version: ${{ env.DOTNET_SDK_VERSION }}
- run: powershell -Command "(Get-Content src/N_m3u8DL-RE/N_m3u8DL-RE.csproj) -replace '<TargetFramework>.*</TargetFramework>', '<TargetFramework>net9.0-windows</TargetFramework>' | 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 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] - name: Upload Artifact[win-x86]
uses: actions/upload-artifact@v3.1.3 uses: actions/upload-artifact@v3.1.3
with: with:
name: N_m3u8DL-RE_Beta_win7-x86 name: N_m3u8DL-RE_Beta_win_NT6.0-x86
path: artifact-x86\N_m3u8DL-RE.exe path: artifact-x86\N_m3u8DL-RE.exe
build-win-x64-arm64: build-win-x64-arm64:
@ -135,7 +137,7 @@ jobs:
create_draft_release: create_draft_release:
name: Create Github draft release name: Create Github draft release
if: ${{ github.event.inputs.doRelease == 'true' }} 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 runs-on: ubuntu-latest
steps: steps:
- name: Audit gh version - name: Audit gh version

View File

@ -2,6 +2,8 @@
public class ResString public class ResString
{ {
public static string CurrentLoc = "en-US";
public static readonly string ReLiveTs = "<RE_LIVE_TS>"; public static readonly string ReLiveTs = "<RE_LIVE_TS>";
public static string singleFileRealtimeDecryptWarn => GetText("singleFileRealtimeDecryptWarn"); public static string singleFileRealtimeDecryptWarn => GetText("singleFileRealtimeDecryptWarn");
public static string singleFileSplitWarn => GetText("singleFileSplitWarn"); public static string singleFileSplitWarn => GetText("singleFileSplitWarn");
@ -132,10 +134,9 @@ public class ResString
if (!StaticText.LANG_DIC.ContainsKey(key)) if (!StaticText.LANG_DIC.ContainsKey(key))
return "<...LANG TEXT MISSING...>"; return "<...LANG TEXT MISSING...>";
var current = Thread.CurrentThread.CurrentUICulture.Name; if (CurrentLoc == "zh-CN" || CurrentLoc == "zh-SG" || CurrentLoc == "zh-Hans")
if (current == "zh-CN" || current == "zh-SG" || current == "zh-Hans")
return StaticText.LANG_DIC[key].ZH_CN; 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].ZH_TW;
return StaticText.LANG_DIC[key].EN_US; return StaticText.LANG_DIC[key].EN_US;
} }

View File

@ -5,7 +5,6 @@ using N_m3u8DL_RE.Parser;
using Spectre.Console; using Spectre.Console;
using N_m3u8DL_RE.Common.Resource; using N_m3u8DL_RE.Common.Resource;
using N_m3u8DL_RE.Common.Log; using N_m3u8DL_RE.Common.Log;
using System.Globalization;
using System.Text; using System.Text;
using N_m3u8DL_RE.Common.Util; using N_m3u8DL_RE.Common.Util;
using N_m3u8DL_RE.Processor; using N_m3u8DL_RE.Processor;
@ -22,11 +21,21 @@ internal class Program
{ {
static async Task Main(string[] args) 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; Console.CancelKeyPress += Console_CancelKeyPress;
ServicePointManager.DefaultConnectionLimit = 1024; ServicePointManager.DefaultConnectionLimit = 1024;
try { Console.CursorVisible = true; } catch { } try { Console.CursorVisible = true; } catch { }
string loc = "en-US"; string loc = ResString.CurrentLoc;
string currLoc = Thread.CurrentThread.CurrentUICulture.Name; string currLoc = Thread.CurrentThread.CurrentUICulture.Name;
if (currLoc == "zh-CN" || currLoc == "zh-SG") loc = "zh-CN"; if (currLoc == "zh-CN" || currLoc == "zh-SG") loc = "zh-CN";
else if (currLoc.StartsWith("zh-")) loc = "zh-TW"; else if (currLoc.StartsWith("zh-")) loc = "zh-TW";
@ -39,10 +48,7 @@ internal class Program
loc = list[index + 1]; loc = list[index + 1];
} }
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(loc); ResString.CurrentLoc = loc;
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(loc);
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(loc);
await CommandInvoker.InvokeArgs(args, DoWorkAsync); await CommandInvoker.InvokeArgs(args, DoWorkAsync);
} }