| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
This guide explains how to include and use a custom_main.js file in your Electron.NET application for advanced Electron/Node.js customization.
Place your custom logic in electron/custom_main.js:
module.exports.onStartup = function(host) {
// Example: Register a global shortcut for opening dev tools
const { app, globalShortcut, BrowserWindow } = require('electron');
app.on('ready', () => {
const ret = globalShortcut.register('Control+Shift+I', () => {
BrowserWindow.getAllWindows().forEach(win => win.webContents.openDevTools());
console.log('Ctrl+Shift+I is pressed: DevTools opened!');
});
});
app.on('will-quit', () => {
globalShortcut.unregisterAll();
});
return true;
};Add this to your .csproj file:
<ItemGroup>
<None Update="electron\custom_main.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>.electron\custom_main.js</TargetPath>
</None>
</ItemGroup>Use the standard build/run commands:
dotnet build
dotnet runElectron.NET will automatically load and execute your custom_main.js before initializing the .NET backend.
Use environment variables to control features:
const env = process.env.ASPNETCORE_ENVIRONMENT || 'Production';
if (env === 'Development') { /* enable dev features */ }Want to contribute to this documentation? Please fork and create a PR! The Wiki is autogenerated from the /docs content in the repository.
| Back | FazBrowse Home | New Git URL |