fuliqi
2024-01-24 29c1e7eb5ac16e90d8991a86c1c071bc312ec8d9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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'))
}