mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-14 03:30:19 +00:00
✨ feat: platform check utils
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
Reference in New Issue
Block a user