UNPKG

@alicloudfe/components

Version:

A react component library for aliyun

35 lines (34 loc) 1.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // 判断操作系统,如果是 windows 的话在 body 上加一个类名用来区分 var isBrowser = function () { return typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'; }; var judgeOs = function () { var _a, _b, _c, _d, _e; if (isBrowser()) { if (window && window.navigator) { var agent = (_a = navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) === null || _a === void 0 ? void 0 : _a.toLowerCase(); if (agent.indexOf('win32') >= 0 || agent.indexOf('wow32') >= 0 || agent.indexOf('win64') >= 0 || agent.indexOf('wow64') >= 0) { if (window.document && window.document.body) { if (!((_c = (_b = document.body) === null || _b === void 0 ? void 0 : _b.classList) === null || _c === void 0 ? void 0 : _c.contains('isWindows'))) { document.body.classList.add('isWindows'); } } } else if (/macintosh|mac os x/i.test(navigator === null || navigator === void 0 ? void 0 : navigator.userAgent)) { if (window.document && window.document.body) { if (!((_e = (_d = document.body) === null || _d === void 0 ? void 0 : _d.classList) === null || _e === void 0 ? void 0 : _e.contains('isMac'))) { document.body.classList.add('isMac'); } } } } } }; exports.default = judgeOs;