DEL: Remove loading window
This commit is contained in:
@@ -4,14 +4,9 @@ import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
|||||||
import icon from '../../resources/icon.png?asset'
|
import icon from '../../resources/icon.png?asset'
|
||||||
import nanodevices from './backend/nanodevices'
|
import nanodevices from './backend/nanodevices'
|
||||||
|
|
||||||
// Minimum time to show the splash screen, in milliseconds
|
|
||||||
const splashTime = is.dev ? 5000 : 5000
|
|
||||||
const loadingWindowWidth = 800 / 2
|
|
||||||
const loadingWindowHeight = 1100 / 2
|
|
||||||
|
|
||||||
const zoomFactor = 1
|
const zoomFactor = 1
|
||||||
const mainWindowWidth = 1111
|
const windowWidth = 1111
|
||||||
const mainWindowHeight = 666
|
const windowHeight = 666
|
||||||
|
|
||||||
const appMenu = {
|
const appMenu = {
|
||||||
device: {
|
device: {
|
||||||
@@ -32,13 +27,13 @@ const createMainWindow = () => {
|
|||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
const mainWindow = new BrowserWindow({
|
const mainWindow = new BrowserWindow({
|
||||||
show: false,
|
show: false,
|
||||||
width: mainWindowWidth,
|
width: windowWidth,
|
||||||
height: mainWindowHeight,
|
height: windowHeight,
|
||||||
titleBarStyle: 'hidden',
|
titleBarStyle: 'hidden',
|
||||||
trafficLightPosition: { x: 10, y: 10 },
|
trafficLightPosition: { x: 10, y: 10 },
|
||||||
resizable: true,
|
resizable: true,
|
||||||
minWidth: mainWindowWidth / 3,
|
minWidth: windowWidth / 3,
|
||||||
minHeight: mainWindowHeight / 3,
|
minHeight: windowHeight / 3,
|
||||||
maximizable: true,
|
maximizable: true,
|
||||||
fullscreenable: false,
|
fullscreenable: false,
|
||||||
center: true,
|
center: true,
|
||||||
@@ -52,12 +47,12 @@ const createMainWindow = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mainWindow.setAspectRatio(mainWindowWidth / mainWindowHeight)
|
mainWindow.setAspectRatio(windowWidth / windowHeight)
|
||||||
mainWindow.webContents.on('dom-ready', () => {
|
mainWindow.webContents.on('dom-ready', () => {
|
||||||
mainWindow.webContents.setZoomFactor(zoomFactor)
|
mainWindow.webContents.setZoomFactor(zoomFactor)
|
||||||
})
|
})
|
||||||
mainWindow.on('resize', () => {
|
mainWindow.on('resize', () => {
|
||||||
mainWindow.webContents.setZoomFactor((zoomFactor * mainWindow.getSize()[0]) / mainWindowWidth)
|
mainWindow.webContents.setZoomFactor((zoomFactor * mainWindow.getSize()[0]) / windowWidth)
|
||||||
})
|
})
|
||||||
mainWindow.on('maximize', () => {
|
mainWindow.on('maximize', () => {
|
||||||
mainWindow.webContents.send('electron:maximized')
|
mainWindow.webContents.send('electron:maximized')
|
||||||
@@ -79,56 +74,11 @@ const createMainWindow = () => {
|
|||||||
mainWindow.loadFile(join(__dirname, '../renderer/index.html'))
|
mainWindow.loadFile(join(__dirname, '../renderer/index.html'))
|
||||||
}
|
}
|
||||||
|
|
||||||
return mainWindow
|
mainWindow.once('ready-to-show', () => {
|
||||||
}
|
mainWindow.show()
|
||||||
|
})
|
||||||
|
|
||||||
const createLoadingWindow = (mainWindow) => {
|
return mainWindow
|
||||||
const loadingWindow = new BrowserWindow({
|
|
||||||
show: false,
|
|
||||||
width: loadingWindowWidth,
|
|
||||||
height: loadingWindowHeight,
|
|
||||||
resizable: false,
|
|
||||||
fullscreenable: false,
|
|
||||||
maximizable: false,
|
|
||||||
transparent: true,
|
|
||||||
frame: false,
|
|
||||||
center: true,
|
|
||||||
backgroundColor: 'black',
|
|
||||||
...(process.platform === 'linux' ? { icon } : {}),
|
|
||||||
webPreferences: {
|
|
||||||
devTools: is.dev,
|
|
||||||
sandbox: false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const startTime = Date.now()
|
|
||||||
let loadingTimeout
|
|
||||||
mainWindow.webContents.once('did-finish-load', () => {
|
|
||||||
loadingTimeout = setTimeout(
|
|
||||||
() => {
|
|
||||||
mainWindow.show()
|
|
||||||
mainWindow.focus()
|
|
||||||
loadingWindow.close()
|
|
||||||
},
|
|
||||||
Math.max(0, splashTime - (Date.now() - startTime))
|
|
||||||
)
|
|
||||||
})
|
|
||||||
loadingWindow.once('closed', () => {
|
|
||||||
if (!mainWindow.isFocusable()) {
|
|
||||||
clearTimeout(loadingTimeout)
|
|
||||||
mainWindow.close()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
loadingWindow.webContents.once('did-finish-load', () => {
|
|
||||||
loadingWindow.show()
|
|
||||||
loadingWindow.focus()
|
|
||||||
})
|
|
||||||
// HMR for renderer base on electron-vite cli.
|
|
||||||
// Load the remote URL for development or the local html file for production.
|
|
||||||
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
|
|
||||||
loadingWindow.loadURL(`${process.env['ELECTRON_RENDERER_URL']}/loading.html`)
|
|
||||||
} else {
|
|
||||||
loadingWindow.loadFile(join(__dirname, '../renderer/loading.html'))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
@@ -150,7 +100,6 @@ app.whenReady().then(() => {
|
|||||||
ipcMain.handle('nanodevices:disconnect', nanodevices.disconnect)
|
ipcMain.handle('nanodevices:disconnect', nanodevices.disconnect)
|
||||||
ipcMain.handle('nanodevices:send', nanodevices.send)
|
ipcMain.handle('nanodevices:send', nanodevices.send)
|
||||||
const mainWindow = createMainWindow()
|
const mainWindow = createMainWindow()
|
||||||
createLoadingWindow(mainWindow)
|
|
||||||
ipcMain.on('electron:minimizeWindow', () => mainWindow.minimize())
|
ipcMain.on('electron:minimizeWindow', () => mainWindow.minimize())
|
||||||
ipcMain.on('electron:toggleMaximizeWindow', () => {
|
ipcMain.on('electron:toggleMaximizeWindow', () => {
|
||||||
if (mainWindow.isMaximized()) {
|
if (mainWindow.isMaximized()) {
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<title>ZERO/ONE Starting...</title>
|
|
||||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
|
||||||
<meta
|
|
||||||
http-equiv="Content-Security-Policy"
|
|
||||||
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:"
|
|
||||||
/>
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
background: black url(src/assets/images/splashBG.png) center;
|
|
||||||
background-size: cover;
|
|
||||||
color: white;
|
|
||||||
height: 100vh;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.badge {
|
|
||||||
background: #f79c1e;
|
|
||||||
color: black;
|
|
||||||
display: inline-block;
|
|
||||||
align-self: center;
|
|
||||||
width: fit-content;
|
|
||||||
border-radius: 4px;
|
|
||||||
padding: 4px 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
margin-top: 10vh;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status {
|
|
||||||
margin-top: 10vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer {
|
|
||||||
font-size: 0.5rem;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<link rel="stylesheet" href="/src/assets/main.css">
|
|
||||||
<link rel="preload" href="/src/assets/fonts/ProtoMono-Regular.ttf" as="font" crossorigin="anonymous" />
|
|
||||||
<link rel="preload" href="/src/assets/fonts/JetBrainsMono%5Bwght%5D.ttf" as="font" crossorigin="anonymous" />
|
|
||||||
<link rel="preload" href="/src/assets/fonts/SG12.ttf" as="font" crossorigin="anonymous" />
|
|
||||||
<link rel="preload" href="/src/assets/fonts/andina.ttf" as="font" crossorigin="anonymous" />
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body class="dark bg-background">
|
|
||||||
<div class="flex h-full flex-col text-center justify-between items-center p-2 px-8 select-none">
|
|
||||||
<div class="title flex flex-col gap-2">
|
|
||||||
<h1 class="text-5xl">ZERO<span class="opacity-70">/</span>ONE</h1>
|
|
||||||
<p class="text-muted-foreground">Configuration Suite v0.1</p>
|
|
||||||
<div class="badge text-xs">PUBLIC BETA</div>
|
|
||||||
<div class="status">
|
|
||||||
<p>Stand by...</p>
|
|
||||||
<p class="text-muted-foreground text-sm">The goblins are turning the cogs.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="footer flex items-center flex-col gap-2 text-muted-foreground">
|
|
||||||
<img width="14" src="/src/assets/icons/binarisEmblem.svg" alt="binaris-logo">
|
|
||||||
<p>Copyright 2024 Binaris Circuitry Ltd.</p>
|
|
||||||
<p>This software is licensed under the Apache License, Version 2.0 (the "License"). Usage of this
|
|
||||||
software is
|
|
||||||
permitted only in compliance with the terms of the License.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Reference in New Issue
Block a user