feat: add support for allowing Escape key to exit fullscreen mode (#5930)

* feat: add support for allowing Escape key to exit fullscreen mode

* feat(i18n): add translation for allowing ESC key to exit fullscreen mode in multiple locales

* feat: enable Escape key to exit fullscreen mode regardless of platform

* feat: 添加允许使用Escape键退出全屏模式的功能,并更新相关国际化支持

* fix: 修复全屏模式下Escape键退出功能的状态管理,移除相关设置项

* feat: 添加全屏状态管理功能至导航栏,更新右侧导航栏组件以支持全屏模式

* feat: 更新导航栏以支持全屏模式,调整右侧导航栏的内边距

* fix: 更新全屏模式下Escape键退出功能的默认设置为启用

* refactor: 移除全屏模式下Escape键退出功能的状态管理逻辑

* fix: 移除全屏模式下Escape键退出功能的调试日志

* feat: 添加全屏模式下Escape键的快捷键配置,默认启用

* refactor: 移除与全屏模式下Escape键退出功能相关的IPC通道和配置

* refactor: 移除全屏模式下Escape键退出功能的配置项

* refactor: 移除Navbar和McpSettingsNavbar中与全屏模式相关的代码

* refactor: 移动exit_fullscreen快捷键配置到shortcuts数组末尾

* refactor: 添加全屏模式下快捷键未设置时直接退出全屏的逻辑

* refactor: 添加全屏模式下快捷键未设置时直接退出全屏的逻辑

* refactor: remove unused useFullscreen hook

* refactor: remove 'allow ESC key to exit fullscreen mode' translations from multiple locale files

---------

Co-authored-by: George Zhao <georgezhao@SKJLAB>
This commit is contained in:
George Zhao 2025-05-14 23:35:02 +08:00 committed by GitHub
parent 8f7c5eed75
commit 5e0080c5a1
7 changed files with 41 additions and 3 deletions

View File

@ -198,10 +198,21 @@ export class WindowService {
// 当按下Escape键且窗口处于全屏状态时退出全屏
if (input.key === 'Escape' && !input.alt && !input.control && !input.meta && !input.shift) {
if (mainWindow.isFullScreen()) {
event.preventDefault()
mainWindow.setFullScreen(false)
// 获取 shortcuts 配置
const shortcuts = configManager.getShortcuts()
const exitFullscreenShortcut = shortcuts.find((s) => s.key === 'exit_fullscreen')
if (exitFullscreenShortcut == undefined) {
mainWindow.setFullScreen(false)
return
}
if (exitFullscreenShortcut?.enabled) {
event.preventDefault()
mainWindow.setFullScreen(false)
return
}
}
}
return
})
}
@ -306,7 +317,7 @@ export class WindowService {
/**
* :
* win/linux: +
* win/linux: "开启托盘+设置关闭时最小化到托盘"
* mac: 任何情况都会到这里mac
*/

View File

@ -1530,6 +1530,7 @@
"clear_shortcut": "Clear Shortcut",
"clear_topic": "Clear Messages",
"copy_last_message": "Copy Last Message",
"exit_fullscreen": "Exit Fullscreen",
"key": "Key",
"mini_window": "Quick Assistant",
"new_topic": "New Topic",

View File

@ -1526,6 +1526,7 @@
"clear_shortcut": "ショートカットをクリア",
"clear_topic": "メッセージを消去",
"copy_last_message": "最後のメッセージをコピー",
"exit_fullscreen": "フルスクリーンを終了",
"key": "キー",
"mini_window": "クイックアシスタント",
"new_topic": "新しいトピック",

View File

@ -1526,6 +1526,7 @@
"clear_shortcut": "Очистить сочетание клавиш",
"clear_topic": "Очистить все сообщения",
"copy_last_message": "Копировать последнее сообщение",
"exit_fullscreen": "Выйти из полноэкранного режима",
"key": "Клавиша",
"mini_window": "Быстрый помощник",
"new_topic": "Новый топик",

View File

@ -1530,6 +1530,7 @@
"clear_shortcut": "清除快捷键",
"clear_topic": "清空消息",
"copy_last_message": "复制上一条消息",
"exit_fullscreen": "退出全屏",
"key": "按键",
"mini_window": "快捷助手",
"new_topic": "新建话题",

View File

@ -1316,6 +1316,22 @@ const migrateConfig = {
} catch (error) {
return state
}
},
'101': (state: RootState) => {
try {
if (state.shortcuts) {
state.shortcuts.shortcuts.push({
key: 'exit_fullscreen',
shortcut: ['Escape'],
editable: false,
enabled: true,
system: true
})
}
return state
} catch (error) {
return state
}
}
}

View File

@ -79,6 +79,13 @@ const initialState: ShortcutsState = {
editable: true,
enabled: true,
system: false
},
{
key: 'exit_fullscreen',
shortcut: ['Escape'],
editable: false,
enabled: true,
system: true
}
]
}