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,
|
2019-01-02 18:01:36 +01:00
|
|
|
leftDrawerOpen: true,
|
2019-01-29 23:13:28 +01:00
|
|
|
posts: [],
|
|
|
|
|
listatodo: [
|
|
|
|
|
{namecat: 'personal', description: 'personal'},
|
|
|
|
|
{namecat: 'work', description: 'work'},
|
|
|
|
|
{namecat: 'shopping', description: 'shopping'}
|
|
|
|
|
]
|
2018-11-15 19:48:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const b = storeBuilder.module<IGlobalState>('GlobalModule', state)
|
|
|
|
|
|
|
|
|
|
// Getters
|
|
|
|
|
namespace Getters {
|
|
|
|
|
|
2018-12-26 21:02:16 +01:00
|
|
|
const conta = b.read(state => state.conta, 'conta')
|
2019-01-29 23:13:28 +01:00
|
|
|
const listatodo = b.read(state => state.listatodo, 'listatodo')
|
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()
|
2019-01-29 23:13:28 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
get listaTodo() {
|
|
|
|
|
return listatodo()
|
2018-12-22 18:42:00 +01:00
|
|
|
}
|
2018-11-15 19:48:37 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace Mutations {
|
|
|
|
|
|
|
|
|
|
function setConta(state: IGlobalState, num: number) {
|
|
|
|
|
state.conta = num
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-02 18:01:36 +01:00
|
|
|
function setleftDrawerOpen(state: IGlobalState, bool: boolean) {
|
|
|
|
|
state.leftDrawerOpen = bool
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-15 19:48:37 +01:00
|
|
|
export const mutations = {
|
2019-01-02 18:01:36 +01:00
|
|
|
setConta: b.commit(setConta),
|
|
|
|
|
setleftDrawerOpen: b.commit(setleftDrawerOpen)
|
2018-11-15 19:48:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 = {
|
2018-12-26 21:02:16 +01:00
|
|
|
get state() {
|
|
|
|
|
return stateGetter()
|
|
|
|
|
},
|
2018-11-15 19:48:37 +01:00
|
|
|
getters: Getters.getters,
|
|
|
|
|
mutations: Mutations.mutations,
|
|
|
|
|
actions: Actions.actions
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default GlobalModule
|
|
|
|
|
|