update
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { join, sep } from 'node:path'
|
||||
import { app, shell, BrowserWindow, ipcMain } from 'electron'
|
||||
import { app, dialog, shell, BrowserWindow, ipcMain } from 'electron'
|
||||
import { watch, type FSWatcher } from 'chokidar'
|
||||
import { getName, getRoot, openDialog } from './project'
|
||||
import { readAll, readProjectFile, readTree, writeProjectFile } from './fs-service'
|
||||
@@ -84,6 +84,20 @@ function registerIpc(): void {
|
||||
|
||||
ipcMain.handle('search:content', (_e, query: string) => searchContent(getRoot(), query))
|
||||
ipcMain.handle('search:files', () => listFiles(getRoot()))
|
||||
|
||||
ipcMain.handle('dialog:unsavedClose', async (e, path: string) => {
|
||||
const win = BrowserWindow.fromWebContents(e.sender)
|
||||
const opts: Electron.MessageBoxOptions = {
|
||||
type: 'warning',
|
||||
buttons: ['Save', "Don't Save", 'Cancel'],
|
||||
defaultId: 0,
|
||||
cancelId: 2,
|
||||
message: `Save changes to ${path}?`,
|
||||
detail: 'Your changes will be lost if you don’t save them.',
|
||||
}
|
||||
const { response } = win ? await dialog.showMessageBox(win, opts) : await dialog.showMessageBox(opts)
|
||||
return response === 0 ? 'save' : response === 1 ? 'discard' : 'cancel'
|
||||
})
|
||||
}
|
||||
|
||||
function createWindow(): void {
|
||||
@@ -97,7 +111,7 @@ function createWindow(): void {
|
||||
titleBarStyle: isMac ? 'hiddenInset' : 'default',
|
||||
trafficLightPosition: isMac ? { x: 14, y: 12 } : undefined,
|
||||
webPreferences: {
|
||||
preload: join(__dirname, '../preload/index.js'),
|
||||
preload: join(__dirname, '../preload/index.cjs'),
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
sandbox: false,
|
||||
|
||||
Reference in New Issue
Block a user