Enhance Windows startup window management
Some checks failed
farmcontrol/farmcontrol-ui/pipeline/head There was a failure building this commit
Some checks failed
farmcontrol/farmcontrol-ui/pipeline/head There was a failure building this commit
- Introduced a delay for maximizing the window on startup to improve user experience on Windows. - Refactored window state application logic to ensure proper handling of window maximization and layout synchronization. - Updated platform checks to use a dedicated constant for Windows, improving code clarity and maintainability.
This commit is contained in:
parent
5450473f74
commit
1cc21fd9e3
@ -7,6 +7,8 @@ import {
|
|||||||
import { sendToRenderer, setMessageSender } from './notify.js'
|
import { sendToRenderer, setMessageSender } from './notify.js'
|
||||||
|
|
||||||
const isMacOS = process.platform === 'darwin'
|
const isMacOS = process.platform === 'darwin'
|
||||||
|
const isWindows = process.platform === 'win32'
|
||||||
|
const WINDOWS_STARTUP_MAXIMIZE_DELAY_MS = 1500
|
||||||
|
|
||||||
const DEV_SERVER_PORT = 5780
|
const DEV_SERVER_PORT = 5780
|
||||||
const DEV_SERVER_URL = `http://localhost:${DEV_SERVER_PORT}`
|
const DEV_SERVER_URL = `http://localhost:${DEV_SERVER_PORT}`
|
||||||
@ -144,7 +146,7 @@ function broadcastWindowState() {
|
|||||||
function applyStartupWindowState(window) {
|
function applyStartupWindowState(window) {
|
||||||
if (!window) return
|
if (!window) return
|
||||||
|
|
||||||
if (isMacOS || process.platform === 'win32') {
|
if (isMacOS) {
|
||||||
window.maximize?.()
|
window.maximize?.()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,10 +170,13 @@ function syncWindowsWebviewLayout(window) {
|
|||||||
function applyWindowsStartupWindowState(window) {
|
function applyWindowsStartupWindowState(window) {
|
||||||
if (!window) return
|
if (!window) return
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
window.maximize?.()
|
||||||
syncWindowsWebviewLayout(window)
|
syncWindowsWebviewLayout(window)
|
||||||
setTimeout(() => syncWindowsWebviewLayout(window), 0)
|
setTimeout(() => syncWindowsWebviewLayout(window), 0)
|
||||||
setTimeout(() => syncWindowsWebviewLayout(window), 100)
|
setTimeout(() => syncWindowsWebviewLayout(window), 100)
|
||||||
setTimeout(broadcastWindowState, 100)
|
setTimeout(broadcastWindowState, 100)
|
||||||
|
}, WINDOWS_STARTUP_MAXIMIZE_DELAY_MS)
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupWindowEvents(window) {
|
function setupWindowEvents(window) {
|
||||||
@ -264,7 +269,7 @@ export async function createMainWindow(rpc) {
|
|||||||
mainWindow.webview.on('dom-ready', () => {
|
mainWindow.webview.on('dom-ready', () => {
|
||||||
webviewDomReady = true
|
webviewDomReady = true
|
||||||
|
|
||||||
if (process.platform === 'win32') {
|
if (isWindows) {
|
||||||
applyWindowsStartupWindowState(mainWindow)
|
applyWindowsStartupWindowState(mainWindow)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user