adapt windows
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
import { globalShortcut, type BrowserWindow } from 'electron'
|
||||
import { globalShortcut } from 'electron'
|
||||
import { sendPlayerControl } from './playerControl'
|
||||
|
||||
/**
|
||||
* 媒体快捷键:
|
||||
* - 播放/暂停:全局 Super+P(macOS ⌘P / Windows Win+P),托盘后台也可用
|
||||
* - 快退/快进:仅窗口聚焦时 Super+← / Super+→,避免全局抢占方向键
|
||||
*
|
||||
* Electron 的 Super = Windows 徽标键 / macOS Command。
|
||||
* 注意:Windows 系统常占用 Win+P(投影),注册失败时会打日志。
|
||||
* - 播放/暂停:全局 CommandOrControl+P(macOS ⌘P / Windows Ctrl+P),与原项目一致
|
||||
* - 快退/快进:由渲染进程监听 ← / →(与原项目一致,见 playerStore)
|
||||
*/
|
||||
|
||||
const GLOBAL_PLAY_PAUSE = 'Super+P'
|
||||
const GLOBAL_PLAY_PAUSE = 'CommandOrControl+P'
|
||||
|
||||
export function registerMediaShortcuts(): void {
|
||||
try {
|
||||
@@ -32,22 +29,3 @@ export function unregisterMediaShortcuts(): void {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
/** 窗口聚焦时的快退 / 快进(不注册全局,避免影响其它应用) */
|
||||
export function bindSeekShortcuts(window: BrowserWindow): void {
|
||||
window.webContents.on('before-input-event', (event, input) => {
|
||||
if (input.type !== 'keyDown') return
|
||||
// meta = macOS Command / Windows 徽标键
|
||||
if (!input.meta || input.control || input.alt) return
|
||||
|
||||
if (input.code === 'ArrowLeft') {
|
||||
event.preventDefault()
|
||||
sendPlayerControl('seek-backward')
|
||||
return
|
||||
}
|
||||
if (input.code === 'ArrowRight') {
|
||||
event.preventDefault()
|
||||
sendPlayerControl('seek-forward')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user