:lightning: macOS performance
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ipcMain, dialog, BrowserWindow } from 'electron'
|
||||
import { ipcMain, dialog, BrowserWindow, Menu } from 'electron'
|
||||
import {
|
||||
listStories, readStory, writeStory, createStory, renameStory, deleteStory,
|
||||
getStoryMeta, setStoryMeta, getCollectionConfig, setCollectionContext,
|
||||
@@ -60,6 +60,34 @@ export function registerIpcHandlers(): void {
|
||||
return result.canceled ? null : result.filePaths[0]
|
||||
})
|
||||
|
||||
// ── Native context menus ─────────────────────────────────────────────────────
|
||||
ipcMain.handle('menu:editorContext', async (event) => {
|
||||
const win = BrowserWindow.fromWebContents(event.sender)
|
||||
if (!win) return
|
||||
const menu = Menu.buildFromTemplate([
|
||||
{ role: 'cut' },
|
||||
{ role: 'copy' },
|
||||
{ role: 'paste' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'selectAll' },
|
||||
])
|
||||
menu.popup({ window: win })
|
||||
})
|
||||
|
||||
ipcMain.handle('menu:storyContext', async (event, _storyId: string) => {
|
||||
const win = BrowserWindow.fromWebContents(event.sender)
|
||||
if (!win) return
|
||||
return new Promise<string | null>((resolve) => {
|
||||
const menu = Menu.buildFromTemplate([
|
||||
{ label: 'Rename', click: () => resolve('rename') },
|
||||
{ type: 'separator' },
|
||||
{ label: 'Delete', click: () => resolve('delete') },
|
||||
])
|
||||
menu.on('menu-will-close', () => setTimeout(() => resolve(null), 100))
|
||||
menu.popup({ window: win })
|
||||
})
|
||||
})
|
||||
|
||||
// ── AI streaming ──────────────────────────────────────────────────────────────
|
||||
ipcMain.handle('ai:streamMessage', async (event, payload: AIPayload) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user