:lightning: macOS performance
This commit is contained in:
@@ -2,7 +2,7 @@ import { app, BrowserWindow, shell, nativeImage, Menu, dialog } from 'electron'
|
||||
import { join } from 'path'
|
||||
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
||||
import { registerIpcHandlers } from './ipcHandlers'
|
||||
import { getCollectionRoot } from './globalConfig'
|
||||
import { getCollectionRoot, readGlobalConfig } from './globalConfig'
|
||||
|
||||
app.setName('Borges')
|
||||
|
||||
@@ -92,6 +92,8 @@ function buildAppMenu(win: BrowserWindow): void {
|
||||
|
||||
function createWindow(): BrowserWindow {
|
||||
const icon = nativeImage.createFromPath(join(__dirname, '../../resources/icon.png'))
|
||||
const config = readGlobalConfig()
|
||||
const isDark = config.theme !== 'light'
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 1440,
|
||||
height: 900,
|
||||
@@ -99,6 +101,8 @@ function createWindow(): BrowserWindow {
|
||||
minHeight: 600,
|
||||
title: 'Borges',
|
||||
titleBarStyle: 'hiddenInset',
|
||||
vibrancy: 'sidebar',
|
||||
backgroundColor: isDark ? '#1c1a18' : '#f5f0ea',
|
||||
icon,
|
||||
show: false,
|
||||
webPreferences: {
|
||||
|
||||
@@ -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