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.
57 lines
1.2 KiB
57 lines
1.2 KiB
import _ from 'lodash'
|
|
import Vue from 'vue'
|
|
import Vuex from 'vuex'
|
|
import pathify from 'vuex-pathify' // eslint-disable-line import/no-duplicates
|
|
import { make } from 'vuex-pathify' // eslint-disable-line import/no-duplicates
|
|
|
|
import page from './page'
|
|
import site from './site'
|
|
|
|
Vue.use(Vuex)
|
|
|
|
const state = {
|
|
loadingStack: [],
|
|
notification: {
|
|
message: '',
|
|
style: 'primary',
|
|
icon: 'cached',
|
|
isActive: false
|
|
}
|
|
}
|
|
|
|
export default new Vuex.Store({
|
|
strict: process.env.NODE_ENV !== 'production',
|
|
plugins: [
|
|
pathify.plugin
|
|
],
|
|
state,
|
|
getters: {
|
|
isLoading: state => { return state.loadingStack.length > 0 }
|
|
},
|
|
mutations: {
|
|
...make.mutations(state),
|
|
loadingStart (state, stackName) {
|
|
state.loadingStack = _.union(state.loadingStack, [stackName])
|
|
},
|
|
loadingStop (state, stackName) {
|
|
state.loadingStack = _.without(state.loadingStack, stackName)
|
|
},
|
|
showNotification (state, opts) {
|
|
state.notification = _.defaults(opts, {
|
|
message: '',
|
|
style: 'primary',
|
|
icon: 'cached',
|
|
isActive: true
|
|
})
|
|
},
|
|
updateNotificationState (state, newState) {
|
|
state.notification.isActive = newState
|
|
}
|
|
},
|
|
actions: { },
|
|
modules: {
|
|
page,
|
|
site
|
|
}
|
|
})
|