mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 16:36:00 +00:00
mac specific keyboard shortcuts #199
This commit is contained in:
@@ -39,3 +39,23 @@ export async function asyncFilter(arr, predicate) {
|
||||
|
||||
return arr.filter((_v, index) => results[index]);
|
||||
}
|
||||
|
||||
export function isMac() {
|
||||
// @ts-ignore
|
||||
const platform = navigator?.platform || navigator?.userAgentData?.platform || 'unknown'
|
||||
return platform.toUpperCase().indexOf('MAC') >= 0;
|
||||
}
|
||||
|
||||
export function formatKeyText(keyText: string): string {
|
||||
if (isMac()) {
|
||||
return keyText.replace('CtrlOrCommand+', '⌘ ').replace('Shift+', '⇧ ').replace('Alt+', '⌥ ')
|
||||
}
|
||||
return keyText.replace('CtrlOrCommand+', 'Ctrl+');
|
||||
}
|
||||
|
||||
export function resolveKeyText(keyText: string): string {
|
||||
if (isMac()) {
|
||||
return keyText.replace('CtrlOrCommand+', 'Command+')
|
||||
}
|
||||
return keyText.replace('CtrlOrCommand+', 'Ctrl+');
|
||||
}
|
||||
Reference in New Issue
Block a user