neko/client/src/store/client.ts
2020-02-04 15:37:56 +00:00

33 lines
739 B
TypeScript

import { getterTree, mutationTree, actionTree } from 'typed-vuex'
import { get, set } from '~/utils/localstorage'
export const namespaced = true
export const state = () => ({
side: get<boolean>('side', false),
tab: get<string>('tab', 'chat'),
about: false,
about_page: '',
})
export const getters = getterTree(state, {})
export const mutations = mutationTree(state, {
setTab(state, tab: string) {
state.tab = tab
set('tab', tab)
},
setAbout(state, page: string) {
state.about_page = page
},
toggleAbout(state) {
state.about = !state.about
},
toggleSide(state) {
state.side = !state.side
set('side', state.side)
},
})
export const actions = actionTree({ state, getters, mutations }, {})