From 3bfcdf9c41c9a8311cb8c4b6a8a9bc5f05ce322d Mon Sep 17 00:00:00 2001 From: Eric R Date: Thu, 28 Sep 2023 06:10:22 -0400 Subject: [PATCH 1/3] [ADDED] MacOS detect --- app/utils.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/utils.ts b/app/utils.ts index 37c17dd760d..67d008b9356 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -173,3 +173,15 @@ export function autoGrowTextArea(dom: HTMLTextAreaElement) { export function getCSSVar(varName: string) { return getComputedStyle(document.body).getPropertyValue(varName).trim(); } + +/** + * Detects if the Operation system is MacOS + */ +export function isMacOS(): boolean { + if (window !== 'undefined') { + let userAgent = window?.navigator?.userAgent + if (userAgent.indexOf('Mac') != -1) return true + } + + return false +} From f3d5fc7a845aeba3dc120b46196dc3978c77faef Mon Sep 17 00:00:00 2001 From: Eric R Date: Thu, 28 Sep 2023 06:11:48 -0400 Subject: [PATCH 2/3] [FIXED] now the default key should be CMD on MacOS --- app/store/config.ts | 3 ++- app/utils.ts | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/store/config.ts b/app/store/config.ts index 956e5f3eb81..53df36ec2a3 100644 --- a/app/store/config.ts +++ b/app/store/config.ts @@ -1,4 +1,5 @@ import { LLMModel } from "../client/api"; +import { isMacOS } from "../utils"; import { getClientConfig } from "../config/client"; import { DEFAULT_INPUT_TEMPLATE, @@ -27,7 +28,7 @@ export enum Theme { export const DEFAULT_CONFIG = { lastUpdate: Date.now(), // timestamp, to merge state - submitKey: SubmitKey.CtrlEnter as SubmitKey, + submitKey: isMacOS() ? SubmitKey.MetaEnter : SubmitKey.CtrlEnter, avatar: "1f603", fontSize: 14, theme: Theme.Auto as Theme, diff --git a/app/utils.ts b/app/utils.ts index 67d008b9356..3db8e7c41b9 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -178,10 +178,10 @@ export function getCSSVar(varName: string) { * Detects if the Operation system is MacOS */ export function isMacOS(): boolean { - if (window !== 'undefined') { - let userAgent = window?.navigator?.userAgent - if (userAgent.indexOf('Mac') != -1) return true - } + if (typeof window !== "undefined") { + let userAgent = window?.navigator?.userAgent; + if (userAgent.indexOf("Mac") != -1) return true; + } - return false + return false; } From f1ca03e3788d89295f889eb67da270adbee6137f Mon Sep 17 00:00:00 2001 From: EricGit Date: Thu, 28 Sep 2023 13:21:17 -0400 Subject: [PATCH 3/3] [FIXED] now it should detects all macintosh --- app/utils.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/utils.ts b/app/utils.ts index 3db8e7c41b9..1b76285cc07 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -175,13 +175,13 @@ export function getCSSVar(varName: string) { } /** - * Detects if the Operation system is MacOS + * Detects Macintosh */ export function isMacOS(): boolean { if (typeof window !== "undefined") { - let userAgent = window?.navigator?.userAgent; - if (userAgent.indexOf("Mac") != -1) return true; + let userAgent = window.navigator.userAgent.toLocaleLowerCase(); + const macintosh = /iphone|ipad|ipod|macintosh/.test(userAgent) + return !!macintosh } - - return false; + return false }