feat: platform check utils

This commit is contained in:
Asuka109
2023-11-07 22:39:59 +08:00
parent ee332a4458
commit 08a3cb9183
2 changed files with 14 additions and 1 deletions
+3 -1
View File
@@ -2,6 +2,8 @@ import { createStyles } from 'antd-style';
import { Fragment, memo } from 'react';
import { Flexbox } from 'react-layout-kit';
import { isApplePlatform } from '@/utils/platform';
const useStyles = createStyles(
({ css, token }) => css`
font-size: 12px;
@@ -27,7 +29,7 @@ const useStyles = createStyles(
);
const HOTKEY_MAPPINGS: Partial<Record<string, string>> = {
alt: 'option',
alt: isApplePlatform() ? 'option' : 'alt',
};
export interface HotKeysProps {
+11
View File
@@ -0,0 +1,11 @@
import UAParser from 'ua-parser-js';
export const getPlatform = () => {
const ua = navigator.userAgent;
return new UAParser(ua || '').getOS();
};
export const isApplePlatform = () => {
const platform = getPlatform().name;
return platform && ['Mac OS', 'iOS'].includes(platform);
};