clash-verge-rev/src/pages/_layout/utils/initial-loading-overlay.ts
Tunglies ec82b69786
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.)
2026-04-06 01:53:40 +08:00

18 lines
380 B
TypeScript

let removed = false
export const hideInitialOverlay = (): number | undefined => {
if (removed) return undefined
const overlay = document.getElementById('initial-loading-overlay')
if (!overlay) {
removed = true
return undefined
}
removed = true
overlay.dataset.hidden = 'true'
const timer = window.setTimeout(() => overlay.remove(), 200)
return timer
}