mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-09-21 22:45:20 +00:00
add loadingWindow
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<PackageOutputPath>..\artifacts</PackageOutputPath>
|
||||
<PackageId>ElectronNET.CLI</PackageId>
|
||||
<Version>1.0.2</Version>
|
||||
<Version>1.0.4</Version>
|
||||
<Authors>Gregor Biswanger, Robert Muehsig</Authors>
|
||||
<Product>Electron.NET</Product>
|
||||
<Company />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { app } = require('electron');
|
||||
const { BrowserWindow } = require('electron')
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const process = require('child_process').spawn;
|
||||
@@ -6,8 +7,13 @@ const portfinder = require('detect-port');
|
||||
let io, browserWindows, ipc, apiProcess, loadURL;
|
||||
let appApi, menu, dialog, notification, tray, webContents;
|
||||
let globalShortcut, shell, screen, clipboard;
|
||||
let loadingWindow;
|
||||
|
||||
app.on('ready', () => {
|
||||
|
||||
// yf add
|
||||
startLoadingWindow();
|
||||
|
||||
portfinder(8000, (error, port) => {
|
||||
startSocketApiBridge(port);
|
||||
});
|
||||
@@ -59,10 +65,38 @@ function startAspCoreBackend(electronPort) {
|
||||
apiProcess.stdout.on('data', (data) => {
|
||||
var text = data.toString();
|
||||
console.log(`stdout: ${data.toString()}`);
|
||||
|
||||
if (data.toString().indexOf("MainWindowShowed") > -1 && loadingWindow && !loadingWindow.isDestroyed()) {
|
||||
loadingWindow.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function startLoadingWindow() {
|
||||
const manifestFile = require("./bin/electron.manifest.json");
|
||||
let loadingUrl = manifestFile.loadingUrl;
|
||||
let icon = manifestFile.icon;
|
||||
if (loadingUrl) {
|
||||
loadingWindow = new BrowserWindow({
|
||||
width: 400,
|
||||
height: 435,
|
||||
transparent: true,
|
||||
frame: false,
|
||||
show: false,
|
||||
devTools: true,
|
||||
icon: path.join(__dirname, icon)
|
||||
})
|
||||
loadingWindow.loadURL(loadingUrl);
|
||||
loadingWindow.once('ready-to-show', () => {
|
||||
loadingWindow.show()
|
||||
})
|
||||
loadingWindow.on('closed', () => {
|
||||
loadingWindow = null
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
//app.on('activate', () => {
|
||||
// On macOS it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
|
||||
Reference in New Issue
Block a user