mirror of
https://github.com/Elvanos/fantasia-archive.git
synced 2024-05-04 12:23:18 +12:00
finalized splash screen setup
This commit is contained in:
parent
56bbcc0285
commit
6e55d8cf65
|
@ -23,9 +23,10 @@
|
|||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
transition: 0.5s opacity ease-in;
|
||||
transition: 0.3s opacity ease-in;
|
||||
transition-delay: 2s;
|
||||
z-index: 9999999999999999999;
|
||||
min-width: 600px;
|
||||
}
|
||||
|
||||
.splashLoading{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { BrowserWindow, app } from 'electron'
|
||||
import { BrowserWindow, app, screen } from 'electron'
|
||||
import { enable } from '@electron/remote/main'
|
||||
import path from 'path'
|
||||
/**
|
||||
|
@ -25,7 +25,9 @@ const preventSecondaryAppInstance = (appWindow: BrowserWindow | undefined) => {
|
|||
*/
|
||||
app.on('second-instance', () => {
|
||||
if (appWindow) {
|
||||
if (appWindow.isMinimized()) appWindow.restore()
|
||||
if (appWindow.isMinimized()) {
|
||||
appWindow.restore()
|
||||
}
|
||||
appWindow.focus()
|
||||
}
|
||||
})
|
||||
|
@ -36,13 +38,21 @@ const preventSecondaryAppInstance = (appWindow: BrowserWindow | undefined) => {
|
|||
* Creates the main app window
|
||||
*/
|
||||
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
|
||||
*/
|
||||
let appWindow: BrowserWindow | undefined = new BrowserWindow({
|
||||
width: displaySizes.width,
|
||||
height: displaySizes.height,
|
||||
useContentSize: true,
|
||||
frame: false,
|
||||
show: false,
|
||||
center: true,
|
||||
icon: path.resolve(__dirname, '../icons/icon.png'),
|
||||
webPreferences: {
|
||||
sandbox: false,
|
||||
|
@ -54,10 +64,19 @@ export const mainWindowCreation = () => {
|
|||
// Enable actual webContents inside the created window
|
||||
enable(appWindow.webContents)
|
||||
|
||||
// Show the windows once electron is ready to show the actual HTML content
|
||||
appWindow.once('ready-to-show', () => {
|
||||
if (appWindow) {
|
||||
appWindow.maximize()
|
||||
appWindow.show()
|
||||
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
|
||||
preventSecondaryAppInstance(appWindow)
|
||||
|
||||
// In case the window somehow didn't maximize/show for any reason; maximize it
|
||||
appWindow.maximize()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue