mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-27 17:50:53 +01:00
33 lines
905 B
Go
33 lines
905 B
Go
import { OS_WINDOWS } from '@/constants/os';
|
|
|
|
function getOS() {
|
|
const userAgent = window.navigator.userAgent;
|
|
const platform = window.navigator.platform;
|
|
const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'];
|
|
const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];
|
|
const iosPlatforms = ['iPhone', 'iPad', 'iPod'];
|
|
let os = null;
|
|
|
|
if (macosPlatforms.indexOf(platform) !== -1) {
|
|
os = 'Mac OS';
|
|
} else if (iosPlatforms.indexOf(platform) !== -1) {
|
|
os = 'iOS';
|
|
} else if (windowsPlatforms.indexOf(platform) !== -1) {
|
|
os = 'Windows';
|
|
} else if (/Android/.test(userAgent)) {
|
|
os = 'Android';
|
|
} else if (!os && /Linux/.test(platform)) {
|
|
os = 'Linux';
|
|
}
|
|
|
|
return os;
|
|
}
|
|
|
|
export const isWindows = (): boolean => {
|
|
return getOS()?.includes(OS_WINDOWS) || false;
|
|
};
|
|
|
|
export const getOSPathSeparator = () => {
|
|
return isWindows() ? '\\' : '/';
|
|
};
|