This commit is contained in:
ct
2025-07-15 02:56:39 +08:00
parent d57c75d5d7
commit 31383349c2
8 changed files with 116 additions and 35 deletions

View File

@@ -1,21 +1,22 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" @class(['dark' => ($appearance ?? 'system') == 'dark'])>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{-- Inline script to detect system dark mode preference and apply it immediately --}}
{{-- Inline script to detect theme preference and apply it immediately to prevent flash --}}
<script>
(function() {
const appearance = '{{ $appearance ?? 'system' }}';
const savedTheme = sessionStorage.getItem('theme') || 'system';
if (appearance === 'system') {
if (savedTheme === 'system') {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
if (prefersDark) {
document.documentElement.classList.add('dark');
}
} else if (savedTheme === 'dark') {
document.documentElement.classList.add('dark');
}
})();
</script>