fix throwing error screen before loading update

This commit is contained in:
RoyceDa
2026-01-30 17:20:14 +02:00
parent d099346056
commit ad696616e1
4 changed files with 121 additions and 80 deletions

View File

@@ -108,22 +108,29 @@ export function foundationIpcRegistration(mainWindow: BrowserWindow) {
});
ipcMain.on('window-resize', (_, { width, height }) => {
const { x: currentX, y: currentY, width: currentWidth, height: currentHeight } = mainWindow.getBounds();
const { x: currentX, y: currentY } = mainWindow.getBounds();
const newX = currentX + (currentWidth - width) / 2;
const newY = currentY + (currentHeight - height) / 2;
const display = screen.getDisplayMatching(mainWindow.getBounds());
const displayBounds = display.workArea;
const { width: screenWidth, height: screenHeight } = screen.getPrimaryDisplay().workAreaSize;
let newX = currentX;
let newY = currentY;
const clampedX = Math.max(0, Math.min(newX, screenWidth - width));
//const clampedY = Math.max(0, Math.min(newY, screenHeight - height));
if (currentX + width > displayBounds.x + displayBounds.width) {
newX = displayBounds.x + displayBounds.width - width;
}
if (currentY + height > displayBounds.y + displayBounds.height) {
newY = displayBounds.y + displayBounds.height - height;
}
mainWindow.setBounds({
x: Math.round(clampedX),
//y: Math.round(clampedY),
width,
height,
x: newX,
y: newY,
width: width,
height: height
});
mainWindow.webContents.send('window-state-changed');
});
ipcMain.on('window-resizeble', (_, isResizeble) => {

View File

@@ -15,6 +15,13 @@ ipcMain.handleOnce('report-boot-process-failed', async () => {
* приложение попыталось загрузиться в режиме разработки.
*/
let filePath = path.join(WORKING_DIR, 'b');
if(!await existsFile(filePath)){
/**
* Исправление ошибки когда директории нет.
*/
logger.log("No compiled files to remove");
return;
}
await fs.rmdir(filePath, { recursive: true });
logger.log("Boot process failed, removed compiled files");
logger.log(`Removed compiled files at ${filePath}`);

View File

@@ -89,19 +89,34 @@ const exposeContext = async () => {
let arch = await ipcRenderer.invoke("get-arch");
let deviceName = await ipcRenderer.invoke("device:name");
let deviceId = await ipcRenderer.invoke("device:id");
let interval : any = 0;
setTimeout(() => {
interval = setInterval(() => {
/**
* Если после определенного таймаута приложение так и
* не загрузилось, то считаем, что процесс завис,
* и показываем экран ошибки. Так же отправляем
* сигнал в main процесс, чтобы тот мог попытаться
* откатить обновление.
* откатить обновление
*/
if (document.body.innerHTML.indexOf("preloadersignature") !== -1) {
/**
* Если сейчас показывается прелоадер, то не считаем
* что обновление битое, так как само обновление еще не
* загрузилось в приложение
*/
return;
}
if (document.body.innerHTML.length < 100) {
/**
* Приложение загружено, а прошло больше 5 секунд
* с момента прелоадера, значит что-то пошло не так
* и нужно показать экран ошибки
*/
if(document.body.innerHTML.length < 100){
document.body.innerHTML = applicationError;
ipcRenderer.invoke("report-boot-process-failed");
}
clearInterval(interval);
}, 5000);
let downloadsPath = await ipcRenderer.invoke("get-downloads-path");

View File

@@ -1,26 +1,35 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<!--
Нужно чтобы точно определить, что сейчас показывается preload
И при старте начинать проверять boot только после того, как этот файл загрузится
-->
<meta key="preloadersignature">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rosetta</title>
<style>
.pulse {
animation: pulse 1s infinite;
}
@keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.15);
}
100% {
transform: scale(1);
}
}
</style>
<style>
*{
* {
padding: 0px;
margin: 0px;
text-align: center;
@@ -31,7 +40,8 @@
-webkit-user-select: none;
-webkit-app-region: no-drag;
}
body{
body {
display: flex;
justify-content: center;
align-items: center;
@@ -41,7 +51,9 @@
}
</style>
</head>
<body>
<img src="R.png" width="100" height="100" class="pulse">
</body>
</html>