detect dark theme from browser
This commit is contained in:
parent
8a7ec2732d
commit
44e850dfa3
|
|
@ -1275,11 +1275,14 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
});
|
});
|
||||||
// Load theme
|
// Load theme
|
||||||
var _darktheme : boolean;
|
var _darktheme : boolean;
|
||||||
if (localStorage.getItem("cvm-dark-theme") === "0")
|
// Check if dark theme is set in local storage
|
||||||
loadColorTheme(false);
|
if (localStorage.getItem("cvm-dark-theme") !== null)
|
||||||
else
|
loadColorTheme(localStorage.getItem("cvm-dark-theme") === "1");
|
||||||
|
// Otherwise, try to detect the system theme
|
||||||
|
else if (window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||||
loadColorTheme(true);
|
loadColorTheme(true);
|
||||||
|
else
|
||||||
|
loadColorTheme(false);
|
||||||
// Initialize authentication if enabled
|
// Initialize authentication if enabled
|
||||||
if (Config.Auth.Enabled) {
|
if (Config.Auth.Enabled) {
|
||||||
auth = new AuthManager(Config.Auth.APIEndpoint);
|
auth = new AuthManager(Config.Auth.APIEndpoint);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user