perf: 代码优化 utils/cache
This commit is contained in:
parent
51916b6bc0
commit
bf29e0e52a
@ -1,5 +1,5 @@
|
|||||||
import { ref, watchEffect } from "vue"
|
import { ref, watchEffect } from "vue"
|
||||||
import { getActiveThemeName, setActiveThemeName } from "@/utils/cache/localStorage"
|
import { getActiveThemeName, setActiveThemeName } from "@/utils/cache/local-storage"
|
||||||
|
|
||||||
const DEFAULT_THEME_NAME = "normal"
|
const DEFAULT_THEME_NAME = "normal"
|
||||||
type DefaultThemeName = typeof DEFAULT_THEME_NAME
|
type DefaultThemeName = typeof DEFAULT_THEME_NAME
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { reactive, ref, watch } from "vue"
|
import { reactive, ref, watch } from "vue"
|
||||||
import { defineStore } from "pinia"
|
import { defineStore } from "pinia"
|
||||||
import { getSidebarStatus, setSidebarStatus } from "@/utils/cache/localStorage"
|
import { getSidebarStatus, setSidebarStatus } from "@/utils/cache/local-storage"
|
||||||
import { DeviceEnum, SIDEBAR_OPENED, SIDEBAR_CLOSED } from "@/constants/app-key"
|
import { DeviceEnum, SIDEBAR_OPENED, SIDEBAR_CLOSED } from "@/constants/app-key"
|
||||||
|
|
||||||
interface Sidebar {
|
interface Sidebar {
|
||||||
|
@ -12,7 +12,7 @@ export const setSidebarStatus = (sidebarStatus: SidebarOpened | SidebarClosed) =
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getActiveThemeName = () => {
|
export const getActiveThemeName = () => {
|
||||||
return localStorage.getItem(CacheKey.ACTIVE_THEME_NAME) as ThemeName
|
return localStorage.getItem(CacheKey.ACTIVE_THEME_NAME) as ThemeName | null
|
||||||
}
|
}
|
||||||
export const setActiveThemeName = (themeName: ThemeName) => {
|
export const setActiveThemeName = (themeName: ThemeName) => {
|
||||||
localStorage.setItem(CacheKey.ACTIVE_THEME_NAME, themeName)
|
localStorage.setItem(CacheKey.ACTIVE_THEME_NAME, themeName)
|
Loading…
x
Reference in New Issue
Block a user