Skip to content

Commit

Permalink
feat: add methods for detecting Windows and Linux platforms (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayangweb authored Feb 20, 2025
1 parent 74af718 commit c520ef8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/utils/platform.ts
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -17,4 +21,4 @@ export function family() {
} else {
return osFamily();
}
}
}

0 comments on commit c520ef8

Please # to comment.