mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 02:06:01 +00:00
electron splash screen
This commit is contained in:
@@ -11,12 +11,22 @@ const url = require('url');
|
|||||||
// Keep a global reference of the window object, if you don't, the window will
|
// 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.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow;
|
let mainWindow;
|
||||||
|
let splashWindow;
|
||||||
|
|
||||||
|
function hideSplash() {
|
||||||
|
if (splashWindow) {
|
||||||
|
splashWindow.destroy();
|
||||||
|
splashWindow = null;
|
||||||
|
}
|
||||||
|
mainWindow.show();
|
||||||
|
}
|
||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 800,
|
// width: 800,
|
||||||
height: 600,
|
// height: 600,
|
||||||
|
show: false,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
},
|
},
|
||||||
@@ -30,9 +40,26 @@ function createWindow() {
|
|||||||
protocol: 'file:',
|
protocol: 'file:',
|
||||||
slashes: true,
|
slashes: true,
|
||||||
});
|
});
|
||||||
|
mainWindow.webContents.on('did-finish-load', function () {
|
||||||
|
hideSplash();
|
||||||
|
});
|
||||||
mainWindow.loadURL(startUrl);
|
mainWindow.loadURL(startUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
splashWindow = new BrowserWindow({
|
||||||
|
width: 300,
|
||||||
|
height: 120,
|
||||||
|
transparent: true,
|
||||||
|
frame: false,
|
||||||
|
});
|
||||||
|
splashWindow.loadURL(
|
||||||
|
url.format({
|
||||||
|
pathname: path.join(__dirname, '../packages/web/build/splash.html'),
|
||||||
|
protocol: 'file:',
|
||||||
|
slashes: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
if (process.env.ELECTRON_START_URL) {
|
if (process.env.ELECTRON_START_URL) {
|
||||||
loadMainWindow();
|
loadMainWindow();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
16
packages/web/public/splash.css
Normal file
16
packages/web/public/splash.css
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
body {
|
||||||
|
background: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
div {
|
||||||
|
color: white;
|
||||||
|
font-size: 25pt;
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
text-align: center;
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
12
packages/web/public/splash.html
Normal file
12
packages/web/public/splash.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="splash.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div>Starting DbGate...</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -4,7 +4,9 @@ export default function resolveApi() {
|
|||||||
|
|
||||||
if (electron) {
|
if (electron) {
|
||||||
const port = electron.remote.getGlobal('port');
|
const port = electron.remote.getGlobal('port');
|
||||||
return `http://localhost:${port}`;
|
if (port) {
|
||||||
|
return `http://localhost:${port}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user