|
|
@@ -4,6 +4,7 @@ import objectPath from "object-path"
|
|
|
import type LayoutConfigTypes from "@/core/config/LayoutConfigTypes"
|
|
|
import layoutConfig from "@/core/config/DefaultLayoutConfig"
|
|
|
import { ThemeModeComponent } from "@/assets/ts/layout"
|
|
|
+import storages from "@/core/utils/storages"
|
|
|
|
|
|
export const LS_CONFIG_NAME_KEY = "config_" + import.meta.env.VITE_APP_NAME
|
|
|
|
|
|
@@ -21,7 +22,7 @@ export const useBodyConfigStore = defineStore("body", () => {
|
|
|
|
|
|
function setLayoutConfigProperty(property: string, value: any) {
|
|
|
objectPath.set(config.value, property, value)
|
|
|
- localStorage.setItem(LS_CONFIG_NAME_KEY, JSON.stringify(config.value))
|
|
|
+ storages.setItem(LS_CONFIG_NAME_KEY, JSON.stringify(config.value))
|
|
|
}
|
|
|
|
|
|
function resetLayoutConfig() {
|
|
|
@@ -32,7 +33,7 @@ export const useBodyConfigStore = defineStore("body", () => {
|
|
|
config.value = initial.value = Object.assign(
|
|
|
{},
|
|
|
initial.value,
|
|
|
- JSON.parse(window.localStorage.getItem(LS_CONFIG_NAME_KEY) || "{}")
|
|
|
+ JSON.parse(storages.getItem(LS_CONFIG_NAME_KEY) || "{}")
|
|
|
)
|
|
|
}
|
|
|
|
|
|
@@ -66,19 +67,22 @@ export const useBodyConfigStore = defineStore("body", () => {
|
|
|
classes.value[position].push(className)
|
|
|
}
|
|
|
}
|
|
|
- const mode = ref<"light" | "dark" | "system">(
|
|
|
- localStorage.getItem(THEME_MODE_LS_KEY)
|
|
|
- ? (localStorage.getItem(THEME_MODE_LS_KEY) as "light" | "dark" | "system")
|
|
|
+ const mode = ref<"light" | "dark" | "system" | "green">(
|
|
|
+ storages.getItem(THEME_MODE_LS_KEY)
|
|
|
+ ? (storages.getItem(THEME_MODE_LS_KEY) as "light" | "dark" | "system" | "green")
|
|
|
: ThemeModeComponent.getSystemMode()
|
|
|
)
|
|
|
|
|
|
- function setThemeMode(payload: "light" | "dark" | "system") {
|
|
|
- localStorage.setItem(THEME_MODE_LS_KEY, payload)
|
|
|
- localStorage.setItem(THEME_MENU_MODE_LS_KEY, payload)
|
|
|
+ function setThemeMode(payload: "light" | "dark" | "system" | "green") {
|
|
|
+ storages.setItem(THEME_MODE_LS_KEY, payload)
|
|
|
+ storages.setItem(THEME_MENU_MODE_LS_KEY, payload)
|
|
|
document.documentElement.setAttribute("data-bs-theme", payload)
|
|
|
ThemeModeComponent.init()
|
|
|
mode.value = payload
|
|
|
}
|
|
|
+ function clearThemeMode() {
|
|
|
+ storages.removeItem(LS_CONFIG_NAME_KEY)
|
|
|
+ }
|
|
|
|
|
|
return {
|
|
|
config,
|
|
|
@@ -94,5 +98,6 @@ export const useBodyConfigStore = defineStore("body", () => {
|
|
|
addClassname,
|
|
|
themeMode: mode,
|
|
|
setThemeMode,
|
|
|
+ clearThemeMode,
|
|
|
}
|
|
|
})
|