mirror of
https://github.com/makeplane/plane.git
synced 2026-02-25 04:35:21 +01:00
* fix: adding langauge support for sidebar items * fix: worksapce sidebar item refactor * chore: code cleanup --------- Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
35 lines
837 B
TypeScript
35 lines
837 B
TypeScript
import { useState, useEffect } from "react";
|
|
|
|
export const usePlatformOS = () => {
|
|
const [platformData, setPlatformData] = useState({
|
|
isMobile: false,
|
|
platform: "",
|
|
});
|
|
|
|
useEffect(() => {
|
|
const detectPlatform = () => {
|
|
const userAgent = window.navigator.userAgent;
|
|
const isMobile = /iPhone|iPad|iPod|Android/i.test(userAgent);
|
|
let platform = "";
|
|
|
|
if (!isMobile) {
|
|
if (userAgent.indexOf("Win") !== -1) {
|
|
platform = "Windows";
|
|
} else if (userAgent.indexOf("Mac") !== -1) {
|
|
platform = "MacOS";
|
|
} else if (userAgent.indexOf("Linux") !== -1) {
|
|
platform = "Linux";
|
|
} else {
|
|
platform = "Unknown";
|
|
}
|
|
}
|
|
|
|
setPlatformData({ isMobile, platform });
|
|
};
|
|
|
|
detectPlatform();
|
|
}, []);
|
|
|
|
return platformData;
|
|
};
|