mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-09-04 07:39:46 +08:00
44 lines
1.0 KiB
JavaScript
44 lines
1.0 KiB
JavaScript
import Cookies from 'js-cookie';
|
|
|
|
const app = {
|
|
state: {
|
|
sidebar: {
|
|
opened: !+Cookies.get('sidebarStatus')
|
|
},
|
|
theme: 'default',
|
|
livenewsChannels: Cookies.get('livenewsChannels') || '[]',
|
|
visitedViews: []
|
|
},
|
|
mutations: {
|
|
TOGGLE_SIDEBAR: state => {
|
|
if (state.sidebar.opened) {
|
|
Cookies.set('sidebarStatus', 1);
|
|
} else {
|
|
Cookies.set('sidebarStatus', 0);
|
|
}
|
|
state.sidebar.opened = !state.sidebar.opened;
|
|
},
|
|
ADD_VISITED_VIEWS: (state, view) => {
|
|
if (state.visitedViews.includes(view)) return
|
|
state.visitedViews.push(view)
|
|
},
|
|
DEL_VISITED_VIEWS: (state, view) => {
|
|
const index = state.visitedViews.indexOf(view)
|
|
state.visitedViews.splice(index, 1)
|
|
}
|
|
},
|
|
actions: {
|
|
ToggleSideBar: ({ commit }) => {
|
|
commit('TOGGLE_SIDEBAR')
|
|
},
|
|
addVisitedViews: ({ commit }, view) => {
|
|
commit('ADD_VISITED_VIEWS', view)
|
|
},
|
|
delVisitedViews: ({ commit }, view) => {
|
|
commit('DEL_VISITED_VIEWS', view)
|
|
}
|
|
}
|
|
};
|
|
|
|
export default app;
|