mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
调整快捷键
This commit is contained in:
@@ -27,6 +27,8 @@ const actions = {
|
||||
|
||||
type ActionName = keyof typeof actions
|
||||
|
||||
export const hasCtrlCmd = (e: KeyboardEvent | MouseEvent) => isMacOS ? e.metaKey : e.ctrlKey
|
||||
|
||||
export const getKeyLabel = (key: XKey | string | number) => {
|
||||
switch (key) {
|
||||
case CtrlCmd:
|
||||
@@ -45,8 +47,6 @@ export const getActionLabel = (name: ActionName) => {
|
||||
return keys.map(getKeyLabel).join(' + ')
|
||||
}
|
||||
|
||||
export const hasCtrlCmd = (e: KeyboardEvent | MouseEvent) => isMacOS ? e.metaKey : e.ctrlKey
|
||||
|
||||
export const matchKeys = (e: KeyboardEvent | MouseEvent, keys: (string | number)[]) => {
|
||||
for (const key of keys) {
|
||||
switch (key) {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useBus } from './bus'
|
||||
import RunPlugin from '@/plugins/RunPlugin'
|
||||
import { copyText } from './copy-text'
|
||||
import env from './env'
|
||||
import { hasCtrlCmd } from './shortcut'
|
||||
|
||||
export default function startup () {
|
||||
const bus = useBus()
|
||||
@@ -35,7 +36,7 @@ export default function startup () {
|
||||
}
|
||||
|
||||
window.addEventListener('keydown', e => {
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
if (hasCtrlCmd(e)) {
|
||||
if (e.key === '0') {
|
||||
webContents.setZoomFactor(1)
|
||||
} else if (e.key === '=') {
|
||||
@@ -49,7 +50,7 @@ export default function startup () {
|
||||
window.addEventListener('mousewheel', event => {
|
||||
const e = event as WheelEvent
|
||||
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
if (hasCtrlCmd(e)) {
|
||||
changeZoomFactor(e.deltaY < 0)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user