MCPcopy
hub / github.com/xintaofei/codeg / usePlatform

Function usePlatform

src/hooks/use-platform.ts:32–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30}
31
32export function usePlatform() {
33 const [platform, setPlatform] = useState<PlatformType>("unknown")
34
35 useEffect(() => {
36 const frame = window.requestAnimationFrame(() => {
37 setPlatform(detectPlatform())
38 })
39
40 return () => {
41 window.cancelAnimationFrame(frame)
42 }
43 }, [])
44
45 return {
46 platform,
47 isMac: platform === "macos",
48 isWindows: platform === "windows",
49 isLinux: platform === "linux",
50 }
51}

Callers 5

WindowControlsFunction · 0.90
AppTitleBarFunction · 0.90
WindowResizeGripsFunction · 0.90
GeneralSettingsFunction · 0.90
useIsMacFunction · 0.90

Calls 1

detectPlatformFunction · 0.85

Tested by

no test coverage detected