mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-26 23:30:09 +08:00
refactor: eliminate startup flicker — defer window show until overlay renders
- Remove Rust-side `eval(INITIAL_LOADING_OVERLAY)` that prematurely dismissed the overlay before React/MUI theme was ready - Defer `window.show()` from Rust `activate_window` to an inline `<script>` in index.html, executed after the themed overlay is in DOM - Remove `useAppInitialization` hook (duplicate of `useLoadingOverlay` with no themeReady gate) - Simplify overlay to pure theme-colored background — no spinner or loading text — so fast startup feels instant - Simplify `hideInitialOverlay` API and reduce overlay fade to 0.2s - Clean up unused CSS variables (spinner-track, spinner-top, etc.)
This commit is contained in:
+16
-48
@@ -11,27 +11,15 @@
|
||||
<title>Clash Verge</title>
|
||||
<style>
|
||||
:root {
|
||||
--initial-bg: #f5f5f5;
|
||||
--initial-text: #333;
|
||||
--initial-spinner-track: #e3e3e3;
|
||||
--initial-spinner-top: #3498db;
|
||||
--bg-color: var(--initial-bg);
|
||||
--text-color: var(--initial-text);
|
||||
--spinner-track: var(--initial-spinner-track);
|
||||
--spinner-top: var(--initial-spinner-top);
|
||||
--bg-color: #f5f5f5;
|
||||
--text-color: #333;
|
||||
color-scheme: light;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--initial-bg: #2e303d;
|
||||
--initial-text: #ffffff;
|
||||
--initial-spinner-track: #3a3a3a;
|
||||
--initial-spinner-top: #0a84ff;
|
||||
--bg-color: var(--initial-bg);
|
||||
--text-color: var(--initial-text);
|
||||
--spinner-track: var(--initial-spinner-track);
|
||||
--spinner-top: var(--initial-spinner-top);
|
||||
--bg-color: #2e303d;
|
||||
--text-color: #ffffff;
|
||||
color-scheme: dark;
|
||||
}
|
||||
}
|
||||
@@ -53,48 +41,28 @@
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: var(--bg-color);
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 9999;
|
||||
font-family:
|
||||
-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
transition: opacity 0.3s ease;
|
||||
transition: opacity 0.2s ease-out;
|
||||
}
|
||||
|
||||
#initial-loading-overlay[data-hidden='true'] {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.initial-spinner {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border: 3px solid var(--spinner-track);
|
||||
border-top: 3px solid var(--spinner-top);
|
||||
border-radius: 50%;
|
||||
animation: initial-spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes initial-spin {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="initial-loading-overlay">
|
||||
<div class="initial-spinner"></div>
|
||||
<div style="font-size: 14px; opacity: 0.7; margin-top: 20px">
|
||||
Loading Clash Verge...
|
||||
</div>
|
||||
</div>
|
||||
<div id="initial-loading-overlay"></div>
|
||||
<script>
|
||||
if (window.__TAURI_INTERNALS__) {
|
||||
window.__TAURI_INTERNALS__
|
||||
.invoke('plugin:window|show', { label: 'main' })
|
||||
.catch(function () {});
|
||||
window.__TAURI_INTERNALS__
|
||||
.invoke('plugin:window|set_focus', { label: 'main' })
|
||||
.catch(function () {});
|
||||
}
|
||||
</script>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./main.tsx"></script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user