import Cookie from 'js-cookie'
|
import { getUseridtree } from '../api/userAuthority'
|
import msgApi from '@/api/messages'
|
// import config from '../app.config.js'
|
export default {
|
updateMainContainerHeight: ({ commit }, height) => (commit('getMainContainerHeight', height)),
|
pushRouterHistory({ commit, state }, route) {
|
const arr = state.routerHistory.filter((v) => {
|
return v.id === route.id
|
})
|
if (!arr.length) {
|
commit('setRouterHistory', [...state.routerHistory, ...[route]])
|
}
|
},
|
removeRoute({ commit, state }, routeName) {
|
const h = state.routerHistory.filter((v) => {
|
return v.url !== routeName
|
})
|
commit('setRouterHistory', h)
|
},
|
// 获取用户信息
|
getInfo({ commit, state }, user) {
|
commit('setUserInfo', user)
|
},
|
//获取消息站数量
|
getNoReadMsgCount({ commit, state }) {
|
return new Promise((resolve, reject) => {
|
msgApi.getUnreadMsgCount().then((res) => {
|
if (res.code === '0') {
|
commit('setNoReadMsgCount', res.data ? res.data : 0)
|
}
|
resolve()
|
}).catch(error => {
|
reject(error)
|
})
|
})
|
},
|
getUserTree({ commit, state }) {
|
return new Promise((resolve, reject) => {
|
getUseridtree().then((res) => {
|
if (res.data && res.data.length) {
|
Cookie.set("isMenuAuth", true, { expires: 0.5 })
|
} else {
|
Cookie.set("isMenuAuth", false, { expires: 0.5 })
|
}
|
commit('setUserTree', res.data ? res.data : [])
|
resolve()
|
}).catch(error => {
|
commit('logout')
|
reject(error)
|
})
|
})
|
},
|
// 清空登录信息
|
clearLoginInfo: ({ commit }) => (commit('logout'))
|
}
|