mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
657 B
33 lines
657 B
'use strict'
|
|
|
|
import _ from 'lodash'
|
|
|
|
export default {
|
|
state: {
|
|
shown: false,
|
|
style: 'green',
|
|
icon: 'check',
|
|
msg: ''
|
|
},
|
|
getters: {},
|
|
mutations: {
|
|
alertChange: (state, opts) => {
|
|
state.shown = (opts.shown === true)
|
|
state.style = opts.style || 'green'
|
|
state.icon = opts.icon || 'check'
|
|
state.msg = opts.msg || ''
|
|
}
|
|
},
|
|
actions: {
|
|
alert({ commit, dispatch }, opts) {
|
|
opts.shown = true
|
|
commit('alertChange', opts)
|
|
dispatch('alertDismiss')
|
|
},
|
|
alertDismiss: _.debounce(({ commit }) => {
|
|
let opts = { shown: false }
|
|
commit('alertChange', opts)
|
|
}, 3000)
|
|
}
|
|
}
|