mirror of
https://github.com/Elvanos/fantasia-archive.git
synced 2024-09-21 11:52:12 +12:00
finalized splash screen setup
This commit is contained in:
parent
56bbcc0285
commit
6e55d8cf65
2 changed files with 24 additions and 7 deletions
|
@ -23,9 +23,10 @@
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
transition: 0.5s opacity ease-in;
|
transition: 0.3s opacity ease-in;
|
||||||
transition-delay: 2s;
|
transition-delay: 2s;
|
||||||
z-index: 9999999999999999999;
|
z-index: 9999999999999999999;
|
||||||
|
min-width: 600px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.splashLoading{
|
.splashLoading{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { BrowserWindow, app } from 'electron'
|
import { BrowserWindow, app, screen } from 'electron'
|
||||||
import { enable } from '@electron/remote/main'
|
import { enable } from '@electron/remote/main'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,9 @@ const preventSecondaryAppInstance = (appWindow: BrowserWindow | undefined) => {
|
||||||
*/
|
*/
|
||||||
app.on('second-instance', () => {
|
app.on('second-instance', () => {
|
||||||
if (appWindow) {
|
if (appWindow) {
|
||||||
if (appWindow.isMinimized()) appWindow.restore()
|
if (appWindow.isMinimized()) {
|
||||||
|
appWindow.restore()
|
||||||
|
}
|
||||||
appWindow.focus()
|
appWindow.focus()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -36,13 +38,21 @@ const preventSecondaryAppInstance = (appWindow: BrowserWindow | undefined) => {
|
||||||
* Creates the main app window
|
* Creates the main app window
|
||||||
*/
|
*/
|
||||||
export const mainWindowCreation = () => {
|
export const mainWindowCreation = () => {
|
||||||
|
/**
|
||||||
|
* Retrieve actual display size to stop flicker/debounce that happens with "maximize" function at first
|
||||||
|
*/
|
||||||
|
const displaySizes = screen.getPrimaryDisplay().workAreaSize
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initial window options
|
* Initial window options
|
||||||
*/
|
*/
|
||||||
let appWindow: BrowserWindow | undefined = new BrowserWindow({
|
let appWindow: BrowserWindow | undefined = new BrowserWindow({
|
||||||
|
width: displaySizes.width,
|
||||||
|
height: displaySizes.height,
|
||||||
useContentSize: true,
|
useContentSize: true,
|
||||||
frame: false,
|
frame: false,
|
||||||
show: false,
|
show: false,
|
||||||
|
center: true,
|
||||||
icon: path.resolve(__dirname, '../icons/icon.png'),
|
icon: path.resolve(__dirname, '../icons/icon.png'),
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
sandbox: false,
|
sandbox: false,
|
||||||
|
@ -54,10 +64,19 @@ export const mainWindowCreation = () => {
|
||||||
// Enable actual webContents inside the created window
|
// Enable actual webContents inside the created window
|
||||||
enable(appWindow.webContents)
|
enable(appWindow.webContents)
|
||||||
|
|
||||||
|
// Show the windows once electron is ready to show the actual HTML content
|
||||||
appWindow.once('ready-to-show', () => {
|
appWindow.once('ready-to-show', () => {
|
||||||
if (appWindow) {
|
if (appWindow) {
|
||||||
appWindow.maximize()
|
appWindow.show()
|
||||||
appWindow.focus()
|
appWindow.focus()
|
||||||
|
appWindow.maximize()
|
||||||
|
|
||||||
|
// In case the windows somehow didn't maximize at first, make sure it does; this is a fix for slower machines
|
||||||
|
setTimeout(() => {
|
||||||
|
if (appWindow) {
|
||||||
|
appWindow.maximize()
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -79,7 +98,4 @@ export const mainWindowCreation = () => {
|
||||||
|
|
||||||
// Check if we are on the primary or secondary instance of the app
|
// Check if we are on the primary or secondary instance of the app
|
||||||
preventSecondaryAppInstance(appWindow)
|
preventSecondaryAppInstance(appWindow)
|
||||||
|
|
||||||
// In case the window somehow didn't maximize/show for any reason; maximize it
|
|
||||||
appWindow.maximize()
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue