-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
494 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<template> | ||
<q-select | ||
v-model="model" | ||
:options="options" | ||
map-options | ||
emit-value | ||
/> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { PlatformEnabled } from 'src/utils/types' | ||
const model = defineModel<PlatformEnabled>() | ||
const options = [ | ||
{ label: '始终启用', value: 'always' }, | ||
{ label: '仅桌面端', value: 'desktop-only' }, | ||
{ label: '仅移动端', value: 'mobile-only' }, | ||
{ label: '始终禁用', value: 'never' } | ||
] | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<template> | ||
<q-field | ||
@focus="onFocus" | ||
@blur="onBlur" | ||
> | ||
<template #control> | ||
<div v-if="text"> | ||
{{ text }} | ||
</div> | ||
</template> | ||
</q-field> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ShortcutKey } from 'src/utils/types' | ||
import { computed } from 'vue' | ||
const model = defineModel<ShortcutKey>() | ||
const listener = (ev: KeyboardEvent) => { | ||
if (['ControlLeft', 'ShiftLeft', 'AltLeft', 'ControlRight', 'ShiftRight', 'AltRight'].includes(ev.code)) return | ||
model.value = { | ||
key: ev.code, | ||
withCtrl: ev.ctrlKey, | ||
withShift: ev.shiftKey, | ||
withAlt: ev.altKey | ||
} | ||
ev.preventDefault() | ||
} | ||
function onFocus() { | ||
model.value = null | ||
document.addEventListener('keydown', listener) | ||
} | ||
function onBlur() { | ||
document.removeEventListener('keydown', listener) | ||
} | ||
const text = computed(() => { | ||
if (!model.value) return | ||
let val = '' | ||
if (model.value.withCtrl) val += 'Ctrl + ' | ||
if (model.value.withShift) val += 'Shift + ' | ||
if (model.value.withAlt) val += 'Alt + ' | ||
val += model.value.key | ||
return val | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { ShortcutKey } from 'src/utils/types' | ||
import { onActivated, onDeactivated, onMounted, onUnmounted, Ref, unref } from 'vue' | ||
|
||
export function useListenKey(shortcutKey: Ref<ShortcutKey>, callback, prevent = true) { | ||
const listener = event => { | ||
const { key, withCtrl = false, withShift = false, withAlt = false } = unref(shortcutKey) | ||
if (event.code === key && event.ctrlKey === withCtrl && event.shiftKey === withShift && event.altKey === withAlt) { | ||
callback() | ||
prevent && event.preventDefault() | ||
} | ||
} | ||
const addListener = () => { document.addEventListener('keydown', listener) } | ||
const rmListener = () => { document.removeEventListener('keydown', listener) } | ||
onMounted(addListener) | ||
onUnmounted(rmListener) | ||
onActivated(addListener) | ||
onDeactivated(rmListener) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
<template> | ||
<q-header | ||
bg-sur-c-low | ||
text-on-sur | ||
> | ||
<q-toolbar> | ||
<q-btn | ||
flat | ||
dense | ||
round | ||
icon="sym_o_arrow_back" | ||
@click="back" | ||
/> | ||
<q-toolbar-title> | ||
键盘快捷键 | ||
</q-toolbar-title> | ||
</q-toolbar> | ||
</q-header> | ||
<q-page-container> | ||
<q-page :style-fn="pageFhStyle"> | ||
<q-list | ||
py-2 | ||
max-w="1000px" | ||
mx-a | ||
> | ||
<q-item> | ||
<q-item-section> | ||
<q-item-label> | ||
启用键盘快捷键 | ||
</q-item-label> | ||
</q-item-section> | ||
<q-item-section side> | ||
<platform-enabled-input | ||
v-model="perfs.enableShortcutKey" | ||
v-bind="inputProps" | ||
/> | ||
</q-item-section> | ||
</q-item> | ||
<q-separator spaced /> | ||
<q-item-label header> | ||
对话页面 | ||
</q-item-label> | ||
<q-item> | ||
<q-item-section> | ||
<q-item-label> | ||
向上滚动 | ||
</q-item-label> | ||
</q-item-section> | ||
<q-item-section side> | ||
<shortcut-key-input | ||
v-model="perfs.scrollUpKey" | ||
v-bind="inputProps" | ||
/> | ||
</q-item-section> | ||
</q-item> | ||
<q-item> | ||
<q-item-section> | ||
<q-item-label> | ||
向下滚动 | ||
</q-item-label> | ||
</q-item-section> | ||
<q-item-section side> | ||
<shortcut-key-input | ||
v-model="perfs.scrollDownKey" | ||
v-bind="inputProps" | ||
/> | ||
</q-item-section> | ||
</q-item> | ||
<q-item> | ||
<q-item-section> | ||
<q-item-label> | ||
滚动到顶部 | ||
</q-item-label> | ||
</q-item-section> | ||
<q-item-section side> | ||
<shortcut-key-input | ||
v-model="perfs.scrollTopKey" | ||
v-bind="inputProps" | ||
/> | ||
</q-item-section> | ||
</q-item> | ||
<q-item> | ||
<q-item-section> | ||
<q-item-label> | ||
滚动到底部 | ||
</q-item-label> | ||
</q-item-section> | ||
<q-item-section side> | ||
<shortcut-key-input | ||
v-model="perfs.scrollBottomKey" | ||
v-bind="inputProps" | ||
/> | ||
</q-item-section> | ||
</q-item> | ||
<q-item> | ||
<q-item-section> | ||
<q-item-label> | ||
切换到前一条消息链 | ||
</q-item-label> | ||
</q-item-section> | ||
<q-item-section side> | ||
<shortcut-key-input | ||
v-model="perfs.switchPrevKey" | ||
v-bind="inputProps" | ||
/> | ||
</q-item-section> | ||
</q-item> | ||
<q-item> | ||
<q-item-section> | ||
<q-item-label> | ||
切换到后一条消息链 | ||
</q-item-label> | ||
</q-item-section> | ||
<q-item-section side> | ||
<shortcut-key-input | ||
v-model="perfs.switchNextKey" | ||
v-bind="inputProps" | ||
/> | ||
</q-item-section> | ||
</q-item> | ||
<q-item> | ||
<q-item-section> | ||
<q-item-label> | ||
切换到第一条消息链 | ||
</q-item-label> | ||
</q-item-section> | ||
<q-item-section side> | ||
<shortcut-key-input | ||
v-model="perfs.switchFirstKey" | ||
v-bind="inputProps" | ||
/> | ||
</q-item-section> | ||
</q-item> | ||
<q-item> | ||
<q-item-section> | ||
<q-item-label> | ||
切换到最后一条消息链 | ||
</q-item-label> | ||
</q-item-section> | ||
<q-item-section side> | ||
<shortcut-key-input | ||
v-model="perfs.switchLastKey" | ||
v-bind="inputProps" | ||
/> | ||
</q-item-section> | ||
</q-item> | ||
</q-list> | ||
</q-page> | ||
</q-page-container> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { useUserPerfsStore } from 'src/stores/user-perfs' | ||
import { pageFhStyle } from 'src/utils/functions' | ||
import { useBack } from 'src/composables/back' | ||
import ShortcutKeyInput from 'src/components/ShortcutKeyInput.vue' | ||
import PlatformEnabledInput from 'src/components/PlatformEnabledInput.vue' | ||
const { perfs } = useUserPerfsStore() | ||
const back = useBack('/settings') | ||
const inputProps = { | ||
dense: true, | ||
filled: true, | ||
class: 'min-w-150px' | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.