feat: initialize project scaffold with Electron structure, transcription engine, and dark-themed UI components
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
const electron = require("electron");
|
||||
const path = require("path");
|
||||
const utils = require("@electron-toolkit/utils");
|
||||
const icon = path.join(__dirname, "../../resources/icon.png");
|
||||
function createWindow() {
|
||||
const mainWindow = new electron.BrowserWindow({
|
||||
width: 1100,
|
||||
height: 670,
|
||||
show: false,
|
||||
autoHideMenuBar: true,
|
||||
...process.platform === "linux" ? { icon } : {},
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, "../preload/index.mjs"),
|
||||
sandbox: false
|
||||
},
|
||||
frame: false,
|
||||
// Custom frame for premium look
|
||||
transparent: true,
|
||||
backgroundColor: "#00000000"
|
||||
});
|
||||
mainWindow.on("ready-to-show", () => {
|
||||
mainWindow.show();
|
||||
});
|
||||
mainWindow.webContents.setWindowOpenHandler((details) => {
|
||||
electron.shell.openExternal(details.url);
|
||||
return { action: "deny" };
|
||||
});
|
||||
if (utils.is.dev && process.env["ELECTRON_RENDERER_URL"]) {
|
||||
mainWindow.loadURL(process.env["ELECTRON_RENDERER_URL"]);
|
||||
} else {
|
||||
mainWindow.loadFile(path.join(__dirname, "../renderer/index.html"));
|
||||
}
|
||||
}
|
||||
electron.app.whenReady().then(() => {
|
||||
utils.electronApp.setAppUserModelId("com.voicext.app");
|
||||
electron.app.on("browser-window-created", (_, window) => {
|
||||
utils.optimizer.watchWindowShortcuts(window);
|
||||
});
|
||||
electron.ipcMain.on("window-controls", (event, action) => {
|
||||
const win = electron.BrowserWindow.fromWebContents(event.sender);
|
||||
if (action === "minimize") win.minimize();
|
||||
if (action === "maximize") win.isMaximized() ? win.unmaximize() : win.maximize();
|
||||
if (action === "close") win.close();
|
||||
});
|
||||
createWindow();
|
||||
electron.app.on("activate", function() {
|
||||
if (electron.BrowserWindow.getAllWindows().length === 0) createWindow();
|
||||
});
|
||||
});
|
||||
electron.app.on("window-all-closed", () => {
|
||||
if (process.platform !== "darwin") {
|
||||
electron.app.quit();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
const electron = require("electron");
|
||||
const preload = require("@electron-toolkit/preload");
|
||||
const api = {
|
||||
windowControls: (action) => electron.ipcRenderer.send("window-controls", action)
|
||||
};
|
||||
if (process.contextIsolated) {
|
||||
try {
|
||||
preload.exposeElectronAPI();
|
||||
electron.contextBridge.exposeInMainWorld("api", api);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
} else {
|
||||
window.electron = preload.exposeElectronAPI();
|
||||
window.api = api;
|
||||
}
|
||||
Reference in New Issue
Block a user