2018-11-26 00:53:05 +01:00
|
|
|
import { IGlobalState } from 'model'
|
2018-11-17 21:07:07 +01:00
|
|
|
import { storeBuilder } from './Store/Store'
|
|
|
|
|
|
2018-11-15 19:48:37 +01:00
|
|
|
|
|
|
|
|
const state: IGlobalState = {
|
|
|
|
|
conta: 0,
|
|
|
|
|
isLoginPage: false,
|
|
|
|
|
layoutNeeded: true,
|
|
|
|
|
mobileMode: false,
|
|
|
|
|
menuCollapse: true,
|
|
|
|
|
posts: []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const b = storeBuilder.module<IGlobalState>('GlobalModule', state)
|
|
|
|
|
|
|
|
|
|
// Getters
|
|
|
|
|
namespace Getters {
|
|
|
|
|
|
2018-12-22 23:30:02 +01:00
|
|
|
const conta = b.read(state => state.conta , 'conta')
|
2018-12-22 18:42:00 +01:00
|
|
|
|
2018-11-15 19:48:37 +01:00
|
|
|
export const getters = {
|
2018-12-22 18:42:00 +01:00
|
|
|
get conta() {
|
|
|
|
|
return conta()
|
|
|
|
|
}
|
2018-11-15 19:48:37 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace Mutations {
|
|
|
|
|
|
|
|
|
|
function setConta(state: IGlobalState, num: number) {
|
|
|
|
|
state.conta = num
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const mutations = {
|
|
|
|
|
setConta: b.commit(setConta)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace Actions {
|
2018-11-17 20:32:28 +01:00
|
|
|
async function setConta(context, num: number) {
|
2018-11-15 19:48:37 +01:00
|
|
|
Mutations.mutations.setConta(num)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const actions = {
|
|
|
|
|
setConta: b.dispatch(setConta)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-22 23:30:02 +01:00
|
|
|
const stateGetter = b.state()
|
|
|
|
|
|
2018-11-15 19:48:37 +01:00
|
|
|
// Module
|
|
|
|
|
const GlobalModule = {
|
|
|
|
|
get state() { return stateGetter()},
|
|
|
|
|
getters: Getters.getters,
|
|
|
|
|
mutations: Mutations.mutations,
|
|
|
|
|
actions: Actions.actions
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default GlobalModule
|
|
|
|
|
|