fix(theme): apply per-user theme_pref on login, persist toggle to server
alpine-init.js resolved the theme purely from localStorage, so it never reflected the logged-in user's theme_pref: switching user kept the previous user's theme because localStorage persists per-browser. - base.html injects window.__SERVER_THEME from the session theme (empty when anonymous, preserving OS-preference behaviour on the login page). - alpine-init.js now treats the server value as authoritative for logged-in users (server > localStorage > OS > light) and syncs localStorage to it. - The navbar toggle now persists the choice via POST /auth/set-theme, which updates the session and the user's theme_pref, so it survives navigation and matches on the next login. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,9 @@
|
||||
<!-- Theme CSS Variables -->
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/themes.css') }}">
|
||||
|
||||
<!-- Authoritative per-user theme from the server session (empty when anonymous) -->
|
||||
<script>window.__SERVER_THEME = "{{ current_theme if current_user else '' }}";</script>
|
||||
|
||||
<!-- Alpine.js Theme Init (before Alpine loads) -->
|
||||
<script src="{{ url_for('static', filename='js/alpine-init.js') }}"></script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user