- Removed the inline translation function from LspSettings component and replaced it with centralized i18n keys. - Updated all relevant text in LspSettings to use the new translation keys. - Introduced a new startup language caching mechanism to ensure the splash screen displays the correct language before settings are loaded. - Refactored app initialization to utilize the new language caching and update loader status based on app initialization phases. - Added tests to ensure that splash screen text remains in sync with the locale table and that no inline bilingual text exists in the codebase.
595 lines
18 KiB
HTML
595 lines
18 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<link rel="icon" type="image/png" href="%BASE_URL%brand/icons/app.png" />
|
|
<title>Adnify</title>
|
|
|
|
<!-- 立即设置背景色和主题,在任何渲染之前 -->
|
|
<script>
|
|
(function () {
|
|
var bg = '#121215';
|
|
var loaderBg = '#121215';
|
|
var isLight = false;
|
|
try {
|
|
var urlParams = new URLSearchParams(window.location.search);
|
|
var themeId = localStorage.getItem('adnify-theme-id') || localStorage.getItem('adnify-theme-current');
|
|
var themeType = localStorage.getItem('adnify-theme-type');
|
|
var themeBg = localStorage.getItem('adnify-theme-bg');
|
|
var currentTheme = localStorage.getItem('adnify-current-theme');
|
|
var queryThemeId = urlParams.get('themeId');
|
|
var queryCurrentTheme = urlParams.get('currentTheme');
|
|
var queryThemeType = urlParams.get('themeType');
|
|
var queryCurrentThemeType = urlParams.get('currentThemeType');
|
|
var queryThemeBg = urlParams.get('themeBg');
|
|
var themes = {
|
|
'adnify-dark': { bg: '#121215', twBg: '18 18 21', light: false },
|
|
'midnight': { bg: '#161B22', twBg: '22 27 34', light: false },
|
|
'cyberpunk': { bg: '#030305', twBg: '3 3 5', light: false },
|
|
'dawn': { bg: '#FFFFFF', twBg: '255 255 255', light: true }
|
|
};
|
|
themeId = queryThemeId || themeId;
|
|
currentTheme = queryCurrentTheme || currentTheme;
|
|
themeType = queryThemeType || themeType;
|
|
if (queryCurrentThemeType) {
|
|
themeType = queryCurrentThemeType;
|
|
}
|
|
themeBg = queryThemeBg || themeBg;
|
|
var resolvedThemeId = currentTheme || themeId;
|
|
var theme = resolvedThemeId && themes[resolvedThemeId] ? themes[resolvedThemeId] : null;
|
|
isLight = themeType === 'light' || (theme && theme.light);
|
|
|
|
if (theme) {
|
|
bg = theme.bg;
|
|
loaderBg = theme.bg;
|
|
document.documentElement.style.setProperty('--background', theme.twBg);
|
|
} else if (themeBg) {
|
|
if (themeBg.indexOf(' ') !== -1) {
|
|
bg = 'rgb(' + themeBg.replace(/ /g, ', ') + ')';
|
|
document.documentElement.style.setProperty('--background', themeBg);
|
|
} else {
|
|
bg = themeBg;
|
|
}
|
|
loaderBg = bg;
|
|
}
|
|
} catch (e) { }
|
|
|
|
var publicBase = '%BASE_URL%';
|
|
if (publicBase && publicBase.charAt(publicBase.length - 1) !== '/') {
|
|
publicBase += '/';
|
|
}
|
|
|
|
document.documentElement.style.background = bg;
|
|
document.documentElement.style.setProperty('--loader-bg', loaderBg);
|
|
|
|
if (isLight) {
|
|
document.documentElement.style.setProperty('--loader-logo-url', 'url(' + JSON.stringify(publicBase + 'brand/logos/app-light.png') + ')');
|
|
document.documentElement.style.setProperty('--loader-text', '#0f172a');
|
|
document.documentElement.style.setProperty('--loader-text-dim', '#64748b');
|
|
document.documentElement.style.setProperty('--loader-surface', '#f8fafc');
|
|
|
|
// Light Mode Glass
|
|
document.documentElement.style.setProperty('--loader-glass-bg', 'linear-gradient(135deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.3) 100%)');
|
|
document.documentElement.style.setProperty('--loader-glass-border', 'rgba(255, 255, 255, 0.9)');
|
|
document.documentElement.style.setProperty('--loader-glass-shadow', 'rgba(139, 92, 246, 0.06)');
|
|
document.documentElement.style.setProperty('--loader-orbit-color', 'rgba(139, 92, 246, 0.1)');
|
|
document.documentElement.style.setProperty('--loader-inner-glow', 'rgba(99, 102, 241, 0.25)');
|
|
document.documentElement.style.setProperty('--loader-aura-1', '#c084fc');
|
|
document.documentElement.style.setProperty('--loader-aura-2', '#818cf8');
|
|
document.documentElement.style.setProperty('--loader-aura-opacity', '0.25');
|
|
|
|
if (!document.documentElement.style.getPropertyValue('--background')) {
|
|
document.documentElement.style.setProperty('--background', '255 255 255');
|
|
}
|
|
document.documentElement.style.setProperty('--surface', '241 243 245');
|
|
document.documentElement.style.setProperty('--border', '222 226 230');
|
|
document.documentElement.setAttribute('data-theme', 'light');
|
|
} else {
|
|
document.documentElement.style.setProperty('--loader-logo-url', 'url(' + JSON.stringify(publicBase + 'brand/logos/app.png') + ')');
|
|
document.documentElement.style.setProperty('--loader-glass-bg', 'rgba(255, 255, 255, 0.03)');
|
|
document.documentElement.style.setProperty('--loader-glass-border', 'rgba(255, 255, 255, 0.08)');
|
|
document.documentElement.style.setProperty('--loader-glass-shadow', 'rgba(0, 0, 0, 0.3)');
|
|
document.documentElement.style.setProperty('--loader-orbit-color', 'rgba(255, 255, 255, 0.04)');
|
|
document.documentElement.style.setProperty('--loader-inner-glow', 'rgba(139, 92, 246, 0.15)');
|
|
document.documentElement.style.setProperty('--loader-aura-1', '#8b5cf6');
|
|
document.documentElement.style.setProperty('--loader-aura-2', '#3b82f6');
|
|
document.documentElement.style.setProperty('--loader-aura-opacity', '0.08');
|
|
document.documentElement.setAttribute('data-theme', 'dark');
|
|
}
|
|
})();
|
|
</script>
|
|
|
|
<!-- 关键 CSS 内联 -->
|
|
<style>
|
|
:root {
|
|
--loader-bg: #121215;
|
|
--loader-accent: #8b5cf6;
|
|
--loader-text: #fafafa;
|
|
--loader-text-dim: #71717a;
|
|
--loader-surface: #18181b;
|
|
--loader-logo-url: url("/brand/logos/app.png");
|
|
}
|
|
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
html,
|
|
body {
|
|
height: 100%;
|
|
background: var(--loader-bg);
|
|
overflow: hidden;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
}
|
|
|
|
#root {
|
|
opacity: 0;
|
|
pointer-events: none;
|
|
}
|
|
|
|
#root.ready {
|
|
opacity: 1;
|
|
pointer-events: auto;
|
|
transition: opacity 0.3s ease-out;
|
|
}
|
|
|
|
#initial-loader {
|
|
position: fixed;
|
|
inset: 0;
|
|
background: var(--loader-bg);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
z-index: 9999;
|
|
background-image: radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
|
|
}
|
|
|
|
#initial-loader.fade-out {
|
|
opacity: 0;
|
|
pointer-events: none;
|
|
transition: opacity 0.4s ease-out, transform 0.4s ease-out;
|
|
transform: scale(1.02);
|
|
}
|
|
|
|
.loader-content {
|
|
position: relative;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
animation: reveal 0.6s cubic-bezier(0.16, 1, 0.3, 1);
|
|
z-index: 10;
|
|
}
|
|
|
|
/* Background Glow via Blur to prevent banding */
|
|
.loader-bg-glow {
|
|
position: absolute;
|
|
filter: blur(140px);
|
|
pointer-events: none;
|
|
z-index: 0;
|
|
border-radius: 50%;
|
|
opacity: var(--loader-aura-opacity);
|
|
}
|
|
|
|
.loader-bg-glow-1 {
|
|
top: -20vh;
|
|
left: 10vw;
|
|
width: 60vw;
|
|
height: 70vh;
|
|
background: var(--loader-aura-1);
|
|
}
|
|
|
|
.loader-bg-glow-2 {
|
|
top: 10vh;
|
|
right: -10vw;
|
|
width: 50vw;
|
|
height: 60vh;
|
|
background: var(--loader-aura-2);
|
|
}
|
|
|
|
.loader-content {
|
|
position: relative;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
animation: reveal 0.6s cubic-bezier(0.16, 1, 0.3, 1);
|
|
z-index: 10;
|
|
}
|
|
|
|
/* Logo & Orbits Container */
|
|
.loader-logo-section {
|
|
position: relative;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
margin-bottom: 32px;
|
|
width: 240px;
|
|
height: 240px;
|
|
}
|
|
|
|
.loader-orbits-wrapper {
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
width: 800px;
|
|
height: 400px;
|
|
pointer-events: none;
|
|
z-index: 0;
|
|
}
|
|
|
|
.orbit {
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
border: 1px solid var(--loader-orbit-color);
|
|
border-radius: 50%;
|
|
}
|
|
|
|
.orbit-1 {
|
|
width: 600px;
|
|
height: 180px;
|
|
transform: translate(-50%, -50%) rotate(-12deg);
|
|
}
|
|
|
|
.orbit-2 {
|
|
width: 500px;
|
|
height: 260px;
|
|
transform: translate(-50%, -50%) rotate(18deg);
|
|
}
|
|
|
|
.orbit-dot {
|
|
position: absolute;
|
|
background: var(--loader-accent);
|
|
border-radius: 50%;
|
|
box-shadow: 0 0 12px 2px var(--loader-accent);
|
|
}
|
|
|
|
.dot-1 {
|
|
width: 8px;
|
|
height: 8px;
|
|
top: 18%;
|
|
left: 15%;
|
|
animation: pulse 2s infinite alternate;
|
|
}
|
|
|
|
.dot-2 {
|
|
width: 5px;
|
|
height: 5px;
|
|
bottom: 22%;
|
|
right: 20%;
|
|
opacity: 0.6;
|
|
animation: pulse 3s infinite alternate;
|
|
}
|
|
|
|
.orbit-star {
|
|
position: absolute;
|
|
top: 8%;
|
|
right: 30%;
|
|
color: var(--loader-accent);
|
|
font-size: 20px;
|
|
animation: pulse 2.5s infinite alternate;
|
|
}
|
|
|
|
/* Logo Glassmorphism */
|
|
.loader-logo-container {
|
|
position: relative;
|
|
width: 160px;
|
|
height: 160px;
|
|
z-index: 10;
|
|
}
|
|
|
|
.loader-logo-bg {
|
|
position: absolute;
|
|
inset: 0;
|
|
background: var(--loader-glass-bg);
|
|
backdrop-filter: blur(20px);
|
|
-webkit-backdrop-filter: blur(20px);
|
|
border-radius: 48px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
box-shadow:
|
|
inset 0 0 0 1px var(--loader-glass-border),
|
|
0 24px 48px var(--loader-glass-shadow);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.loader-inner-glow {
|
|
position: absolute;
|
|
inset: 20px;
|
|
background: var(--loader-inner-glow);
|
|
filter: blur(25px);
|
|
border-radius: 50%;
|
|
/* Animate opacity only: a blur() that also scales must be re-convolved
|
|
every frame, which is the single most expensive thing on this screen. */
|
|
animation: glow-pulse 3s infinite alternate;
|
|
will-change: opacity;
|
|
z-index: 1;
|
|
}
|
|
|
|
.loader-logo-icon {
|
|
position: relative;
|
|
width: 120px;
|
|
height: 120px;
|
|
background-image: var(--loader-logo-url);
|
|
background-position: center;
|
|
background-repeat: no-repeat;
|
|
background-size: contain;
|
|
filter: drop-shadow(0 8px 16px rgba(139, 92, 246, 0.2));
|
|
z-index: 2;
|
|
}
|
|
|
|
/* Typography */
|
|
.loader-title {
|
|
font-size: 48px;
|
|
font-weight: 800;
|
|
color: var(--loader-text);
|
|
margin-bottom: 12px;
|
|
letter-spacing: -0.5px;
|
|
z-index: 10;
|
|
}
|
|
|
|
.loader-subtitle {
|
|
font-size: 14px;
|
|
color: var(--loader-text-dim);
|
|
margin-bottom: 48px;
|
|
letter-spacing: 4px;
|
|
text-transform: uppercase;
|
|
font-weight: 600;
|
|
z-index: 10;
|
|
}
|
|
|
|
/* Progress Bar */
|
|
.loader-progress-container {
|
|
position: relative;
|
|
width: 480px;
|
|
height: 36px;
|
|
background: var(--loader-glass-bg);
|
|
backdrop-filter: blur(16px);
|
|
border: 1px solid var(--loader-glass-border);
|
|
border-radius: 18px;
|
|
padding: 4px;
|
|
display: flex;
|
|
align-items: center;
|
|
box-shadow: 0 12px 32px var(--loader-glass-shadow);
|
|
margin-bottom: 32px;
|
|
z-index: 10;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.loader-progress-bar {
|
|
height: 100%;
|
|
/* Full width, revealed via scaleX: animating width would relayout (and
|
|
repaint the gradient) on every one of the 150ms progress ticks. */
|
|
width: 100%;
|
|
transform: scaleX(0);
|
|
transform-origin: left center;
|
|
background: linear-gradient(90deg, #a5b4fc, #c084fc);
|
|
border-radius: 14px;
|
|
transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
|
will-change: transform;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.loader-progress-bar::after {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
width: 60px;
|
|
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7));
|
|
border-radius: 14px;
|
|
}
|
|
|
|
.loader-progress-text {
|
|
position: absolute;
|
|
right: 20px;
|
|
font-size: 13px;
|
|
font-weight: 700;
|
|
color: #6366f1;
|
|
z-index: 2;
|
|
}
|
|
|
|
/* Status Text */
|
|
.loader-status {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
font-size: 14px;
|
|
color: var(--loader-text);
|
|
font-weight: 500;
|
|
margin-bottom: 12px;
|
|
z-index: 10;
|
|
}
|
|
|
|
.loader-status-sub {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
font-size: 12px;
|
|
color: var(--loader-text-dim);
|
|
z-index: 10;
|
|
}
|
|
|
|
.loader-icon-spin {
|
|
animation: spin 1.5s linear infinite;
|
|
width: 14px;
|
|
height: 14px;
|
|
stroke: var(--loader-accent);
|
|
}
|
|
|
|
.loader-icon-diamond {
|
|
width: 10px;
|
|
height: 10px;
|
|
fill: currentColor;
|
|
}
|
|
|
|
@keyframes reveal {
|
|
from {
|
|
opacity: 0;
|
|
transform: translateY(10px) scale(0.98);
|
|
}
|
|
|
|
to {
|
|
opacity: 1;
|
|
transform: translateY(0) scale(1);
|
|
}
|
|
}
|
|
|
|
@keyframes pulse {
|
|
|
|
0%,
|
|
100% {
|
|
opacity: 0.4;
|
|
transform: scale(0.95);
|
|
}
|
|
|
|
50% {
|
|
opacity: 1;
|
|
transform: scale(1.05);
|
|
}
|
|
}
|
|
|
|
/* Opacity-only variant for blurred elements, where animating transform
|
|
would force the blur to be recomputed on every frame. */
|
|
@keyframes glow-pulse {
|
|
|
|
0%,
|
|
100% {
|
|
opacity: 0.4;
|
|
}
|
|
|
|
50% {
|
|
opacity: 1;
|
|
}
|
|
}
|
|
|
|
@keyframes spin {
|
|
to {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="initial-loader">
|
|
<div class="loader-bg-glow loader-bg-glow-1"></div>
|
|
<div class="loader-bg-glow loader-bg-glow-2"></div>
|
|
<div class="loader-content">
|
|
<div class="loader-logo-section">
|
|
<div class="loader-orbits-wrapper">
|
|
<div class="orbit orbit-1"></div>
|
|
<div class="orbit orbit-2"></div>
|
|
<div class="orbit-dot dot-1"></div>
|
|
<div class="orbit-dot dot-2"></div>
|
|
<div class="orbit-star">✦</div>
|
|
</div>
|
|
|
|
<div class="loader-logo-container">
|
|
<div class="loader-logo-bg">
|
|
<div class="loader-inner-glow"></div>
|
|
<div class="loader-logo-icon" role="img" aria-label="Adnify"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="loader-title">Adnify</div>
|
|
<div class="loader-subtitle">Next-Gen AI Editor</div>
|
|
|
|
<div class="loader-progress-container">
|
|
<div class="loader-progress-bar" id="loader-bar"></div>
|
|
<div class="loader-progress-text" id="loader-text">0%</div>
|
|
</div>
|
|
|
|
<div class="loader-status">
|
|
<svg class="loader-icon-spin" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
|
|
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
|
|
</svg>
|
|
<span data-splash-key="splash.initializing" data-splash-zh="正在初始化 AI 引擎...">Starting the AI engine...</span>
|
|
</div>
|
|
<div class="loader-status-sub">
|
|
<svg class="loader-icon-diamond" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
<path d="M12 2L22 12L12 22L2 12L12 2Z"></path>
|
|
</svg>
|
|
<span data-splash-key="splash.initializingSub" data-splash-zh="正在启动核心服务与通信通道">Bringing up core services and IPC channels</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="root"></div>
|
|
|
|
<script>
|
|
// 首帧闪屏文案。
|
|
//
|
|
// 真正的语言设置在 electron-store 里,只能异步读到,而这一屏在那之前就已经渲染了。
|
|
// 默认语言是 en,所以标签里写的是英文;上次启动缓存到 localStorage 的语言是 zh 时,
|
|
// 在首次绘制前把这两句换成中文。之后每个阶段的文案都由 useAppInit 走 locale 表更新,
|
|
// `data-splash-key` 让 i18n 测试能校验这里的兜底文案和 locale 表没有走样。
|
|
(function () {
|
|
try {
|
|
if (localStorage.getItem('adnify-language') !== 'zh') return;
|
|
var nodes = document.querySelectorAll('#initial-loader [data-splash-zh]');
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
nodes[i].textContent = nodes[i].getAttribute('data-splash-zh');
|
|
}
|
|
} catch (e) {
|
|
// localStorage 不可用:留着英文默认值,别让闪屏挡住启动
|
|
}
|
|
})();
|
|
</script>
|
|
|
|
<script>
|
|
// 模拟真实的进度条加载动效
|
|
(function () {
|
|
var progress = 0;
|
|
var bar = document.getElementById('loader-bar');
|
|
var text = document.getElementById('loader-text');
|
|
var loader = document.getElementById('initial-loader');
|
|
|
|
var interval = setInterval(function () {
|
|
// 进度算法:越来越慢,卡在 99%
|
|
var remaining = 99 - progress;
|
|
var increment = Math.max(1, Math.floor(remaining * 0.15));
|
|
progress += increment;
|
|
|
|
if (bar && text) {
|
|
bar.style.transform = 'scaleX(' + (progress / 100) + ')';
|
|
text.innerText = progress + '%';
|
|
}
|
|
|
|
if (progress >= 99) {
|
|
clearInterval(interval);
|
|
}
|
|
}, 150);
|
|
|
|
// 暴露给外部应用:当应用加载完成后调用
|
|
window.completeLoading = function () {
|
|
clearInterval(interval);
|
|
if (bar && text) {
|
|
bar.style.transform = 'scaleX(1)';
|
|
text.innerText = '100%';
|
|
}
|
|
setTimeout(function () {
|
|
if (loader) loader.classList.add('fade-out');
|
|
var root = document.getElementById('root');
|
|
if (root) root.classList.add('ready');
|
|
}, 300); // 留一点时间看完 100%
|
|
};
|
|
})();
|
|
</script>
|
|
<script type="module" src="/src/renderer/main.tsx"></script>
|
|
</body>
|
|
|
|
</html>
|