Skip to content

Commit

Permalink
added splashscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
ubench-org committed Aug 13, 2023
1 parent 1a8a8f1 commit cee7a7d
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 5 deletions.
24 changes: 24 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,30 @@ select {
.hidden {
visibility: collapse;
}
.spinner-xl {
border: 8px solid white;
border-radius: 50%;
width: 128px;
height: 128px;
animation: pulse 1s linear infinite;
margin: auto;
position: absolute;
top: 46px;
left: calc(50% - 68px);
}


@keyframes pulse {
0% {
opacity: 1;
scale: 0.9;
}

100% {
opacity: 0;
scale: 1.1;
}
}

.spinner {
border: 2px solid var(--dark);
Expand Down
24 changes: 24 additions & 0 deletions public/splash.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UBench Launcher</title>

<link rel="stylesheet" href="./css/style.css">
<style>
.logo {
width: 128px;
height: 128px;
top: 54px;
left: calc(50% - 60px );
position: absolute;
}
</style>
</head>
<body>
<img src="./icons/logo.png" class="logo">
<div class="spinner-xl"></div>
</body>

</html>
3 changes: 3 additions & 0 deletions public/views/settings.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<p id="version_p">UBench Launcher Version</p>
<p hidden id="version"><%=version%></p>
<p>&copy; UBench Organization</p>

<img src="./icons/logo.png" class="logo">
<div class="spinner-xl"></div>
</div>
<script>
let version = document.getElementById("version").innerHTML; //.toString().split(".");
Expand Down
34 changes: 29 additions & 5 deletions src/ubenchlauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function analyze_system() {
has_sysinfo = true;

ejse.data("version", fs.readJSONSync(path.join(rootDir, "package.json")).version);
ejse.data('sysinfo',JSON.stringify(fs.readJsonSync(path.join(rootDir, "data", "sysinfo.json"))));
ejse.data('sysinfo', JSON.stringify(fs.readJsonSync(path.join(rootDir, "data", "sysinfo.json"))));
ejse.data("menu", "System");
fs.writeJsonSync(path.join(rootDir, "data", "sysinfo.json"), {
"uuid": uuid,
Expand All @@ -182,9 +182,28 @@ function analyze_system() {


let mainWindow;
let splashWindow;

const splash = () => {

splashWindow = new BrowserWindow({
width: 400,
height: 250,
transparent: false,
frame: false,
alwaysOnTop: true
});
splashWindow.loadFile(path.join(rootDir, "public", "splash.html"))

splashWindow.once('ready-to-show', () => {
splashWindow.center();
})

}

const createWindow = () => {
// Create the browser window.
splashWindow.close();
mainWindow = new BrowserWindow({
width: 600,
height: 400,
Expand All @@ -199,7 +218,7 @@ const createWindow = () => {
autoHideMenuBar: true,
title: "UBench Launcher"
})


ipcMain.on('load', (event) => {
event.sender.send('load');
Expand Down Expand Up @@ -311,7 +330,9 @@ const createWindow = () => {
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.whenReady().then(() => {


splash();

const options = {
type: 'question',
buttons: ['Disagree', 'Yes, collect anonymous data'],
Expand All @@ -327,11 +348,14 @@ app.whenReady().then(() => {
else fs.writeJSONSync(path.join(rootDir, "data", "sysinfo.json"), {});
}


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.
if (BrowserWindow.getAllWindows().length === 0) createWindow()
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
splashWindow.hide();
}
})
})

Expand Down

0 comments on commit cee7a7d

Please sign in to comment.