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>
|
<template>
|
||||||
<span class="shortcuts">
|
<span class="shortcuts">
|
||||||
<template v-for="(k, i) in keys" :key="i">
|
<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>
|
<span v-if="i < keys.length - 1">{{ combination }}</span>
|
||||||
</template>
|
</template>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {isMac} from '@/helpers/isMac'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'shortcut',
|
name: 'shortcut',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
isMac: isMac(),
|
||||||
|
}
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
keys: {
|
keys: {
|
||||||
type: Array,
|
type: Array,
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
import {Directive} from 'vue'
|
import {Directive} from 'vue'
|
||||||
import {install, uninstall} from '@github/hotkey'
|
import {install, uninstall} from '@github/hotkey'
|
||||||
|
import {isMac} from '@/helpers/isMac'
|
||||||
|
|
||||||
const directive: Directive = {
|
const directive: Directive = {
|
||||||
mounted(el, {value}) {
|
mounted(el, {value}) {
|
||||||
|
if (isMac() && value.includes('Control')) {
|
||||||
|
value = value.replace('Control', 'Meta')
|
||||||
|
}
|
||||||
install(el, value)
|
install(el, value)
|
||||||
},
|
},
|
||||||
beforeUnmount(el) {
|
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