import Cookies from 'js-cookie' import { getLanguage } from '@/lang/index' const state = { sidebar: { opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true, withoutAnimation: false, activeIndex: '' }, device: 'desktop', language: getLanguage(), size: Cookies.get('size') || 'medium', navbar: { activeIndex: '' // 导航目前是第几个 个人中心需要 }, logo: '', isLoading:null } const mutations = { TOGGLE_SIDEBAR: state => { state.sidebar.opened = !state.sidebar.opened state.sidebar.withoutAnimation = false if (state.sidebar.opened) { Cookies.set('sidebarStatus', 1) } else { Cookies.set('sidebarStatus', 0) } }, CLOSE_SIDEBAR: (state, withoutAnimation) => { Cookies.set('sidebarStatus', 0) state.sidebar.opened = false state.sidebar.withoutAnimation = withoutAnimation }, TOGGLE_DEVICE: (state, device) => { state.device = device }, SET_LANGUAGE: (state, language) => { state.language = language Cookies.set('language', language) }, SET_SIZE: (state, size) => { state.size = size Cookies.set('size', size) }, SET_ACTIVEINDEX: (state, path) => { state.sidebar.activeIndex = path }, SET_NAVACTIVEINDEX: (state, path) => { state.navbar.activeIndex = path }, } const actions = { toggleSideBar({ commit }) { commit('TOGGLE_SIDEBAR') }, closeSideBar({ commit }, { withoutAnimation }) { commit('CLOSE_SIDEBAR', withoutAnimation) }, toggleDevice({ commit }, device) { commit('TOGGLE_DEVICE', device) }, setLanguage({ commit }, language) { commit('SET_LANGUAGE', language) }, setSize({ commit }, size) { commit('SET_SIZE', size) } } // const app = { // // namespaced: true, // state: { // sidebar: { // opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true, // withoutAnimation: false, // activeIndex: '' // }, // device: 'desktop', // language: getLanguage(), // size: Cookies.get('size') || 'medium', // navbar: { // activeIndex: '' // 导航目前是第几个 个人中心需要 // }, // logo: '', // isLoading:null // }, // mutations: { // TOGGLE_SIDEBAR: state => { // state.sidebar.opened = !state.sidebar.opened // state.sidebar.withoutAnimation = false // if (state.sidebar.opened) { // Cookies.set('sidebarStatus', 1) // } else { // Cookies.set('sidebarStatus', 0) // } // }, // CLOSE_SIDEBAR: (state, withoutAnimation) => { // Cookies.set('sidebarStatus', 0) // state.sidebar.opened = false // state.sidebar.withoutAnimation = withoutAnimation // }, // TOGGLE_DEVICE: (state, device) => { // state.device = device // }, // SET_LANGUAGE: (state, language) => { // state.language = language // Cookies.set('language', language) // }, // SET_SIZE: (state, size) => { // state.size = size // Cookies.set('size', size) // }, // SET_ACTIVEINDEX: (state, path) => { // state.sidebar.activeIndex = path // }, // SET_NAVACTIVEINDEX: (state, path) => { // state.navbar.activeIndex = path // }, // setLoading(state, isLoading) { // // console.log(isLoading); // state.isLoading = isLoading; // } // }, // actions: { // toggleSideBar({ commit }) { // commit('TOGGLE_SIDEBAR') // }, // closeSideBar({ commit }, { withoutAnimation }) { // commit('CLOSE_SIDEBAR', withoutAnimation) // }, // toggleDevice({ commit }, device) { // commit('TOGGLE_DEVICE', device) // }, // setLanguage({ commit }, language) { // commit('SET_LANGUAGE', language) // }, // setSize({ commit }, size) { // commit('SET_SIZE', size) // }, // onLoading(state, isLoading) { // state.commit('setLoading', isLoading); // } // } // } export default { namespaced: true, state, mutations, actions } //export default app // import Cookies from 'js-cookie' // import { getLanguage } from '@/lang/index' // const state = { // sidebar: { // opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true, // withoutAnimation: false, // activeIndex: '' // }, // device: 'desktop', // language: getLanguage(), // size: Cookies.get('size') || 'medium', // navbar: { // activeIndex: '' // 导航目前是第几个 个人中心需要 // }, // logo: '', // isLoading:null // } // const mutations = { // TOGGLE_SIDEBAR: state => { // state.sidebar.opened = !state.sidebar.opened // state.sidebar.withoutAnimation = false // if (state.sidebar.opened) { // Cookies.set('sidebarStatus', 1) // } else { // Cookies.set('sidebarStatus', 0) // } // }, // CLOSE_SIDEBAR: (state, withoutAnimation) => { // Cookies.set('sidebarStatus', 0) // state.sidebar.opened = false // state.sidebar.withoutAnimation = withoutAnimation // }, // TOGGLE_DEVICE: (state, device) => { // state.device = device // }, // SET_LANGUAGE: (state, language) => { // state.language = language // Cookies.set('language', language) // }, // SET_SIZE: (state, size) => { // state.size = size // Cookies.set('size', size) // }, // SET_ACTIVEINDEX: (state, path) => { // state.sidebar.activeIndex = path // }, // SET_NAVACTIVEINDEX: (state, path) => { // state.navbar.activeIndex = path // }, // } // const actions = { // toggleSideBar({ commit }) { // commit('TOGGLE_SIDEBAR') // }, // closeSideBar({ commit }, { withoutAnimation }) { // commit('CLOSE_SIDEBAR', withoutAnimation) // }, // toggleDevice({ commit }, device) { // commit('TOGGLE_DEVICE', device) // }, // setLanguage({ commit }, language) { // commit('SET_LANGUAGE', language) // }, // setSize({ commit }, size) { // commit('SET_SIZE', size) // } // } // const app = { // // namespaced: true, // state: { // sidebar: { // opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true, // withoutAnimation: false, // activeIndex: '' // }, // device: 'desktop', // language: getLanguage(), // size: Cookies.get('size') || 'medium', // navbar: { // activeIndex: '' // 导航目前是第几个 个人中心需要 // }, // logo: '', // isLoading:null // }, // mutations: { // TOGGLE_SIDEBAR: state => { // state.sidebar.opened = !state.sidebar.opened // state.sidebar.withoutAnimation = false // if (state.sidebar.opened) { // Cookies.set('sidebarStatus', 1) // } else { // Cookies.set('sidebarStatus', 0) // } // }, // CLOSE_SIDEBAR: (state, withoutAnimation) => { // Cookies.set('sidebarStatus', 0) // state.sidebar.opened = false // state.sidebar.withoutAnimation = withoutAnimation // }, // TOGGLE_DEVICE: (state, device) => { // state.device = device // }, // SET_LANGUAGE: (state, language) => { // state.language = language // Cookies.set('language', language) // }, // SET_SIZE: (state, size) => { // state.size = size // Cookies.set('size', size) // }, // SET_ACTIVEINDEX: (state, path) => { // state.sidebar.activeIndex = path // }, // SET_NAVACTIVEINDEX: (state, path) => { // state.navbar.activeIndex = path // }, // setLoading(state, isLoading) { // // console.log(isLoading); // state.isLoading = isLoading; // } // }, // actions: { // toggleSideBar({ commit }) { // commit('TOGGLE_SIDEBAR') // }, // closeSideBar({ commit }, { withoutAnimation }) { // commit('CLOSE_SIDEBAR', withoutAnimation) // }, // toggleDevice({ commit }, device) { // commit('TOGGLE_DEVICE', device) // }, // setLanguage({ commit }, language) { // commit('SET_LANGUAGE', language) // }, // setSize({ commit }, size) { // commit('SET_SIZE', size) // }, // onLoading(state, isLoading) { // state.commit('setLoading', isLoading); // } // } // } // // export default { // // namespaced: true, // // state, // // mutations, // // actions // // } // export default app