feat: custom title bar that is more compact
This commit is contained in:
@@ -12,6 +12,7 @@ import { getGitEngine } from '../engine/GitEngine';
|
||||
import { taskManager, TaskProgress } from '../engine/TaskManager';
|
||||
import { getDatabase } from '../database';
|
||||
import { media } from '../database/schema';
|
||||
import { APP_MENU_ACTION_EVENT_MAP, APP_MENU_WEB_CONTENTS_ACTIONS, type AppMenuAction } from '../shared/menuCommands';
|
||||
|
||||
/**
|
||||
* Wrap an IPC handler so that "Database is closing" errors during shutdown
|
||||
@@ -46,6 +47,45 @@ function resolvePostCreatedAt(post: { createdAt: Date | string }): Date {
|
||||
return Number.isNaN(parsed.getTime()) ? new Date() : parsed;
|
||||
}
|
||||
|
||||
function runWebContentsMenuAction(sender: any, action: AppMenuAction): boolean {
|
||||
if (!sender) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!APP_MENU_WEB_CONTENTS_ACTIONS.has(action)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case 'undo':
|
||||
sender.undo?.();
|
||||
return true;
|
||||
case 'redo':
|
||||
sender.redo?.();
|
||||
return true;
|
||||
case 'cut':
|
||||
sender.cut?.();
|
||||
return true;
|
||||
case 'copy':
|
||||
sender.copy?.();
|
||||
return true;
|
||||
case 'paste':
|
||||
sender.paste?.();
|
||||
return true;
|
||||
case 'delete':
|
||||
sender.delete?.();
|
||||
return true;
|
||||
case 'selectAll':
|
||||
sender.selectAll?.();
|
||||
return true;
|
||||
case 'toggleDevTools':
|
||||
sender.toggleDevTools?.();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function registerIpcHandlers(): void {
|
||||
// ============ Git Handlers ============
|
||||
|
||||
@@ -673,6 +713,20 @@ export function registerIpcHandlers(): void {
|
||||
}
|
||||
});
|
||||
|
||||
safeHandle('app:triggerMenuAction', async (event, action: string) => {
|
||||
const typedAction = action as AppMenuAction;
|
||||
const handledByWebContents = runWebContentsMenuAction((event as any)?.sender, typedAction);
|
||||
if (handledByWebContents) {
|
||||
return;
|
||||
}
|
||||
|
||||
const channel = APP_MENU_ACTION_EVENT_MAP[typedAction];
|
||||
if (!channel) {
|
||||
return;
|
||||
}
|
||||
event.sender.send(channel);
|
||||
});
|
||||
|
||||
// ============ Meta Handlers ============
|
||||
|
||||
safeHandle('meta:getTags', async () => {
|
||||
|
||||
Reference in New Issue
Block a user