1
0
mirror of https://github.com/zclzone/vue-naive-admin.git synced 2026-04-26 04:04:08 +08:00
Files
vue-naive-admin/src/store/modules/app/index.js
2023-07-11 15:07:37 +08:00

29 lines
567 B
JavaScript

import { defineStore } from 'pinia'
import { useDark } from '@vueuse/core'
const isDark = useDark()
export const useAppStore = defineStore('app', {
state() {
return {
collapsed: false,
isDark,
}
},
actions: {
switchCollapsed() {
this.collapsed = !this.collapsed
},
setCollapsed(collapsed) {
this.collapsed = collapsed
},
/** 设置暗黑模式 */
setDark(isDark) {
this.isDark = isDark
},
/** 切换/关闭 暗黑模式 */
toggleDark() {
this.isDark = !this.isDark
},
},
})