feat: added skeleton omr api integration
This commit is contained in:
+28
-1
@@ -1,7 +1,7 @@
|
||||
import { app, BrowserWindow, ipcMain, dialog, Menu, nativeTheme } from "electron"
|
||||
import { join, dirname } from "node:path"
|
||||
import { fileURLToPath } from "node:url"
|
||||
import { readFileSync, writeFileSync } from "node:fs"
|
||||
import { readFileSync, writeFileSync, existsSync, mkdirSync, copyFileSync, readdirSync } from "node:fs"
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
@@ -69,6 +69,14 @@ ipcMain.handle("dialog:openFile", async (_event, filters: { name: string; extens
|
||||
return result.filePaths
|
||||
})
|
||||
|
||||
ipcMain.handle("dialog:openDirectory", async () => {
|
||||
const result = await dialog.showOpenDialog(win!, {
|
||||
properties: ["openDirectory"],
|
||||
})
|
||||
win?.webContents?.focus()
|
||||
return result.filePaths?.[0] ?? ""
|
||||
})
|
||||
|
||||
ipcMain.handle("dialog:saveFile", async (_event, defaultName: string, filters: { name: string; extensions: string[] }[]) => {
|
||||
const result = await dialog.showSaveDialog(win!, {
|
||||
defaultPath: defaultName,
|
||||
@@ -97,6 +105,25 @@ ipcMain.handle("file:writeBinary", async (_event, path: string, base64: string)
|
||||
writeFileSync(path, Buffer.from(base64, "base64"))
|
||||
})
|
||||
|
||||
ipcMain.handle("dir:read", async (_event, dirPath: string) => {
|
||||
if (!existsSync(dirPath)) return []
|
||||
const entries = readdirSync(dirPath, { withFileTypes: true })
|
||||
return entries.map((e) => ({ name: e.name, isDirectory: e.isDirectory() }))
|
||||
})
|
||||
|
||||
ipcMain.handle("dir:ensure", async (_event, dirPath: string) => {
|
||||
if (!existsSync(dirPath)) mkdirSync(dirPath, { recursive: true })
|
||||
return dirPath
|
||||
})
|
||||
|
||||
ipcMain.handle("path:exists", async (_event, path: string) => {
|
||||
return existsSync(path)
|
||||
})
|
||||
|
||||
ipcMain.handle("file:copy", async (_event, src: string, dest: string) => {
|
||||
copyFileSync(src, dest)
|
||||
})
|
||||
|
||||
app.whenReady().then(createWindow)
|
||||
|
||||
app.on("window-all-closed", () => {
|
||||
|
||||
Reference in New Issue
Block a user