-
-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
83 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
struct OSVersion | ||
{ | ||
bool Is20H1OrNewer() const noexcept | ||
{ | ||
return version.dwBuildNumber >= 19041; | ||
} | ||
|
||
// 下面为 Win11 | ||
// 不考虑代号相同的 Win10 | ||
|
||
bool IsWin11() const noexcept | ||
{ | ||
return Is21H2OrNewer(); | ||
} | ||
|
||
bool Is21H2OrNewer() const noexcept | ||
{ | ||
return version.dwBuildNumber >= 22000; | ||
} | ||
|
||
bool Is22H2OrNewer() const noexcept | ||
{ | ||
return version.dwBuildNumber >= 22621; | ||
} | ||
bool IsWin7or8() const noexcept | ||
{ | ||
return version.dwMajorVersion <= 6; | ||
} | ||
RTL_OSVERSIONINFOW version; | ||
}; | ||
namespace | ||
{ | ||
RTL_OSVERSIONINFOW _GetOSversion() noexcept | ||
{ | ||
HMODULE hNtDll = GetModuleHandle(L"ntdll.dll"); | ||
if (!hNtDll) | ||
{ | ||
return {}; | ||
} | ||
|
||
auto rtlGetVersion = (LONG(WINAPI *)(PRTL_OSVERSIONINFOW))GetProcAddress(hNtDll, "RtlGetVersion"); | ||
if (rtlGetVersion == nullptr) | ||
{ | ||
// assert(false); | ||
return {}; | ||
} | ||
|
||
RTL_OSVERSIONINFOW version{}; | ||
version.dwOSVersionInfoSize = sizeof(version); | ||
rtlGetVersion(&version); | ||
|
||
return version; | ||
} | ||
} | ||
static OSVersion GetOSVersion() | ||
{ | ||
{ | ||
static OSVersion version = {_GetOSversion()}; | ||
return version; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
npm run docs:build | ||
cp index.html .vitepress/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<link rel="icon" href="https://image.lunatranslator.org/luna.ico" type="image/x-icon"> | ||
<script> | ||
let lang = window.localStorage.currentlang ? window.localStorage.currentlang : browserlang() | ||
window.location.pathname = `/${lang}/` | ||
</script> | ||
</head> | ||
|
||
</html> |