refac
This commit is contained in:
@@ -714,6 +714,25 @@
|
||||
await goto(`/?q=${encodeURIComponent(event.data.query)}`);
|
||||
return;
|
||||
}
|
||||
if (event.type === 'theme:update' && event.data?.theme) {
|
||||
const newTheme = event.data.theme;
|
||||
localStorage.setItem('theme', newTheme);
|
||||
theme.set(newTheme);
|
||||
|
||||
// Apply theme classes (mirrors logic from chat/Settings/General.svelte)
|
||||
const themes = ['dark', 'light', 'oled-dark'];
|
||||
let themeToApply = newTheme === 'oled-dark' ? 'dark' : newTheme === 'her' ? 'light' : newTheme;
|
||||
if (newTheme === 'system') {
|
||||
themeToApply = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||
}
|
||||
themes
|
||||
.filter((e) => e !== themeToApply)
|
||||
.forEach((e) => {
|
||||
e.split(' ').forEach((cls) => document.documentElement.classList.remove(cls));
|
||||
});
|
||||
themeToApply.split(' ').forEach((cls) => document.documentElement.classList.add(cls));
|
||||
return;
|
||||
}
|
||||
if (event.type === 'models:refresh') {
|
||||
const token = localStorage.token;
|
||||
if (token) {
|
||||
|
||||
Reference in New Issue
Block a user