refactor: migrate from Vuex to Pinia
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useSidebarStore = defineStore('sidebar', () => {
|
||||
const visible = ref(undefined)
|
||||
const unfoldable = ref(false)
|
||||
|
||||
const toggleVisible = (value) => {
|
||||
visible.value = value !== undefined ? value : !visible.value
|
||||
}
|
||||
|
||||
const toggleUnfoldable = () => {
|
||||
unfoldable.value = !unfoldable.value
|
||||
}
|
||||
|
||||
return { visible, unfoldable, toggleVisible, toggleUnfoldable }
|
||||
})
|
||||
@@ -0,0 +1,12 @@
|
||||
import { ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useThemeStore = defineStore('theme', () => {
|
||||
const theme = ref('light')
|
||||
|
||||
const toggleTheme = (_theme) => {
|
||||
theme.value = _theme
|
||||
}
|
||||
|
||||
return { theme, toggleTheme }
|
||||
})
|
||||
Reference in New Issue
Block a user