-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplash.html
More file actions
120 lines (104 loc) · 4.09 KB
/
Copy pathsplash.html
File metadata and controls
120 lines (104 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Twine - Загрузка</title>
<link rel="stylesheet" href="splash.css" />
</head>
<body>
<div class="splash-container">
<!-- Логотип -->
<div class="logo-container">
<img src="public/logo/logo-icon.svg" alt="Twine" class="logo" />
</div>
<!-- Статус текст -->
<div class="status-container">
<p id="status-text" class="status-text">Запуск приложения...</p>
</div>
<!-- Прогресс бар (скрыт по умолчанию) -->
<div id="progress-container" class="progress-container hidden">
<div class="progress-bar">
<div id="progress-fill" class="progress-fill"></div>
</div>
<p id="progress-text" class="progress-text">0%</p>
</div>
</div>
<script>
const { ipcRenderer } = require('electron');
const statusText = document.getElementById('status-text');
const progressContainer = document.getElementById('progress-container');
const progressFill = document.getElementById('progress-fill');
const progressText = document.getElementById('progress-text');
// Функция для плавной смены текста
function updateStatus(text) {
statusText.classList.add('fade-out');
setTimeout(() => {
statusText.textContent = text;
statusText.classList.remove('fade-out');
}, 150);
}
// Показать/скрыть прогресс бар
function toggleProgress(show) {
if (show) {
progressContainer.classList.remove('hidden');
setTimeout(() => {
progressContainer.classList.add('visible');
}, 10);
} else {
progressContainer.classList.remove('visible');
setTimeout(() => {
progressContainer.classList.add('hidden');
}, 300);
}
}
// Обновить прогресс
function updateProgress(percent) {
progressFill.style.width = percent + '%';
progressText.textContent = Math.round(percent) + '%';
}
// Слушатели событий от main процесса
ipcRenderer.on('status-update', (event, message) => {
updateStatus(message);
});
ipcRenderer.on('checking-for-update', () => {
updateStatus('Проверяем обновления...');
});
ipcRenderer.on('update-available', () => {
updateStatus('Найдено обновление!');
setTimeout(() => {
updateStatus('Скачиваем обновление...');
toggleProgress(true);
}, 1000);
});
ipcRenderer.on('update-not-available', () => {
updateStatus('Обновлений нет');
setTimeout(() => {
updateStatus('Загрузка приложения...');
}, 500);
});
ipcRenderer.on('download-progress', (event, progressObj) => {
updateProgress(progressObj.percent);
});
ipcRenderer.on('update-downloaded', () => {
updateStatus('Обновление скачано!');
toggleProgress(false);
setTimeout(() => {
updateStatus('Устанавливаем обновление...');
}, 500);
});
ipcRenderer.on('error', () => {
// При ошибке обновления (если вдруг придет) просто продолжаем загрузку
updateStatus('Загрузка приложения...');
toggleProgress(false);
setTimeout(() => {
// Можно отправить событие, если нужно, но тут просто меняем статус
}, 500);
});
// Начальная проверка после небольшой задержки
setTimeout(() => {
updateStatus('Проверяем обновления...');
}, 500);
</script>
</body>
</html>