Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#2927 from lifeeric/MACOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Yidadaa authored Oct 7, 2023
2 parents ef3e8e6 + f1ca03e commit 5a2cc6f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/store/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LLMModel } from "../client/api";
import { isMacOS } from "../utils";
import { getClientConfig } from "../config/client";
import {
DEFAULT_INPUT_TEMPLATE,
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,15 @@ export function autoGrowTextArea(dom: HTMLTextAreaElement) {
export function getCSSVar(varName: string) {
return getComputedStyle(document.body).getPropertyValue(varName).trim();
}

/**
* Detects Macintosh
*/
export function isMacOS(): boolean {
if (typeof window !== "undefined") {
let userAgent = window.navigator.userAgent.toLocaleLowerCase();
const macintosh = /iphone|ipad|ipod|macintosh/.test(userAgent)
return !!macintosh
}
return false
}

0 comments on commit 5a2cc6f

Please sign in to comment.