chore: bump version to 0.7.1
This commit is contained in:
254
electron-app/loading.html
Normal file
254
electron-app/loading.html
Normal file
@@ -0,0 +1,254 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>lyroc 启动中...</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
background: linear-gradient(135deg, #1e1e28, #2d2d3a);
|
||||
color: #fff;
|
||||
overflow: hidden;
|
||||
user-select: none;
|
||||
border-radius: 12px;
|
||||
opacity: 1;
|
||||
transition: opacity 0.8s ease-out;
|
||||
}
|
||||
|
||||
body.fade-out {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
max-width: 280px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
margin-bottom: 20px;
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 18px;
|
||||
margin-bottom: 30px;
|
||||
font-weight: 300;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.progress-container {
|
||||
width: 100%;
|
||||
height: 6px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 3px;
|
||||
overflow: hidden;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
height: 100%;
|
||||
width: 0%;
|
||||
background: linear-gradient(90deg, #00c6fb 0%, #005bea 100%);
|
||||
border-radius: 3px;
|
||||
transition: width 0.4s ease;
|
||||
}
|
||||
|
||||
.progress-info {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 5px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.progress-percentage {
|
||||
font-size: 16px;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
min-width: 50px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.status {
|
||||
font-size: 12px;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
margin-top: 10px;
|
||||
min-height: 16px;
|
||||
}
|
||||
|
||||
.progress-label {
|
||||
font-size: 16px;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
min-width: 50px;
|
||||
text-align: left;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0% { opacity: 0.8; transform: scale(0.95); }
|
||||
50% { opacity: 1; transform: scale(1); }
|
||||
100% { opacity: 0.8; transform: scale(0.95); }
|
||||
}
|
||||
|
||||
.logo-placeholder {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, #00c6fb, #005bea);
|
||||
margin-bottom: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logo-placeholder">lyroc</div>
|
||||
<h1 class="title" id="loading-title">lyroc 启动中</h1>
|
||||
<div class="progress-info">
|
||||
<div class="progress-label" id="progress-label">进度</div>
|
||||
<span class="progress-percentage" id="progress-percentage">0%</span>
|
||||
</div>
|
||||
<div class="progress-container">
|
||||
<div class="progress-bar" id="progress"></div>
|
||||
</div>
|
||||
<div class="status" id="status">正在初始化应用...</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 监听来自主进程的消息
|
||||
const { ipcRenderer } = require('electron');
|
||||
|
||||
// 获取DOM元素
|
||||
const progressBar = document.getElementById('progress');
|
||||
const statusText = document.getElementById('status');
|
||||
const progressPercentageText = document.getElementById('progress-percentage');
|
||||
const loadingTitle = document.getElementById('loading-title');
|
||||
const progressLabel = document.getElementById('progress-label');
|
||||
|
||||
// 设置初始进度
|
||||
let currentProgress = 0;
|
||||
|
||||
// 语言配置
|
||||
const translations = {
|
||||
en: {
|
||||
title: 'lyroc Starting',
|
||||
progress: 'Progress',
|
||||
initializing: 'Initializing application...',
|
||||
ready: 'Ready'
|
||||
},
|
||||
zh: {
|
||||
title: 'lyroc 启动中',
|
||||
progress: '进度',
|
||||
initializing: '正在初始化应用...',
|
||||
ready: '准备就绪'
|
||||
}
|
||||
};
|
||||
|
||||
// 设置语言
|
||||
function setLanguage(lang) {
|
||||
const t = translations[lang] || translations.en;
|
||||
loadingTitle.textContent = t.title;
|
||||
progressLabel.textContent = t.progress;
|
||||
if (currentProgress === 0) {
|
||||
statusText.textContent = t.initializing;
|
||||
}
|
||||
}
|
||||
|
||||
// 监听语言切换事件
|
||||
ipcRenderer.on('change-language', (_, lang) => {
|
||||
console.log('加载窗口收到语言切换事件:', lang);
|
||||
setLanguage(lang);
|
||||
});
|
||||
|
||||
// 监听进度更新事件
|
||||
ipcRenderer.on('update-progress', (event, data) => {
|
||||
// 更新进度条
|
||||
currentProgress = data.progress;
|
||||
progressBar.style.width = `${currentProgress}%`;
|
||||
progressPercentageText.textContent = `${Math.round(currentProgress)}%`;
|
||||
|
||||
// 更新状态文本
|
||||
if (data.message) {
|
||||
statusText.textContent = data.message;
|
||||
}
|
||||
|
||||
// 如果进度达到100%,添加淡出效果
|
||||
if (currentProgress >= 100) {
|
||||
// 清除自动增长定时器
|
||||
clearInterval(autoIncreaseInterval);
|
||||
|
||||
// 延迟一会儿后添加淡出效果
|
||||
setTimeout(() => {
|
||||
document.body.classList.add('fade-out');
|
||||
|
||||
// 通知主进程可以关闭窗口了
|
||||
setTimeout(() => {
|
||||
ipcRenderer.send('loading-finished');
|
||||
}, 800); // 与CSS中的淡出时间一致
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
|
||||
// 动画平滑过渡到目标进度
|
||||
function animateProgress(target, duration) {
|
||||
const start = currentProgress;
|
||||
const startTime = performance.now();
|
||||
|
||||
function updateFrame(currentTime) {
|
||||
const elapsed = currentTime - startTime;
|
||||
const progress = Math.min(elapsed / duration, 1);
|
||||
const current = start + (target - start) * progress;
|
||||
|
||||
progressBar.style.width = `${current}%`;
|
||||
progressPercentageText.textContent = `${Math.round(current)}%`;
|
||||
|
||||
if (progress < 1) {
|
||||
requestAnimationFrame(updateFrame);
|
||||
}
|
||||
}
|
||||
|
||||
requestAnimationFrame(updateFrame);
|
||||
}
|
||||
|
||||
// 自动增加一点进度,给用户感觉应用正在加载
|
||||
let autoIncreaseInterval = setInterval(() => {
|
||||
if (currentProgress < 90) {
|
||||
const increment = Math.random() * 0.5;
|
||||
currentProgress += increment;
|
||||
progressBar.style.width = `${currentProgress}%`;
|
||||
progressPercentageText.textContent = `${Math.round(currentProgress)}%`;
|
||||
}
|
||||
}, 400);
|
||||
|
||||
// 页面加载完成时,设置初始进度
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
progressBar.style.width = '10%';
|
||||
progressPercentageText.textContent = '10%';
|
||||
currentProgress = 10;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user