Comments (2)
I don't think this is related to these schematics.
To prevent the main window from updating its title when loading the your index.html you need to react to the 'page-title-updated' event as documented here: https://github.com/electron/electron/blob/master/docs/api/browser-window.md#event-page-title-updated
var win = new BrowserWindow({
title: 'My app'
});
win.on('page-title-updated', (event) => {
event.preventDefault();
});
If your project is using the default Angular CLI structure I think you need to look for your icon in src/assets/icon.png/
.
from electron-schematics.
Hi, with 'page-title-updated'
event handling, I can set the title of the window. But unfortunately, the title in the macOS application menu is still set to "electron".
Also I adjusted the icon path, but the app is still using the electron icon.
Here is the electron related code:
// Modules to control application life and create native browser window
import { app, BrowserWindow, Menu, MenuItem } from "electron";
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow: BrowserWindow | null = null;
const menuTemplate = [
{
label: "Filter",
submenu: [
{
label: "main page",
accelerator: "Shift+CmdOrCtrl+S",
click() {
mainWindow.loadURL(process.env.ELECTRON_URL);
}
}
]
}
];
const menu = Menu.buildFromTemplate(menuTemplate);
function createWindow() {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 500,
title: "my fancy app",
icon: "src/assets/icon.png"
});
// and load the index.html of the app.
const isServe = process.env.ELECTRON_SERVE === "true";
if (isServe) {
mainWindow.loadURL(process.env.ELECTRON_URL);
} else {
mainWindow.loadFile("index.html");
}
// Open the DevTools.
// mainWindow.webContents.openDevTools();
// Emitted when the window is closed.
mainWindow.on("closed", () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
mainWindow.on("page-title-updated", event => {
event.preventDefault();
});
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on("ready", () => {
Menu.setApplicationMenu(menu);
createWindow();
});
// Quit when all windows are closed.
app.on("window-all-closed", () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
this file is located (as generated by the schematics) here: projects/electron/main.ts
.
And the icon is located in src/assets/icon.png
.
from electron-schematics.
Related Issues (10)
- Multiple electron processes HOT 1
- console.log doesn't work HOT 2
- Multiple processes after uncaught exceptions HOT 4
- Will this work with NativeScript's Angular code share schematic? HOT 1
- Allow us to set electron and electron-builder version HOT 4
- electron 5?
- Allow to specify targets for electron-builder
- Not able to reference assets in production HOT 1
- Allow to pass --configuration and other parameters when building
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron-schematics.