fix: detect linux

This commit is contained in:
EnixCoda 2020-11-28 15:02:12 +08:00
parent 49df251ed6
commit 0f654996b2
No known key found for this signature in database
GPG key ID: 0C1A07377913A1DD
2 changed files with 3 additions and 0 deletions

View file

@ -46,6 +46,7 @@ export function Node({
onClick={event => {
if (
(os === OperatingSystems.macOS && event.metaKey) ||
(os === OperatingSystems.Linux && event.ctrlKey) ||
(os === OperatingSystems.Windows && event.ctrlKey)
) {
// The default behavior, open in new tab

View file

@ -16,6 +16,7 @@ export function pick<T>(source: T, keys: string[]): Partial<T> {
export enum OperatingSystems {
Windows = 'Windows',
macOS = 'Macintosh',
Linux = 'Linux',
others = 'unknown',
}
@ -25,6 +26,7 @@ function detectOS(): OperatingSystems {
} = window
if (userAgent.indexOf(OperatingSystems.Windows) !== -1) return OperatingSystems.Windows
else if (userAgent.indexOf(OperatingSystems.macOS) !== -1) return OperatingSystems.macOS
else if (userAgent.indexOf(OperatingSystems.Linux) !== -1) return OperatingSystems.Linux
return OperatingSystems.others
}