diff --git a/zero.Backoffice.UI/app/app.vue b/zero.Backoffice.UI/app/app.vue
index 258f9d15..43b612c8 100644
--- a/zero.Backoffice.UI/app/app.vue
+++ b/zero.Backoffice.UI/app/app.vue
@@ -46,6 +46,10 @@
this.accountStore.user = userResponse.data;
await useUiStore().setup();
}
+ else
+ {
+ await useUiStore().setup(true);
+ }
await useTranslationStore().setup();
diff --git a/zero.Backoffice.UI/app/modules/media/pages/overview/overview-item.vue b/zero.Backoffice.UI/app/modules/media/pages/overview/overview-item.vue
index a6323ba7..4c019de5 100644
--- a/zero.Backoffice.UI/app/modules/media/pages/overview/overview-item.vue
+++ b/zero.Backoffice.UI/app/modules/media/pages/overview/overview-item.vue
@@ -3,7 +3,7 @@
{{value.name}}
diff --git a/zero.Backoffice.UI/app/ui/app-navigation.vue b/zero.Backoffice.UI/app/ui/app-navigation.vue
index f0afbe9e..7a7fdf35 100644
--- a/zero.Backoffice.UI/app/ui/app-navigation.vue
+++ b/zero.Backoffice.UI/app/ui/app-navigation.vue
@@ -51,8 +51,8 @@
-
-
+
+
@@ -161,15 +161,6 @@
localStorage.setItem(compactCacheKey, this.compact.toString());
},
- toggleDarkTheme()
- {
- this.darkTheme = !this.darkTheme;
- EventHub.emit('app.theme', this.darkTheme ? 'dark' : 'light');
- localStorage.setItem(themeCacheKey, this.darkTheme ? 'dark' : 'light');
- document.body.classList.toggle('theme-light', !this.darkTheme);
- document.body.classList.toggle('theme-dark', this.darkTheme);
- },
-
openSearch()
{
//EventHub.$emit('app.search.open');
diff --git a/zero.Backoffice.UI/app/ui/app-overlays.vue b/zero.Backoffice.UI/app/ui/app-overlays.vue
index 27e84982..289e026c 100644
--- a/zero.Backoffice.UI/app/ui/app-overlays.vue
+++ b/zero.Backoffice.UI/app/ui/app-overlays.vue
@@ -50,11 +50,6 @@
});
},
- beforeDestroy()
- {
- this.$el.removeEventListener('keyup');
- },
-
methods: {
add(instance)
diff --git a/zero.Backoffice.UI/app/ui/store.ts b/zero.Backoffice.UI/app/ui/store.ts
index a328031b..dfa16fab 100644
--- a/zero.Backoffice.UI/app/ui/store.ts
+++ b/zero.Backoffice.UI/app/ui/store.ts
@@ -3,8 +3,14 @@ import { defineStore } from 'pinia';
import { UiFlavorProvider, UiIconSet, UiSection, UiSettingsGroup, UiStoreState } from 'zero/ui';
import api from './api';
+const THEME_KEY = 'zero.theme';
+
export const useUiStore = defineStore('zero.ui', {
state: () => ({
+ preferences: {
+ theme: 'dark'
+ },
+
sections: [],
settingGroups: [],
iconSets: [],
@@ -13,8 +19,15 @@ export const useUiStore = defineStore('zero.ui', {
} as UiStoreState),
actions: {
- async setup()
+ async setup(anonymous)
{
+ this.setTheme(localStorage.getItem(THEME_KEY) || 'default');
+
+ if (anonymous)
+ {
+ return;
+ }
+
const values = await Promise.all([
api.getSections(),
api.getSettingGroups(),
@@ -28,6 +41,16 @@ export const useUiStore = defineStore('zero.ui', {
this.iconSets = values[2].data as UiIconSet[];
this.flavors = values[3].data as Record;
this.blueprints = values[4].data as string[];
+ },
+
+ setTheme(theme: 'default' | 'light' | 'dark')
+ {
+ const dark = theme === 'dark';
+ this.preferences.theme = theme;
+ localStorage.setItem(THEME_KEY, theme);
+
+ document.body.classList.toggle('theme-light', !dark);
+ document.body.classList.toggle('theme-dark', dark);
}
}
});
\ No newline at end of file
diff --git a/zero.Backoffice.UI/app/ui/ui.d.ts b/zero.Backoffice.UI/app/ui/ui.d.ts
index 0ee54dae..9a40158f 100644
--- a/zero.Backoffice.UI/app/ui/ui.d.ts
+++ b/zero.Backoffice.UI/app/ui/ui.d.ts
@@ -3,6 +3,8 @@ declare module 'zero/ui'
{
export interface UiStoreState
{
+ preferences: UiPreferences;
+
sections: UiSection[];
settingGroups: UiSettingsGroup[];
iconSets: UiIconSet[];
@@ -10,6 +12,11 @@ declare module 'zero/ui'
blueprints: string[];
}
+ export interface UiPreferences
+ {
+ theme: 'default' | 'dark' | 'light';
+ }
+
export interface UiSection
{
alias: string;