chore(version): 0.8.7

This commit is contained in:
kangfenmao 2024-10-31 14:40:02 +08:00
parent e2fc593624
commit 968a749aaa
2 changed files with 40 additions and 21 deletions

View File

@ -1,6 +1,6 @@
{
"name": "CherryStudio",
"version": "0.8.6",
"version": "0.8.7",
"private": true,
"description": "A powerful AI assistant for producer.",
"main": "./out/main/index.js",

View File

@ -1,26 +1,45 @@
import { BrowserWindow, globalShortcut } from 'electron'
export function registerZoomShortcut(mainWindow: BrowserWindow) {
// 注册放大快捷键 (Ctrl+Plus 或 Cmd+Plus)
globalShortcut.register('CommandOrControl+=', () => {
if (mainWindow) {
const currentZoom = mainWindow.webContents.getZoomFactor()
mainWindow.webContents.setZoomFactor(currentZoom + 0.1)
}
})
const registerShortcuts = () => {
// 注册放大快捷键 (Ctrl+Plus 或 Cmd+Plus)
globalShortcut.register('CommandOrControl+=', () => {
if (mainWindow) {
const currentZoom = mainWindow.webContents.getZoomFactor()
mainWindow.webContents.setZoomFactor(currentZoom + 0.1)
}
})
// 注册缩小快捷键 (Ctrl+Minus 或 Cmd+Minus)
globalShortcut.register('CommandOrControl+-', () => {
if (mainWindow) {
const currentZoom = mainWindow.webContents.getZoomFactor()
mainWindow.webContents.setZoomFactor(currentZoom - 0.1)
}
})
// 注册缩小快捷键 (Ctrl+Minus 或 Cmd+Minus)
globalShortcut.register('CommandOrControl+-', () => {
if (mainWindow) {
const currentZoom = mainWindow.webContents.getZoomFactor()
mainWindow.webContents.setZoomFactor(currentZoom - 0.1)
}
})
// 注册重置缩放快捷键 (Ctrl+0 或 Cmd+0)
globalShortcut.register('CommandOrControl+0', () => {
if (mainWindow) {
mainWindow.webContents.setZoomFactor(1)
}
})
// 注册重置缩放快捷键 (Ctrl+0 或 Cmd+0)
globalShortcut.register('CommandOrControl+0', () => {
if (mainWindow) {
mainWindow.webContents.setZoomFactor(1)
}
})
}
const unregisterShortcuts = () => {
globalShortcut.unregister('CommandOrControl+=')
globalShortcut.unregister('CommandOrControl+-')
globalShortcut.unregister('CommandOrControl+0')
}
// 当窗口获得焦点时注册快捷键
mainWindow.on('focus', registerShortcuts)
// 当窗口失去焦点时注销快捷键
mainWindow.on('blur', unregisterShortcuts)
// 初始注册(如果窗口已经处于焦点状态)
if (mainWindow.isFocused()) {
registerShortcuts()
}
}