feat: add methods for detecting Windows and Linux platforms (#162)

This commit is contained in:
ayangweb
2025-02-20 11:16:20 +08:00
committed by GitHub
parent 74af718249
commit c520ef8e9f

View File

@@ -1,9 +1,13 @@
import { family as osFamily, platform } from "@tauri-apps/plugin-os";
export const isWeb = !("__TAURI_OS_PLUGIN_INTERNALS__" in window);
export const isMobile = isWeb ? navigator.userAgent.toLowerCase().includes("mobile") : platform() === "android";
export const isMobile = isWeb
? navigator.userAgent.toLowerCase().includes("mobile")
: platform() === "android";
export const isDesktop = !isMobile;
export const isMac = !isWeb && platform() === "macos";
export const isWin = !isWeb && platform() === "windows";
export const isLinux = !isWeb && platform() === "linux";
export const appScale = isMobile ? 0.5 : 1;
export function family() {
@@ -17,4 +21,4 @@ export function family() {
} else {
return osFamily();
}
}
}