mirror of
https://github.com/aaif-goose/goose.git
synced 2026-07-03 14:10:03 +02:00
feat: use mac main menu (#366)
This commit is contained in:
@@ -215,13 +215,18 @@ function ChatContent({
|
||||
}
|
||||
|
||||
export default function ChatWindow() {
|
||||
// Shared function to create a chat window
|
||||
const openNewChatWindow = () => {
|
||||
window.electron.createChatWindow();
|
||||
};
|
||||
|
||||
// Add keyboard shortcut handler
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
// Check for Command+N (Mac) or Control+N (Windows/Linux)
|
||||
if ((event.metaKey || event.ctrlKey) && event.key === 'n') {
|
||||
event.preventDefault(); // Prevent default browser behavior
|
||||
window.electron.createChatWindow();
|
||||
openNewChatWindow();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+20
-2
@@ -1,6 +1,6 @@
|
||||
import 'dotenv/config';
|
||||
import { loadZshEnv } from './utils/loadEnv';
|
||||
import { app, BrowserWindow, Tray, Menu, globalShortcut, ipcMain, Notification } from 'electron';
|
||||
import { app, BrowserWindow, Tray, Menu, globalShortcut, ipcMain, Notification, MenuItem } from 'electron';
|
||||
import path from 'node:path';
|
||||
import { findAvailablePort, startGoosed } from './goosed';
|
||||
import started from "electron-squirrel-startup";
|
||||
@@ -208,6 +208,23 @@ app.whenReady().then(async () => {
|
||||
// Show launcher input on key combo
|
||||
globalShortcut.register('Control+Alt+Command+G', createLauncher);
|
||||
|
||||
// Preserve existing menu and add new items
|
||||
const menu = Menu.getApplicationMenu();
|
||||
const fileMenu = menu?.items.find(item => item.label === 'File');
|
||||
|
||||
// Add 'New Chat Window' to File menu
|
||||
if (fileMenu && fileMenu.submenu) {
|
||||
fileMenu.submenu.append(new MenuItem({
|
||||
label: 'New Chat Window',
|
||||
accelerator: 'CmdOrCtrl+N',
|
||||
click() {
|
||||
ipcMain.emit('create-chat-window');
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
Menu.setApplicationMenu(menu);
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createChat(app);
|
||||
@@ -266,4 +283,5 @@ app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user