mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-25 13:45:03 +08:00
b8d2daccde
- refactor(ui): add runtime platform detector and conditionally apply blur only on non-Linux platforms - chore: verify typecheck and renderer build succeed; no functional regression expected
31 lines
778 B
TypeScript
31 lines
778 B
TypeScript
// 轻量平台检测,避免在 SSR 或无 navigator 的环境报错
|
|
export const isMac = (): boolean => {
|
|
try {
|
|
const ua = navigator.userAgent || "";
|
|
const plat = (navigator.platform || "").toLowerCase();
|
|
return /mac/i.test(ua) || plat.includes("mac");
|
|
} catch {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
export const isWindows = (): boolean => {
|
|
try {
|
|
const ua = navigator.userAgent || "";
|
|
return /windows|win32|win64/i.test(ua);
|
|
} catch {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
export const isLinux = (): boolean => {
|
|
try {
|
|
const ua = navigator.userAgent || "";
|
|
// WebKitGTK/Chromium 在 Linux/Wayland/X11 下 UA 通常包含 Linux 或 X11
|
|
return /linux|x11/i.test(ua) && !/android/i.test(ua) && !isMac() && !isWindows();
|
|
} catch {
|
|
return false;
|
|
}
|
|
};
|
|
|