【发布时间】:2021-03-15 09:00:58
【问题描述】:
我希望启动画面在屏幕上停留 3 秒,但 electron 加载应用程序的速度比这更快,所以它只停留一秒钟。
我正在使用 Angular 来制作 SPA。
这是启动画面和主窗口的电子函数
app.on("ready", () => {
// create main browser window
mainWindow = new BrowserWindow({
titleBarStyle: "hidden",
width: 1920,
height: 1080,
show: false, // don't show the main window
});
// create a new `splash`-Window
splash = new BrowserWindow({
width: 800,
height: 450,
transparent: true,
frame: false,
alwaysOnTop: true,
});
splash.loadURL(`file://${__dirname}/splash.html`);
mainWindow.loadURL(`file://${__dirname}/dist/MedalFrontEnd/index.html`);
// if main window is ready to show, then destroy the splash window and show up the main window
function showFunc() {
mainWindow.once("ready-to-show", () => {
splash.destroy();
mainWindow.show();
});
}
showFunc();
});
【问题讨论】:
-
我不是一个真正的电子人,但你不能只做 setTimeout(() => {splash.destroy(); mainWindow.show();}, 3000) 吗?跨度>
标签: javascript node.js angular electron