forked from vikunja/frontend
feat: use command on mac and ctrl on other platforms
This commit is contained in:
parent
f3f3713bc1
commit
a90b863590
|
@ -1,15 +1,22 @@
|
|||
<template>
|
||||
<span class="shortcuts">
|
||||
<template v-for="(k, i) in keys" :key="i">
|
||||
<kbd>{{ k }}</kbd>
|
||||
<kbd>{{ isMac ? k.replace('ctrl', '⌘') : k }}</kbd>
|
||||
<span v-if="i < keys.length - 1">{{ combination }}</span>
|
||||
</template>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {isMac} from '@/helpers/isMac'
|
||||
|
||||
export default {
|
||||
name: 'shortcut',
|
||||
data() {
|
||||
return {
|
||||
isMac: isMac(),
|
||||
}
|
||||
},
|
||||
props: {
|
||||
keys: {
|
||||
type: Array,
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
import {Directive} from 'vue'
|
||||
import {install, uninstall} from '@github/hotkey'
|
||||
import {isMac} from '@/helpers/isMac'
|
||||
|
||||
const directive: Directive = {
|
||||
mounted(el, {value}) {
|
||||
if (isMac() && value.includes('Control')) {
|
||||
value = value.replace('Control', 'Meta')
|
||||
}
|
||||
install(el, value)
|
||||
},
|
||||
beforeUnmount(el) {
|
||||
|
|
3
src/helpers/isMac.ts
Normal file
3
src/helpers/isMac.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
export const isMac = (): Boolean => {
|
||||
return navigator.userAgent.includes('Mac')
|
||||
}
|
Loading…
Reference in New Issue
Block a user