fix(support-info): show Windows marketing name in support info
This commit is contained in:
2 files changed
+55
-1
No files matched your search
@@ -32,10 +32,33 @@ export function formatSupportInfoRuntime(runtime: AppSupportInfo["runtime"], lab
|
||||
return labels.unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a Windows NT kernel version (`major.minor.build[.ubr]`) to its marketing name.
|
||||
*
|
||||
* Windows 11 still reports kernel `10.0.x`; the build number is what distinguishes it
|
||||
* (build >= 22000 is Windows 11). Returns null for non-`10.0` versions (e.g. legacy 6.x)
|
||||
* so callers keep the raw string instead of guessing.
|
||||
*/
|
||||
export function windowsMarketingName(version: string | null | undefined): string | null {
|
||||
const trimmed = version?.trim();
|
||||
if (!trimmed) return null;
|
||||
const parts = trimmed.split(".");
|
||||
if (parts.length < 3) return null;
|
||||
const major = Number(parts[0]);
|
||||
const build = Number(parts[2]);
|
||||
if (!Number.isInteger(major) || !Number.isInteger(build)) return null;
|
||||
if (major !== 10) return null;
|
||||
return build >= 22000 ? "Windows 11" : "Windows 10";
|
||||
}
|
||||
|
||||
export function formatSupportInfoOperatingSystem(info: AppSupportInfo, unknownLabel: string): string {
|
||||
const name = info.osName?.trim();
|
||||
const version = info.osVersion?.trim();
|
||||
if (!name && !version) return unknownLabel;
|
||||
if (name?.toLowerCase() === "windows") {
|
||||
const marketing = windowsMarketingName(version);
|
||||
if (marketing) return version ? `${marketing} (${version})` : marketing;
|
||||
}
|
||||
return [name, version].filter(Boolean).join(" ");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user