add: global blur effect
This commit is contained in:
+10
-1
@@ -3,6 +3,7 @@ import { defineStore } from "pinia";
|
||||
|
||||
export const DEFAULT_BODY_BACKGROUND = "#FFF";
|
||||
const THEME_STORAGE_KEY = "gao-customer-h5:theme-mode";
|
||||
const BACKDROP_BLUR_STORAGE_KEY = "gao-customer-h5:backdrop-blur";
|
||||
|
||||
export type ThemeMode = "light" | "dark" | "system";
|
||||
|
||||
@@ -18,6 +19,7 @@ function readStoredThemeMode(): ThemeMode {
|
||||
const store = defineStore("globalUI", () => {
|
||||
const bodyBackground = ref<string>(DEFAULT_BODY_BACKGROUND);
|
||||
const themeMode = ref<ThemeMode>(readStoredThemeMode());
|
||||
const backdropBlur = ref(localStorage.getItem(BACKDROP_BLUR_STORAGE_KEY) !== "false");
|
||||
|
||||
function setBodyBackground(color?: string): void {
|
||||
bodyBackground.value = color || DEFAULT_BODY_BACKGROUND;
|
||||
@@ -28,11 +30,18 @@ const store = defineStore("globalUI", () => {
|
||||
localStorage.setItem(THEME_STORAGE_KEY, mode);
|
||||
}
|
||||
|
||||
function setBackdropBlur(enabled: boolean): void {
|
||||
backdropBlur.value = enabled;
|
||||
localStorage.setItem(BACKDROP_BLUR_STORAGE_KEY, String(enabled));
|
||||
}
|
||||
|
||||
return {
|
||||
bodyBackground,
|
||||
themeMode,
|
||||
backdropBlur,
|
||||
setBodyBackground,
|
||||
setThemeMode
|
||||
setThemeMode,
|
||||
setBackdropBlur
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user