Repository navigation
chore(Layout): prevent first-paint theme flash and remove unused layouts #8915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,15 @@ | |
| <html lang="en" data-bs-theme='light'> | ||
|
|
||
| <head> | ||
| <script> | ||
| (() => { | ||
| const theme = localStorage.getItem('theme') ?? 'auto'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Concurrent theme change flashes stale theme When another tab changes the saved theme after the inline script reads it but before Reconcile cross-tab theme changes during initialization, for example by handling the |
||
| const activeTheme = theme === 'auto' | ||
| ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') | ||
| : theme; | ||
| document.documentElement.setAttribute('data-bs-theme', activeTheme); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ Low · Theme startup bypasses JSInterop When the sample site's App document is loaded, the inline script calls Route the theme DOM update through JSInterop instead of calling From - 不直接操作 DOM(用 JSInterop) |
||
| })(); | ||
| </script> | ||
| <meta charset="utf-8" /> | ||
| <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
|
|
||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| @page "/error" | ||
| @layout ErrorLayout | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Error page repeats layout failure When the exception handler routes to Restore |
||
|
|
||
| <h1 class="text-danger">Error.</h1> | ||
| <h2 class="text-danger">An error occurred while processing your request.</h2> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium · Dark system preference is ignored
When the browser blocks access to local storage,
localStorage.getItem('theme')throws before the IIFE checksprefers-color-scheme, leaving the document's hard-coded light theme in place even when the system prefers dark.Catch local-storage access errors and use the system preference when no saved theme can be read.