mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 04:48:53 +00:00
30 lines
908 B
TypeScript
30 lines
908 B
TypeScript
const agent = globalThis.navigator?.userAgent ?? '';
|
|
const platform = globalThis.navigator?.platform;
|
|
|
|
export const IS_WEB =
|
|
typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
|
|
export const IS_NODE = typeof process !== 'undefined' && !IS_WEB;
|
|
|
|
export const IS_SAFARI = /Apple Computer/.test(globalThis.navigator?.vendor);
|
|
|
|
export const IS_FIREFOX =
|
|
IS_WEB && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
|
|
|
export const IS_ANDROID = /Android \d/.test(agent);
|
|
|
|
export const IS_IOS =
|
|
IS_SAFARI &&
|
|
(/Mobile\/\w+/.test(agent) || globalThis.navigator?.maxTouchPoints > 2);
|
|
|
|
export const IS_MAC = /Mac/i.test(platform);
|
|
|
|
export const IS_IPAD =
|
|
/iPad/i.test(platform) ||
|
|
/iPad/i.test(agent) ||
|
|
(/Macintosh/i.test(agent) && globalThis.navigator?.maxTouchPoints > 2);
|
|
|
|
export const IS_WINDOWS = /Win/.test(platform);
|
|
|
|
export const IS_MOBILE = IS_IOS || IS_IPAD || IS_ANDROID;
|