@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 22 lines 998 Bytes
Raw
1 import { ANDROID_PLAY_STORE_URL, IOS_APP_STORE_URL } from "./site";
2
3 export type Platform = { os: "mac" | "win" | "linux" | "ios" | "android" };
4
5 export function detectPlatform(userAgent: string, maxTouchPoints: number): Platform | null {
6 // Mobile checks come first: Android user agents contain "Linux" and iOS
7 // user agents contain "Mac OS X".
8 if (/Android/i.test(userAgent)) return { os: "android" };
9 if (/iPhone|iPad|iPod/i.test(userAgent)) return { os: "ios" };
10 if (/Win/i.test(userAgent)) return { os: "win" };
11 // iPadOS Safari sends a Mac user agent by default; only the touch screen
12 // tells it apart from a Mac.
13 if (/Mac/i.test(userAgent)) return { os: maxTouchPoints > 1 ? "ios" : "mac" };
14 if (/Linux/i.test(userAgent)) return { os: "linux" };
15 return null;
16 }
17
18 export function getMobileStoreUrl(platform: Platform): string | null {
19 if (platform.os === "ios") return IOS_APP_STORE_URL;
20 if (platform.os === "android") return ANDROID_PLAY_STORE_URL;
21 return null;
22 }