mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-04-06 03:57:53 +08:00
35 lines
735 B
JavaScript
35 lines
735 B
JavaScript
import Cookies from 'js-cookie'
|
|
|
|
const app = {
|
|
state: {
|
|
sidebar: {
|
|
opened: !+Cookies.get('sidebarStatus')
|
|
},
|
|
language: Cookies.get('language') || 'en'
|
|
},
|
|
mutations: {
|
|
TOGGLE_SIDEBAR: state => {
|
|
if (state.sidebar.opened) {
|
|
Cookies.set('sidebarStatus', 1)
|
|
} else {
|
|
Cookies.set('sidebarStatus', 0)
|
|
}
|
|
state.sidebar.opened = !state.sidebar.opened
|
|
},
|
|
SET_LANGUAGE: (state, language) => {
|
|
state.language = language
|
|
Cookies.set('language', language)
|
|
}
|
|
},
|
|
actions: {
|
|
toggleSideBar({ commit }) {
|
|
commit('TOGGLE_SIDEBAR')
|
|
},
|
|
setLanguage({ commit }, language) {
|
|
commit('SET_LANGUAGE', language)
|
|
}
|
|
}
|
|
}
|
|
|
|
export default app
|