error.js 747 字节
Newer Older
M
MicroMilo 已提交
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
export default {
    namespaced: true,
    state: {
        logs: []
    },
    mutations: {
        ADD_ERROR_LOG: (state, log) => {
            state.logs.unshift(log)
        },
        CLEAR_ERROR_LOG: (state) => {
            state.logs.splice(0)
        }
    },
    actions: {
        add({
            commit
        }, log) {
            if (!log.route) {
                const pages = getCurrentPages()
                if (pages.length) {
                    log.route = pages[pages.length - 1].route
                }
            }
            log.route = '/' + (log.route || '')
            commit('ADD_ERROR_LOG', log)
        },
        clear({
            commit
        }) {
            commit('CLEAR_ERROR_LOG')
        }
    }
}