fix: force default light mode for public pages and admin

- Set defaultColorScheme='light' in root MantineProvider
- Change darkModeStore default from system preference to false (light)
- Add MantineProvider with light theme to darmasaba/layout.tsx
- Remove dark mode dependency from ModuleView component
- Prevent system color scheme from affecting initial page load

This ensures consistent light mode on first visit for both
public pages and admin panel, regardless of OS settings.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
2026-02-25 10:45:27 +08:00
parent fd63bb0fd4
commit b86a3a85c3
4 changed files with 35 additions and 30 deletions

View File

@@ -21,17 +21,18 @@ import { proxy, useSnapshot } from 'valtio';
const STORAGE_KEY = 'darmasaba-admin-dark-mode';
// Initialize from localStorage or system preference
// Initialize from localStorage or default to light mode
const getInitialDarkMode = (): boolean => {
if (typeof window === 'undefined') return false;
const stored = localStorage.getItem(STORAGE_KEY);
if (stored !== null) {
return stored === 'true';
}
// Fallback to system preference
return window.matchMedia('(prefers-color-scheme: dark)').matches;
// Default to light mode for first-time users
// System preference is NOT used as default to ensure consistent UX
return false;
};
class DarkModeStore {